static game #1
This commit is contained in:
+74
-86
@@ -16,7 +16,13 @@
|
||||
// Constructors/Destructors
|
||||
// ----
|
||||
|
||||
Ari::Ari() {}
|
||||
const u8 WATER_TILES_COUNT = 64;
|
||||
|
||||
Ari::Ari(const Engine &t_engine) : engine(t_engine), camera(&engine.screen)
|
||||
{
|
||||
waterFloors = new Mesh[WATER_TILES_COUNT];
|
||||
spirals = new Point[WATER_TILES_COUNT];
|
||||
}
|
||||
|
||||
Ari::~Ari() {}
|
||||
|
||||
@@ -24,13 +30,74 @@ Ari::~Ari() {}
|
||||
// Methods
|
||||
// ----
|
||||
|
||||
// TEST START
|
||||
const u8 WATER_TILES_COUNT = 64;
|
||||
Mesh *island, *islandAddons, *skybox, *test;
|
||||
Mesh **waterFloors;
|
||||
Point *spirals;
|
||||
void Ari::onInit()
|
||||
{
|
||||
|
||||
void calcSpiral(int X, int Y)
|
||||
engine.renderer->setCameraDefinitions(&camera.worldView, &camera.unitCirclePosition, camera.planes);
|
||||
engine.audio.init(0);
|
||||
engine.audio.setVolume(40);
|
||||
engine.audio.loadSong("MOV-CIRC.WAV");
|
||||
engine.audio.play();
|
||||
|
||||
texRepo = engine.renderer->getTextureRepository();
|
||||
|
||||
island.loadDff("sunnyisl/", "sunnyisl", 0.1F, false);
|
||||
island.rotation.x = -1.6F;
|
||||
island.position.set(0.0F, 10.0F, 20.0F);
|
||||
island.shouldBeBackfaceCulled = true;
|
||||
island.shouldBeFrustumCulled = false;
|
||||
|
||||
islandAddons.loadDff("sunnyisl/", "sunnyisl3", 0.1F, false);
|
||||
islandAddons.rotation.x = -1.6F;
|
||||
islandAddons.position.set(0.0F, 10.0F, 20.0F);
|
||||
|
||||
skybox.loadObj("skybox/", "skybox", 100.0F, false);
|
||||
skybox.shouldBeFrustumCulled = false;
|
||||
|
||||
waterFloors[0].loadObj("water/", "water", 5.0F, false);
|
||||
waterFloors[0].position.set(0.0F, 8.0F, 0.0F);
|
||||
texRepo->addByMesh("water/", waterFloors[0]);
|
||||
for (u8 i = 0; i < WATER_TILES_COUNT; i++)
|
||||
{
|
||||
spirals[i].x = 1.0F;
|
||||
spirals[i].y = 2.0F;
|
||||
}
|
||||
u32 spiralOffset = (u32)Math::sqrt(WATER_TILES_COUNT);
|
||||
calcSpiral(spiralOffset, spiralOffset);
|
||||
for (u8 i = 1; i < WATER_TILES_COUNT; i++)
|
||||
{
|
||||
waterFloors[i].loadFrom(waterFloors[0]);
|
||||
waterFloors[i].position.set(10.0F * spirals[i].x, 8.0F, 10.0F * spirals[i].y);
|
||||
texRepo->getByMesh(waterFloors[0].getId(), waterFloors[0].getMaterial(0).getId())
|
||||
->addLink(waterFloors[i].getId(), waterFloors[i].getMaterial(0).getId());
|
||||
}
|
||||
|
||||
texRepo->addByMesh("sunnyisl/", island);
|
||||
texRepo->addByMesh("sunnyisl/", islandAddons);
|
||||
texRepo->addByMesh("skybox/", skybox);
|
||||
texRepo->addByMesh("ari/", player.mesh);
|
||||
}
|
||||
|
||||
void Ari::initBulb()
|
||||
{
|
||||
bulb.intensity = 15;
|
||||
bulb.position.set(5.0F, 10.0F, 10.0F);
|
||||
}
|
||||
|
||||
void Ari::onUpdate()
|
||||
{
|
||||
if (engine.pad.isCrossClicked)
|
||||
printf("FPS:%f\n", engine.fps);
|
||||
camera.update(engine.pad, player.mesh);
|
||||
engine.renderer->draw(skybox);
|
||||
engine.renderer->draw(island);
|
||||
engine.renderer->draw(islandAddons);
|
||||
engine.renderer->draw(player.mesh);
|
||||
for (u8 i = 0; i < WATER_TILES_COUNT; i++)
|
||||
engine.renderer->draw(waterFloors[i]);
|
||||
}
|
||||
|
||||
void Ari::calcSpiral(int X, int Y)
|
||||
{
|
||||
int x, y, dx;
|
||||
x = y = dx = 0;
|
||||
@@ -54,82 +121,3 @@ void calcSpiral(int X, int Y)
|
||||
y += dy;
|
||||
}
|
||||
}
|
||||
// TEST END
|
||||
|
||||
// TODO 1 - const & in parameters
|
||||
// TODO 2 - Destructor mesh
|
||||
|
||||
void Ari::onInit()
|
||||
{
|
||||
player = new Player();
|
||||
camera = new Camera(&engine.screen);
|
||||
engine.renderer->setCameraDefinitions(&camera->worldView, &camera->unitCirclePosition, camera->planes);
|
||||
engine.audio.init(0);
|
||||
engine.audio.setVolume(40);
|
||||
engine.audio.loadSong("MOV-CIRC.WAV");
|
||||
engine.audio.play();
|
||||
|
||||
texRepo = engine.renderer->getTextureRepository();
|
||||
|
||||
island = new Mesh();
|
||||
island->loadDff("sunnyisl/", "sunnyisl", 0.1F, false);
|
||||
island->rotation.x = -1.6F;
|
||||
island->position.set(0.0F, 10.0F, 20.0F);
|
||||
island->shouldBeBackfaceCulled = true;
|
||||
island->shouldBeFrustumCulled = false;
|
||||
|
||||
islandAddons = new Mesh();
|
||||
islandAddons->loadDff("sunnyisl/", "sunnyisl3", 0.1F, false);
|
||||
islandAddons->rotation.x = -1.6F;
|
||||
islandAddons->position.set(0.0F, 10.0F, 20.0F);
|
||||
|
||||
skybox = new Mesh();
|
||||
skybox->loadObj("skybox/", "skybox", 100.0F, false);
|
||||
skybox->shouldBeFrustumCulled = false;
|
||||
|
||||
waterFloors = new Mesh *[WATER_TILES_COUNT];
|
||||
spirals = new Point[WATER_TILES_COUNT];
|
||||
waterFloors[0] = new Mesh();
|
||||
waterFloors[0]->loadObj("water/", "water", 5.0F, false);
|
||||
waterFloors[0]->position.set(0.0F, 8.0F, 0.0F);
|
||||
texRepo->addByMesh("water/", *waterFloors[0]);
|
||||
for (u8 i = 0; i < WATER_TILES_COUNT; i++)
|
||||
{
|
||||
spirals[i].x = 1.0F;
|
||||
spirals[i].y = 2.0F;
|
||||
}
|
||||
u32 spiralOffset = (u32)Math::sqrt(WATER_TILES_COUNT);
|
||||
calcSpiral(spiralOffset, spiralOffset);
|
||||
for (u8 i = 1; i < WATER_TILES_COUNT; i++)
|
||||
{
|
||||
waterFloors[i] = new Mesh();
|
||||
waterFloors[i]->loadFrom(*waterFloors[0]);
|
||||
waterFloors[i]->position.set(10.0F * spirals[i].x, 8.0F, 10.0F * spirals[i].y);
|
||||
texRepo->getByMesh(waterFloors[0]->getId(), waterFloors[0]->getMaterial(0).getId())
|
||||
->addLink(waterFloors[i]->getId(), waterFloors[i]->getMaterial(0).getId());
|
||||
}
|
||||
|
||||
texRepo->addByMesh("sunnyisl/", *island);
|
||||
texRepo->addByMesh("sunnyisl/", *islandAddons);
|
||||
texRepo->addByMesh("skybox/", *skybox);
|
||||
texRepo->addByMesh("ari/", player->mesh);
|
||||
}
|
||||
|
||||
void Ari::initBulb()
|
||||
{
|
||||
bulb.intensity = 15;
|
||||
bulb.position.set(5.0F, 10.0F, 10.0F);
|
||||
}
|
||||
|
||||
void Ari::onUpdate()
|
||||
{
|
||||
if (engine.pad.isCrossClicked)
|
||||
printf("FPS:%f\n", engine.fps);
|
||||
camera->update(engine.pad, player->mesh);
|
||||
engine.renderer->draw(skybox);
|
||||
engine.renderer->draw(island);
|
||||
engine.renderer->draw(islandAddons);
|
||||
engine.renderer->draw(&player->mesh);
|
||||
for (u8 i = 0; i < WATER_TILES_COUNT; i++)
|
||||
engine.renderer->draw(waterFloors[i]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user