Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "MyGame.h"
- #include <fstream>
- using namespace std;
- CMyGame::CMyGame(void) {}
- CMyGame::~CMyGame(void) {}
- // -------- game initialisation --------
- void CMyGame::OnInitialize()
- {
- // Loading graphics and sound assets
- cout << "Loading assets" << endl;
- font.LoadDefault();
- // enable lighting
- Light.Enable();
- // house model
- house.LoadModel("House.obj","House.bmp");
- // player model
- player.LoadModel("monkey.md2","brute.bmp");
- player.SetScale( 1.0f);
- player.Rotate(90);
- // van model
- van.LoadModel("van.obj", "van.bmp");
- // enemy1 model
- enemy1.LoadModel("Abarlith.md2", "Abarlith.bmp");
- enemy1.SetScale(3.5f);
- enemy2.LoadModel("Abarlith.md2", "Abarlith.bmp");
- enemy2.SetScale(3.5f);
- enemy3.LoadModel("Abarlith.md2", "Abarlith.bmp");
- enemy3.SetScale(3.0f);
- enemy4.LoadModel("Abarlith.md2", "Abarlith.bmp");
- enemy4.SetScale(3.0f);
- enemy5.LoadModel("Abarlith.md2", "Abarlith.bmp");
- enemy5.SetScale(3.0f);
- enemy6.LoadModel("Abarlith.md2", "Abarlith.bmp");
- enemy6.SetScale(3.0f);
- // wall model
- wall.LoadModel("jungle_wall.obj", "wall2.bmp");
- // canopy model
- canopy.LoadModel("canopy.obj", "canopy.tga");
- // banana tree model
- banana.LoadModel("banana.obj", "banana.tga");
- // grass model
- grass.LoadModel("grass.obj", "grass.tga");
- // box model
- box.LoadModel("box.obj", "pallette.bmp");
- // box2 model
- box2.LoadModel("box2.obj", "box2.bmp");
- // barrel model
- barrel.LoadModel("barrel.obj", "pallette.bmp");
- // fence model
- fence.LoadModel("fence.obj", "fence.tga");
- // cage doors
- cage1.LoadModel("cage.obj", "bar.tga");
- cage1.SetScale(7.0f);
- cage2.LoadModel("cage.obj", "bar.tga");
- cage2.SetScale(7.0f);
- cage3.LoadModel("cage.obj", "bar.tga");
- cage3.SetScale(7.0f);
- cage4.LoadModel("cage.obj", "bar.tga");
- cage4.SetScale(7.0f);
- // shack model
- shack.LoadModel("shack.obj", "shack.bmp");
- // watchtower model
- watchtower.LoadModel("watchtower.obj", "watchtower.bmp");
- // track model
- track.LoadModel("track.obj", "track.tga");
- // rain model
- rain.LoadModel("rain.obj", "rain.tga");
- rain.SetScale(1.0f);
- // cage switch models
- cage_switch1.LoadModel("switch.obj", "switch.bmp");
- cage_switch1.SetScale(7.0f);
- cage_switch2.LoadModel("switch.obj", "switch.bmp");
- cage_switch2.SetScale(7.0f);
- cage_switch3.LoadModel("switch.obj", "switch.bmp");
- cage_switch3.SetScale(7.0f);
- cage_switch4.LoadModel("switch.obj", "switch.bmp");
- cage_switch4.SetScale(7.0f);
- // floor texture
- floor.LoadTexture("floor.bmp");
- floor.SetTiling(true);
- // Load skydome geometry and texture
- skydome.LoadModel("Skydome.obj", "Skydome2.bmp");
- skydome.SetScale(300);
- skydome.SetY(-800.0f);
- // start screen
- startScreen.LoadImage("startScreen.bmp");
- startScreen.SetPosition(Width/2.0f,Height/2.0f);
- level=1;
- // lightning sprite
- lightning.LoadImage("lightningloop.bmp", CColor::Black(), 6);
- lightning.SetPosition(Width / 2.0f, Height / 2.0f);
- }
- void CMyGame::OnStartLevel(int level)
- {
- score = 0;
- floor.SetSize(9000,9000);
- IsPlaying.SetStatus(100);
- rains.clear();
- monkeys.clear();
- fstream input;
- input.open("model_positions.txt");
- do
- {
- input >> type >> x >> y >> z >> rot >> dir >> scle;
- if (type == 1)
- {
- CModel* pHouse = house.clone();
- pHouse->SetPosition((float)x, (float)y, (float)z);
- pHouse->Rotate((float)rot);
- pHouse->SetDirection((float)dir);
- pHouse->SetScale((float)scle);
- houses.push_back(pHouse);
- }
- else if (type == 2)
- {
- CModel* pWall = wall.clone();
- pWall->SetPosition((float)x, (float)y, (float)z);
- pWall->Rotate((float)rot);
- pWall->SetDirection((float)dir);
- pWall->SetScale((float)scle);
- walls.push_back(pWall);
- }
- else if (type == 3)
- {
- CModel* pCanopy = canopy.clone();
- pCanopy->SetPosition((float)x, (float)y, (float)z);
- pCanopy->Rotate((float)rot);
- pCanopy->SetDirection(float(rand() % 360));
- pCanopy->SetScale((float)scle);
- canopys.push_back(pCanopy);
- }
- else if (type == 4)
- {
- CModel* pBanana = banana.clone();
- pBanana->SetPosition((float)x, (float)y, (float)z);
- pBanana->Rotate((float)rot);
- pBanana->SetDirection((float)dir);
- pBanana->SetScale((float)scle);
- bananas.push_back(pBanana);
- }
- else if (type == 5)
- {
- CModel* pGrass = grass.clone();
- pGrass->SetPosition((float)x, (float)y, (float)z);
- pGrass->Rotate((float)rot);
- pGrass->SetDirection(float(rand() % 360));
- pGrass->SetScale((float)scle);
- grasses.push_back(pGrass);
- }
- else if (type == 6)
- {
- CModel* pBox = box.clone();
- pBox->SetPosition((float)x, (float)y, (float)z);
- pBox->Rotate((float)rot);
- pBox->SetDirection((float)dir);
- pBox->SetScale((float)scle);
- boxes.push_back(pBox);
- }
- else if (type == 7)
- {
- CModel* pBox2 = box2.clone();
- pBox2->SetPosition((float)x, (float)y, (float)z);
- pBox2->Rotate((float)rot);
- pBox2->SetDirection((float)dir);
- pBox2->SetScale((float)scle);
- boxes2.push_back(pBox2);
- }
- else if (type == 8)
- {
- CModel* pBarrel = barrel.clone();
- pBarrel->SetPosition((float)x, (float)y, (float)z);
- pBarrel->Rotate((float)rot);
- pBarrel->SetDirection((float)dir);
- pBarrel->SetScale((float)scle);
- barrels.push_back(pBarrel);
- }
- else if (type == 9)
- {
- CModel* pVan = van.clone();
- pVan->SetPosition((float)x, (float)y, (float)z);
- pVan->Rotate((float)rot);
- pVan->SetDirection((float)dir);
- pVan->SetScale((float)scle);
- vans.push_back(pVan);
- }
- else if (type == 10)
- {
- CModel* pFence = fence.clone();
- pFence->SetPosition((float)x, (float)y, (float)z);
- pFence->Rotate((float)rot);
- pFence->SetDirection((float)dir);
- pFence->SetScale((float)scle);
- fences.push_back(pFence);
- }
- else if (type == 11)
- {
- CModel* pShack = shack.clone();
- pShack->SetPosition((float)x, (float)y, (float)z);
- pShack->Rotate((float)rot);
- pShack->SetDirection((float)dir);
- pShack->SetScale((float)scle);
- shacks.push_back(pShack);
- }
- else if (type == 12)
- {
- CModel* pWatchtower = watchtower.clone();
- pWatchtower->SetPosition((float)x, (float)y, (float)z);
- pWatchtower->Rotate((float)rot);
- pWatchtower->SetDirection((float)dir);
- pWatchtower->SetScale((float)scle);
- watchtowers.push_back(pWatchtower);
- }
- else if (type == 13)
- {
- CModel* pTrack = track.clone();
- pTrack->SetPosition((float)x, (float)y, (float)z);
- pTrack->Rotate((float)rot);
- pTrack->SetDirection((float)dir);
- pTrack->SetScale((float)scle);
- tracks.push_back(pTrack);
- }
- else if (type == 14)
- {
- CModel* pMonkey = player.clone();
- pMonkey->SetPosition((float)x, (float)y, (float)z);
- pMonkey->Rotate((float)rot);
- pMonkey->SetDirection((float)dir);
- pMonkey->SetScale((float)scle);
- monkeys.push_back(pMonkey);
- pMonkey->PlayAnimation(1, 3, 6, true);
- }
- } while (!input.eof());
- input.close();
- // --- grass positions ---
- for (int n = 1; n <= 200; n++)
- {
- CModel* pGrass = grass.clone();
- pGrass->SetDirection(float(rand() % 360));
- pGrass->Move(rand() % 1800);
- grasses.push_back(pGrass);
- }
- // --- cage positions ---
- cage1.SetPosition(1300, 0, 0);
- cage2.SetPosition(-600, 0, -1195);
- cage3.SetPosition(350, 0, 650);
- cage4.SetPosition(200, 0, 1150);
- // --- cage switch positions ---
- cage_switch1.SetPosition(1200, 0, -200);
- cage_switch1.Rotate(-90);
- cage_switch2.SetPosition(-400, 0, -1095);
- cage_switch3.SetPosition(200, 0, 400);
- cage_switch3.Rotate(180);
- cage_switch4.SetPosition(100, 0, 1000);
- cage_switch4.Rotate(-90);
- // --- enemy positions ---
- // watchtower enemies (non-active)
- enemy1.SetPosition(350, 400, -1250);
- enemy1.Rotate(-90);
- enemy1.SetScale(2.3f);
- enemy1.PlayAnimation(1, 39, 7, true);
- enemy2.SetPosition(-1300, 400, -1250);
- enemy2.Rotate(-90);
- enemy2.SetScale(2.3f);
- enemy2.PlayAnimation(1, 39, 7, true);
- // active enemies
- enemy3.SetPosition(900, 65, -400);
- enemy4.SetPosition(-600, 65, -850);
- enemy5.SetPosition(-1200, 65, 300);
- enemy6.SetPosition(-375, 65, 1325);
- // --- enemy path positions ---
- // path number reflects enemy number
- path3.push_back(CVector(900, 0, -400));
- path3.push_back(CVector(900, 0, 1000));
- path4.push_back(CVector(-600, 0, -850));
- path4.push_back(CVector(300, 0, -850));
- path5.push_back(CVector(-1200, 0, 300));
- path5.push_back(CVector(200, 0, 300));
- path6.push_back(CVector(-375, 65, 1325));
- path6.push_back(CVector(-375, 65, 1325));
- // --- player position ---
- player.SetPosition(1200, 0, 1200);
- // --- setup healthbar ---
- hbar.SetSize(100,15);
- hbar.SetPosition(830,680);
- hbar.SetHealth(100);
- // --- enemy dist bar ---
- enemydist.SetColor(CColor::Cyan());
- enemydist.SetSize(100, 15);
- enemydist.SetPosition(830, 660);
- enemydist.SetHealth(100);
- // --- background sounds ---
- rainsound.Play("rain.wav", -1);
- }
- void CMyGame::AddDistBar()
- {
- if (gtd3 > 800 && gtd3 < 900 || gtd4 > 800 && gtd4 < 900 || gtd5 > 800 && gtd5 < 900 || gtd6 > 800 && gtd6 < 900) enemydist.SetHealth(83);
- if (gtd3 > 700 && gtd3 < 800 || gtd4 > 700 && gtd4 < 800 || gtd5 > 700 && gtd5 < 800 || gtd6 > 700 && gtd6 < 800) enemydist.SetHealth(66);
- if (gtd3 > 600 && gtd3 < 700 || gtd4 > 600 && gtd4 < 700 || gtd5 > 600 && gtd5 < 700 || gtd6 > 600 && gtd6 < 700) enemydist.SetHealth(49);
- if (gtd3 > 500 && gtd3 < 600 || gtd4 > 500 && gtd4 < 600 || gtd5 > 500 && gtd5 < 600 || gtd6 > 500 && gtd6 < 600) enemydist.SetHealth(32);
- if (gtd3 > 400 && gtd3 < 500 || gtd4 > 400 && gtd4 < 500 || gtd5 > 400 && gtd5 < 500 || gtd6 > 400 && gtd6 < 500) enemydist.SetHealth(15);
- if (gtd3 > 300 && gtd3 < 400 || gtd4 > 300 && gtd4 < 400 || gtd5 > 300 && gtd5 < 400 || gtd6 > 300 && gtd6 < 400) enemydist.SetHealth(0);
- }
- void CMyGame::AddRain()
- {
- // --- simulating rain ---
- if (rains.size() < 4200)
- {
- if (rand() % 5 == 1) // initial spawn rate
- {
- for (int n = 1; n <= 1200; n++)
- {
- if (rand() % 20 == 1) // chance of rain to spawn at different heights
- {
- CModel* pRain = rain.clone();
- pRain->Rotate(float(rand() % 360));
- pRain->SetYVelocity(-600);
- rains.push_back(pRain);
- }
- }
- }
- }
- for (CModel* pRain : rains) if (pRain->GetY() < 20) pRain->SetPosition(rand() % 2800 - 1400, 900, rand() % 2800 - 1400); // do not delete if Y < 20, just move back up at random XZ!! (fixes memory leak)
- rains.remove_if(deleted);
- }
- void CMyGame::AddLightning()
- {
- // --- simulating lightning ---
- if (rand() % 300 == 1) lightning.SetStatus(60); // 0.3% chance per frame for lightning strike
- if (lightning.GetStatus() > 58) // controlling the sprite life cycle and play sound because even if animation loop = false, still continues to loop(..?)
- {
- lightning.PlayAnimation(1, 6, 6, false);
- lightning.SetStatus(lightning.GetStatus() - 1);
- }
- if (lightning.GetStatus() <= 0) lightning.Delete();
- }
- void CMyGame::EnemyControl(CModelMd2* a, CModelMd2* b, vector<CVector>* c, float* d)
- {
- a = &player;
- float dx = a->GetX() - b->GetX();
- float dz = a->GetZ() - b->GetZ();
- float td = sqrt(dx * dx + dz * dz); // distance between player and enemy3 ('distance' function not working)
- if (b->IsAutoMoving()) b->PlayAnimation(40, 45, 5, true); // is moving, play run animation
- else if (td < 300) b->PlayAnimation(123, 134, 5, true); // is player close, point animation
- else b->PlayAnimation(1, 39, 7, true); // is not, play standing animation
- if (td > 300) // path finding
- {
- if (!b->IsAutoMoving() && b->GetStatus() < c->size())
- {
- if (c == &path3)
- {
- CVector v = path3[b->GetStatus()];
- b->SetStatus(b->GetStatus() + 1);
- if (rand() % 90 == 1) b->MoveTo(v.x, v.z, 150); // random delay for playability and realism
- }
- else if (c == &path4)
- {
- CVector v = path4[b->GetStatus()];
- b->SetStatus(b->GetStatus() + 1);
- if (rand() % 90 == 1) b->MoveTo(v.x, v.z, 150);
- }
- else if (c == &path5)
- {
- CVector v = path5[b->GetStatus()];
- b->SetStatus(b->GetStatus() + 1);
- if (rand() % 90 == 1) b->MoveTo(v.x, v.z, 150);
- }
- }
- if (!b->IsAutoMoving() && b->GetStatus() == c->size())
- {
- if (c == &path3)
- {
- b->SetStatus(0);
- CVector v = path3[b->GetStatus()];
- if (rand() % 90 == 1) b->MoveTo(v.x, v.z, 150);
- }
- if (c == &path4)
- {
- b->SetStatus(0);
- CVector v = path4[b->GetStatus()];
- if (rand() % 90 == 1) b->MoveTo(v.x, v.z, 150);
- }
- if (c == &path5)
- {
- b->SetStatus(0);
- CVector v = path5[b->GetStatus()];
- if (rand() % 90 == 1) b->MoveTo(v.x, v.z, 150);
- }
- }
- }
- else if (td < 300) // alert when player is near and take health
- {
- IsPlaying.SetStatus(IsPlaying.GetStatus() - 1);
- b->Stop();
- b->SetRotationToPoint(a->GetX(), a->GetZ());
- hbar.SetHealth(hbar.GetHealth() - 1);
- }
- if (td > 300 && td < 400) IsPlaying.SetStatus(100);
- *d = td;
- }
- void CMyGame::OnUpdate()
- {
- long t = GetTime();
- // --- controls ---
- PlayerControl();
- EnemyControl(&player, &enemy3, &path3, >d3);
- EnemyControl(&player, &enemy4, &path4, >d4);
- EnemyControl(&player, &enemy5, &path5, >d5);
- EnemyControl(&player, &enemy6, &path6, >d6);
- // --- rules ---
- if (IsMenuMode() || IsGameOver()) return;
- if (hbar.GetHealth() <= 0) GameOver();
- // win condition
- for (CModel* van : vans) if (player.HitTestFront(van) && score == 4)
- {
- win.Play("win.wav");
- rainsound.Stop();
- PauseGame();
- }
- // life recovery
- if (gtd3 > 900 && gtd4 > 900 && gtd5 > 900 && gtd6 > 900) hbar.SetHealth(hbar.GetHealth() + 1);
- else if (hbar.GetHealth() > 100) hbar.SetHealth(100);
- // timed alert sound
- if (IsPlaying.GetStatus() > 97 && IsPlaying.GetStatus() < 100) alert.Play("found.wav");
- // gameover sound
- if (IsGameOver())
- {
- rainsound.Stop();
- gameover.Play("gameover.wav");
- }
- // --- weather ---
- AddRain();
- AddLightning();
- // --- distance bar ---
- AddDistBar();
- // --- deletes ---
- if (cage1.GetY() < 300) cage1.Delete();
- else if (cage2.GetY() < 300) cage2.Delete();
- else if (cage3.GetY() < 300) cage3.Delete();
- else if (cage4.GetY() < 300) cage4.Delete();
- monkeys.remove_if(deleted);
- // --- updating models ---
- player.Update(t);
- enemy1.Update(t);
- enemy2.Update(t);
- enemy3.Update(t);
- enemy4.Update(t);
- enemy5.Update(t);
- enemy6.Update(t);
- cage1.Update(t);
- cage2.Update(t);
- cage3.Update(t);
- cage4.Update(t);
- monkeys.Update(t);
- rains.Update(t);
- lightning.Update(t);
- }
- void CMyGame::PlayerControl()
- {
- // --- player control ---
- if (IsKeyDown(SDLK_w)) player.SetSpeed(300);
- else player.SetSpeed(0);
- if (IsKeyDown(SDLK_a))
- {
- player.Rotate(5);
- player.SetDirection(player.GetRotation());
- rotation -= 5;
- }
- if (IsKeyDown(SDLK_d))
- {
- player.Rotate(-5);
- player.SetDirection(player.GetRotation());
- rotation += 5;
- }
- // --- player animation ---
- if (IsKeyDown(SDLK_w)) player.PlayAnimation(4,8,10,true);
- else player.PlayAnimation(1,3,6,true);
- // --- hittesting ---
- if (player.HitTestFront(&cage1) || player.HitTestFront(&cage2) || player.HitTestFront(&cage3) || player.HitTestFront(&cage4)
- || player.HitTestFront(&cage_switch1) || player.HitTestFront(&cage_switch2) || player.HitTestFront(&cage_switch3) || player.HitTestFront(&cage_switch4)) player.SetSpeed(0);
- for (CModel* pWall : walls) if (player.HitTestFront(pWall)) player.SetSpeed(0);
- for (CModel* pBox : boxes) if (player.HitTestFront(pBox)) player.SetSpeed(0);
- for (CModel* pBox2 : boxes2) if (player.HitTestFront(pBox2)) player.SetSpeed(0);
- for (CModel* pBarrel : barrels) if (player.HitTestFront(pBarrel)) player.SetSpeed(0);
- for (CModel* pVan : vans) if (player.HitTestFront(pVan)) player.SetSpeed(0);
- for (CModel* pFence : fences) if (player.HitTestFront(pFence)) player.SetSpeed(0);
- for (CModel* pHouse : houses) if (player.HitTestFront(pHouse)) player.SetSpeed(0);
- for (CModel* pMonkey : monkeys) if (player.HitTestFront(pMonkey)) player.SetSpeed(0);
- }
- //----------------- Draw 2D overlay ----------------------
- void CMyGame::OnDraw(CGraphics* g)
- {
- if (IsMenuMode())
- {
- startScreen.Draw(g);
- return;
- }
- // lightning and UI
- if (lightning.GetStatus() > 0) lightning.Draw(g);
- if (gtd3 < 900 || gtd4 < 900 || gtd5 < 900 || gtd6 < 900) enemydist.Draw(g);
- hbar.Draw(g);
- // score
- font.SetSize(32); font.SetColor( CColor::Red()); font.DrawNumber(10,Height-50, score), font.DrawText(28, Height - 50, "/4");
- if (IsGameOver())
- {
- font.SetSize(64); font.SetColor( CColor::Red()); font.DrawText(300,300, "GAME OVER");
- }
- for (CModel* van : vans) if (player.HitTestFront(van) && score != 4)
- {
- font.SetSize(44); font.SetColor(CColor::Blue()); font.DrawText(Width/2 - 250, Height/2, "leave no monkey behind!");
- }
- for (CModel* van : vans) if (player.HitTestFront(van) && score == 4)
- {
- font.SetSize(44); font.SetColor(CColor::Blue()); font.DrawText(Width / 2 - 200, Height / 2, "we're outta here!");
- }
- }
- // ---------------- Draw 3D world -------------------------
- void CMyGame::OnRender3D(CGraphics* g)
- {
- CameraControl(g);
- floor.Draw(g);
- enemy1.Draw(g);
- enemy2.Draw(g);
- enemy3.Draw(g);
- enemy4.Draw(g);
- enemy5.Draw(g);
- enemy6.Draw(g);
- player.Draw(g);
- walls.Draw(g);
- skydome.Draw(g);
- canopys.Draw(g);
- bananas.Draw(g);
- grasses.Draw(g);
- boxes.Draw(g);
- barrels.Draw(g);
- vans.Draw(g);
- fences.Draw(g);
- shacks.Draw(g);
- monkeys.Draw(g);
- boxes2.Draw(g);
- houses.Draw(g);
- watchtowers.Draw(g);
- tracks.Draw(g);
- rains.Draw(g);
- cage_switch1.Draw(g);
- cage_switch2.Draw(g);
- cage_switch3.Draw(g);
- cage_switch4.Draw(g);
- cage1.Draw(g);
- cage2.Draw(g);
- cage3.Draw(g);
- cage4.Draw(g);
- ShowCoordinateSystem();
- }
- void CMyGame::CameraControl(CGraphics* g)
- {
- // game world tilt
- // ------ Global Transformation Functions -----
- glTranslatef(0, -300, 800); // move game world down
- glRotatef(tilt, 1, 0, 0); // tilt game world around x axis
- glScalef(scale, scale, scale); // scaling the game world
- glRotatef(rotation, 0, 1, 0); // rotating the game world
- // ---- 3rd person camera setup -----
- // translate game world to player position
- glTranslatef(-player.GetX(), 0, -player.GetZ());
- UpdateView();
- Light.Apply();
- }
- // called at the start of a new game - display menu here
- void CMyGame::OnDisplayMenu()
- {
- }
- // called when Game Mode entered
- void CMyGame::OnStartGame()
- {
- OnStartLevel(1);
- }
- // called when Game is Over
- void CMyGame::OnGameOver()
- {
- }
- // one time termination code
- void CMyGame::OnTerminate()
- {
- }
- // ------- Keyboard Event Handling ------------
- void CMyGame::OnKeyDown(SDLKey sym, SDLMod mod, Uint16 unicode)
- {
- if (sym == SDLK_F4 && (mod & (KMOD_LALT | KMOD_RALT)))
- StopGame();
- if (sym == SDLK_SPACE)
- {
- if (IsPaused()) ResumeGame();
- else PauseGame();
- }
- if (sym == SDLK_F2)
- {
- NewGame();
- rainsound.Clear();
- }
- if (sym == SDLK_e)
- {
- if (player.HitTest(&cage_switch1) && cage1.GetStatus() == 0) { cageopen.Play("cageopen.wav"); cage1.Open(); }
- if (player.HitTest(&cage_switch2) && cage2.GetStatus() == 0) { cageopen.Play("cageopen.wav"); cage2.Open(); }
- if (player.HitTest(&cage_switch3) && cage3.GetStatus() == 0) { cageopen.Play("cageopen.wav"); cage3.Open(); }
- if (player.HitTest(&cage_switch4) && cage4.GetStatus() == 0) { cageopen.Play("cageopen.wav"); cage4.Open(); }
- for (CModel* pMonkey : monkeys)
- if (player.HitTest(pMonkey))
- {
- score++;
- collect.Play("collect.wav");
- pMonkey->Delete();
- }
- }
- // --- camera control testing ---
- if (sym == SDLK_LEFT)
- tilt += 5;
- if (sym == SDLK_RIGHT)
- tilt -= 5;
- if (sym == SDLK_UP)
- scale += 1.0f;
- if (sym == SDLK_DOWN)
- scale -= 1.0f;
- }
- void CMyGame::OnKeyUp(SDLKey sym, SDLMod mod, Uint16 unicode)
- {
- }
- // ----- Mouse Events Handlers -------------
- void CMyGame::OnMouseMove(Uint16 x,Uint16 y,Sint16 relx,Sint16 rely,bool bLeft,bool bRight,bool bMiddle)
- {
- }
- void CMyGame::OnLButtonDown(Uint16 x,Uint16 y)
- {
- if (IsMenuMode()) StartGame();
- }
- void CMyGame::OnLButtonUp(Uint16 x,Uint16 y)
- {
- }
- void CMyGame::OnRButtonDown(Uint16 x,Uint16 y)
- {
- }
- void CMyGame::OnRButtonUp(Uint16 x,Uint16 y)
- {
- }
- void CMyGame::OnMButtonDown(Uint16 x,Uint16 y)
- {
- }
- void CMyGame::OnMButtonUp(Uint16 x,Uint16 y)
- {
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement