Advertisement
Guest User

Untitled

a guest
Mar 29th, 2017
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 23.87 KB | None | 0 0
  1. #include <trymacro.h>
  2.  
  3. #include "engine.h"
  4. #include "input.h"
  5.  
  6. void resizeConsole()
  7. {
  8. HWND console = GetConsoleWindow();
  9. RECT r;
  10. GetWindowRect(console, &r);
  11. MoveWindow(console, r.left, r.top, 640, 640, TRUE);
  12. }
  13.  
  14. mango::int32 main()
  15. {
  16. M_TRY
  17. {
  18. resizeConsole();
  19.  
  20. engine::Game::game_handle game = new engine::Game();
  21. game->Play();
  22. }
  23. M_CATCH("main.txt")
  24. }
  25.  
  26. //M_TRY {} M_CATCH(main.txt) --> try catch block to catch
  27. //mango::exception:: and critical errors and logging them to main.txt.
  28.  
  29. #ifndef GUARD_MANGO_TYPEDEFS_H
  30. #define GUARD_MANGO_TYPEDEFS_H
  31.  
  32. #define NO_THREAD_ALLOC //disables thread_safety in my customallocator for better performance since this project is single threaded and locks are not needed (will be removed for multithreaded implementation)
  33. #include <Gaming/pixelutility.h>
  34.  
  35. namespace engine
  36. {
  37. typedef const mango::int32 const_size;
  38. typedef mango::archive::thread_pool thread_pool;
  39. typedef mango::shared_ptr<thread_pool> pool_ptr;
  40. typedef mango::int32 colour;
  41. typedef mango::int32 counter;
  42. typedef mango::int64 large_counter;
  43. typedef mango::delta_timer timer;
  44. typedef double seconds;
  45. typedef graphic::KatCoord point;
  46.  
  47. typedef graphic::Character player;
  48. typedef graphic::Character actor;
  49. typedef graphic::Character enemy;
  50. typedef graphic::Character effect;
  51. typedef graphic::Character background;
  52.  
  53. typedef mango::shared_ptr<player> player_handle;
  54. typedef mango::shared_ptr<actor> actor_handle;
  55. typedef mango::shared_ptr<enemy> enemy_handle;
  56. typedef mango::shared_ptr<effect> effect_handle;
  57. typedef mango::shared_ptr<background> background_handle;
  58.  
  59. typedef std::string mesh_name;
  60.  
  61. typedef mango::vector<actor_handle> actor_pipeline;
  62. typedef mango::semimap<mesh_name, actor_handle> sprite_pipeline;
  63. typedef mango::semimap<effect_handle, counter> effect_pipeline;
  64.  
  65. typedef graphic::GraphicController graphic_device;
  66. typedef mango::shared_ptr<graphic_device> graphic_handle;
  67.  
  68. typedef bool flag;
  69.  
  70. typedef mango::Byte key;
  71. typedef mango::queued_mutex lock;
  72. typedef mango::shared_ptr<lock> lock_handle;
  73. typedef mango::lock_guard<lock> lock_guard;
  74. }
  75.  
  76. #endif//GUARD_MANGO_TYPEDEFS_H
  77.  
  78. #ifndef GUARD_MANGO_INPUT_H
  79. #define GUARD_MANGO_INPUT_H
  80.  
  81. #include "typedefs.h"
  82.  
  83. namespace input
  84. {
  85. static const engine::key W = 'w';
  86. static const engine::key A = 'a';
  87. static const engine::key S = 's';
  88. static const engine::key D = 'd';
  89.  
  90. static const engine::key SPACE = ' ';
  91.  
  92. static const engine::key SHIFTX = 'X';
  93. static const engine::key DEFAULT = '~';
  94.  
  95. namespace actions
  96. {
  97. enum action
  98. {
  99. up,
  100. down,
  101. left,
  102. right,
  103. shoot,
  104. invalid
  105. };
  106. }
  107.  
  108. typedef typename actions::action action;
  109.  
  110. class InputController
  111. {
  112. public: //Typedefs
  113. typedef input::actions::action player_action;
  114. typedef mango::semimap<engine::key, player_action> input_map;
  115.  
  116. public: //Functions
  117. InputController(engine::key up, engine::key down, engine::key left, engine::key right, engine::key shoot)
  118. {
  119. m_KeyMapping.add(up, actions::up);
  120. m_KeyMapping.add(down, actions::down);
  121. m_KeyMapping.add(left, actions::left);
  122. m_KeyMapping.add(right, actions::right);
  123. m_KeyMapping.add(shoot, actions::shoot);
  124. }
  125.  
  126. player_action KeyPressed(engine::key in)
  127. {
  128. return (mango::npos != m_KeyMapping.find(in)) ? m_KeyMapping.at(in) : actions::invalid;
  129. }
  130.  
  131. private: //Members
  132. input_map m_KeyMapping;
  133. };
  134.  
  135. engine::key getKeyPress()
  136. {
  137. return mango::archive::mgetch();
  138. }
  139. }
  140.  
  141. namespace engine
  142. {
  143. typedef input::InputController input_device;
  144. typedef mango::shared_ptr<input_device> input_handle;
  145. }
  146.  
  147.  
  148. #endif//GUARD_MANGO_INPUT_H
  149.  
  150. #ifndef GUARD_MANGO_ENGINE_H
  151. #define GUARD_MANGO_ENGINE_H
  152.  
  153. #include "typedefs.h"
  154. #include "input.h"
  155.  
  156. namespace engine
  157. {
  158. class Game
  159. {
  160. public: //Typedefs
  161. typedef mango::shared_ptr<Game> game_handle;
  162.  
  163. public: //Functions
  164. Game()
  165. : m_IsRunning(true), m_UpdateRate(1.0 / 100),
  166. m_PlayerAction(input::actions::invalid), m_ActionCounter(0), m_SpawnRate(2.4),
  167. m_UpdateCount(0), m_Score(0)
  168. {
  169. m_Graphics = new engine::graphic_device(GetConsoleWindow(), engine::point(640, 640));
  170. m_Input = new engine::input_device(input::W, input::S, input::A, input::D, input::SPACE);
  171.  
  172. LoadSprite("player", 10, 295, 470, 50, 70); //PlayerShip Frames 10, Initial PlayerPosition (295|470), PlayerResolution 50px70p
  173.  
  174. LoadBackground();
  175. }
  176.  
  177. void Play()
  178. {
  179. srand((mango::uns32)time(nullptr));
  180. m_Timer.start();
  181. m_ShotTimer.start();
  182. m_SpawnTimer.start();
  183. m_DifficultyTimer.start();
  184.  
  185. engine::key input = input::DEFAULT;
  186.  
  187. while (input != input::SHIFTX && m_IsRunning)
  188. {
  189. if (mango::archive::mkbhit())
  190. {
  191. input = input::getKeyPress();
  192. KeyPressed(input);
  193. }
  194.  
  195. Frame();
  196. }
  197. }
  198.  
  199. private:
  200.  
  201. bool SpawnCollision(mango::int32 x)
  202. {
  203. for (mango::int32 currentActor = 0; m_Actors.size() > currentActor; ++currentActor)
  204. {
  205. engine::point x1 = engine::point(x - 5 , 5);
  206. engine::point x2 = engine::point(x + 20, 5);
  207.  
  208. bool containsX1orX2 = m_Actors.at(currentActor)->Contains(x1) || m_Actors.at(currentActor)->Contains(x2);
  209.  
  210. if (containsX1orX2)
  211. {
  212. return true;
  213. }
  214. }
  215.  
  216. return false;
  217. }
  218.  
  219. void printScore()
  220. {
  221. //TODO:
  222. }
  223.  
  224. void Frame()
  225. {
  226. Update();
  227. Collision();
  228. Draw();
  229. Present();
  230. ClearPipelines();
  231. SpawnEnemys();
  232. SetSpawnRate();
  233. }
  234.  
  235. void SetSpawnRate()
  236. {
  237. const engine::seconds MINSPAWNRATE = 0.3;
  238. const engine::seconds INCREMENTATIONINTERVAL = 7.0;
  239. const engine::seconds SPAWNRATEINCRFACTOR = -0.05;
  240.  
  241. if (MINSPAWNRATE <= m_SpawnRate)
  242. {
  243. m_DifficultyTimer.tick();
  244. if (INCREMENTATIONINTERVAL <= m_DifficultyTimer.totalTime())
  245. {
  246. m_SpawnRate += SPAWNRATEINCRFACTOR;
  247. ResetTimer(m_DifficultyTimer);
  248. }
  249. }
  250. }
  251.  
  252. void SelectEnemyType(mango::int32 x)
  253. {
  254. mango::int32 enemyType = rand() % 6 + 64; //A-E
  255. std::string name = "enemy";
  256. name.push_back(enemyType);
  257.  
  258. if ('A' == enemyType || 'C' == enemyType)
  259. {
  260. LoadEnemy(name, 1, x, -5, 40, 40); //40 - 40 --> enemyA and enemyC sprite are at the same resolution --> 40px40p
  261. }
  262. if ('B' == enemyType || 'E' == enemyType)
  263. {
  264. LoadEnemy(name, 1, x, -5, 25, 50); //25 - 50 --> enemyB and enemyE sprite are at the same resolution --> 25px50p
  265. }
  266. if ('D' == enemyType)
  267. {
  268. LoadEnemy(name, 1, x, -5, 30, 54); //30 - 54 --> enemyD --> 30px54p
  269. }
  270. }
  271.  
  272. void SpawnEnemys()
  273. {
  274. const mango::int32 MAXACTORS = 50;
  275.  
  276. m_SpawnTimer.tick();
  277. if (m_SpawnRate <= m_SpawnTimer.totalTime() &&m_Actors.size() < MAXACTORS)
  278. {
  279. ResetTimer(m_SpawnTimer);
  280.  
  281. mango::int32 x = 0;
  282.  
  283. do
  284. {
  285. x = rand() % 550 + 5; //5-550 Spawn Frame
  286. } while (SpawnCollision(x));
  287.  
  288. SelectEnemyType(x);
  289. }
  290. }
  291.  
  292. static bool ProcessCollision(engine::actor_handle shot, engine::sprite_pipeline* actors, engine::actor_pipeline* shots)
  293. {
  294. const mango::int32 MAXENEMY_Y = 650;
  295. const mango::int32 MAXSHOT_Y = -10;
  296.  
  297. for (mango::int32 currentActor = 0; actors->size() > currentActor; ++currentActor)
  298. {
  299. engine::point x1 = shot->GetPosition();
  300. engine::point x2 = shot->GetPosition();
  301.  
  302. x2.X += 10;
  303.  
  304. bool bothAreVisible = shot->GetVisibility() && actors->at(currentActor)->GetVisibility();
  305. bool containsX1orX2 = actors->at(currentActor)->Contains(x1) || actors->at(currentActor)->Contains(x2);
  306. bool isNoOtherShot = 0 == shots->find(actors->at(currentActor));
  307.  
  308. if(bothAreVisible && containsX1orX2 && isNoOtherShot) //Remove hit and ship if hit
  309. {
  310. actors->at(currentActor)->SetVisibility(false);
  311. shot->SetVisibility(false);
  312. }
  313. if (MAXENEMY_Y <= actors->at(currentActor)->GetPosition().Y) //Remove ship if out of screen
  314. {
  315. actors->at(currentActor)->SetVisibility(false);
  316. }
  317. if (MAXSHOT_Y >= x1.Y) //Remove shot if out of screen
  318. {
  319. shot->SetVisibility(false);
  320. }
  321. }
  322.  
  323. return true;
  324. }
  325.  
  326. void Collision()
  327. {
  328. for (mango::int32 currentShot = 0; m_Shots.size() > currentShot; ++currentShot)
  329. {
  330. ProcessCollision(m_Shots.at(currentShot), &m_Actors, &m_Shots);
  331. }
  332. }
  333.  
  334. void ClearPipelines()
  335. {
  336. for (mango::int32 currentShot = 0; m_Shots.size() > currentShot; ++currentShot)
  337. {
  338. if (!m_Shots.at(currentShot)->GetVisibility())
  339. {
  340. m_Actors.remove(m_Shots.at(currentShot));
  341. m_Shots.erase(currentShot);
  342.  
  343. --currentShot;
  344. }
  345. }
  346.  
  347. for (mango::int32 currentActor = 0; m_Actors.size() > currentActor; ++currentActor)
  348. {
  349. const mango::int32 MAXENEMY_Y = 650;
  350.  
  351. if (MAXENEMY_Y <= m_Actors.at(currentActor)->GetPosition().Y)
  352. {
  353. engine::actor_handle gameOver = new engine::actor(engine::point(0, 150), 600, 200);
  354. gameOver->LoadAnimation(0, "game_over", 1);
  355.  
  356. m_Graphics->ClearBuffer();
  357. m_Graphics->Draw((engine::actor*)m_Background);
  358. m_Graphics->Draw((engine::actor*)gameOver);
  359. m_Graphics->Present();
  360.  
  361. mango::csleep(3000); //3 Seconds
  362.  
  363. m_IsRunning = false;
  364. return;
  365. }
  366.  
  367. if (!m_Actors.at(currentActor)->GetVisibility())
  368. {
  369. SpawnEffect(m_Actors.at(currentActor), "explosion");
  370. m_Actors.remove(m_Actors.key_at(currentActor));
  371.  
  372. --currentActor;
  373. m_Score += 100;
  374. }
  375. }
  376. }
  377.  
  378. void Shoot(engine::key key)
  379. {
  380. const mango::int32 ACTIONCOUNTERINCRFACTOR = 30;
  381.  
  382. if (input::actions::shoot == m_Input->KeyPressed(key))
  383. {
  384. SpawnShot("player");
  385.  
  386. if ((0 != m_ActionCounter && input::actions::right == m_PlayerAction))
  387. {
  388. m_PlayerAction = input::actions::right;
  389. m_ActionCounter = ACTIONCOUNTERINCRFACTOR;
  390. }
  391. if ((0 != m_ActionCounter && input::actions::left == m_PlayerAction))
  392. {
  393. m_PlayerAction = input::actions::left;
  394. m_ActionCounter = ACTIONCOUNTERINCRFACTOR;
  395. }
  396. if ((0 != m_ActionCounter && input::actions::up == m_PlayerAction))
  397. {
  398. m_PlayerAction = input::actions::up;
  399. m_ActionCounter = ACTIONCOUNTERINCRFACTOR;
  400. }
  401. if ((0 != m_ActionCounter && input::actions::down == m_PlayerAction))
  402. {
  403. m_PlayerAction = input::actions::down;
  404. m_ActionCounter = ACTIONCOUNTERINCRFACTOR;
  405. }
  406. }
  407. }
  408.  
  409. void Move(engine::key key)
  410. {
  411. const mango::int32 ACTIONCOUNTERINCRFACTOR = 30;
  412.  
  413. if (input::actions::left == m_Input->KeyPressed(key))
  414. {
  415. if (0 == m_ActionCounter || input::actions::left != m_PlayerAction)
  416. {
  417. m_PlayerAction = input::actions::left;
  418. m_ActionCounter = ACTIONCOUNTERINCRFACTOR;
  419. }
  420. }
  421. if (input::actions::right == m_Input->KeyPressed(key))
  422. {
  423. if (0 == m_ActionCounter || input::actions::right != m_PlayerAction)
  424. {
  425. m_PlayerAction = input::actions::right;
  426. m_ActionCounter = ACTIONCOUNTERINCRFACTOR;
  427. }
  428. }
  429. if (input::actions::up == m_Input->KeyPressed(key))
  430. {
  431. if (0 == m_ActionCounter || input::actions::up != m_PlayerAction)
  432. {
  433. m_PlayerAction = input::actions::up;
  434. m_ActionCounter = ACTIONCOUNTERINCRFACTOR;
  435. }
  436. }
  437. if (input::actions::down == m_Input->KeyPressed(key))
  438. {
  439. if (0 == m_ActionCounter || input::actions::down != m_PlayerAction)
  440. {
  441. m_PlayerAction = input::actions::down;
  442. m_ActionCounter = ACTIONCOUNTERINCRFACTOR;
  443. }
  444. }
  445. }
  446.  
  447. void KeyPressed(engine::key key)
  448. {
  449. Shoot(key);
  450. Move(key);
  451. }
  452.  
  453.  
  454. void Draw()
  455. {
  456. m_Graphics->ClearBuffer();
  457.  
  458. m_Graphics->Draw((engine::actor*)m_Background);
  459. m_Graphics->Draw(m_Actors);
  460.  
  461. for (mango::int32 currentEffect = 0; m_Effects.size() > currentEffect; ++currentEffect)
  462. {
  463. m_Graphics->Draw((engine::actor*)m_Effects.key_at(currentEffect));
  464. }
  465. }
  466.  
  467. void UpdateEnemies()
  468. {
  469. const mango::int32 ENEMYMOTIONRATE_X = 0;
  470. const mango::int32 ENEMYMOTIONRATE_Y = 1;
  471.  
  472. for (mango::int32 currentActor = 0; m_Actors.size() > currentActor; ++currentActor)
  473. {
  474. bool isNoPlayerShot = 0 == m_Shots.find(m_Actors.at(currentActor));
  475. bool isNotThePlayer = m_Actors.at(currentActor) != m_Actors.at(0);
  476.  
  477. if (isNoPlayerShot && isNotThePlayer)
  478. {
  479. m_Actors.at(currentActor)->Move(ENEMYMOTIONRATE_X, ENEMYMOTIONRATE_Y);
  480. }
  481. }
  482. }
  483.  
  484. void UpdateActors()
  485. {
  486. m_Timer.tick();
  487. if ((m_UpdateRate) <= m_Timer.totalTime())
  488. {
  489. if (0 != m_Actors.size())
  490. {
  491. lambda((engine::actor_handle actor) { actor->Update(); return 0; }, 1); //exp1
  492. m_Actors.for_each(exp1);
  493. }
  494.  
  495. ++m_UpdateCount;
  496.  
  497. UpdatePlayer();
  498. UpdateEffects();
  499. UpdateEnemies();
  500.  
  501. ResetTimer(m_Timer);
  502. }
  503. }
  504.  
  505. void UpdateBackground()
  506. {
  507. const mango::int32 BGMOTIONRATE_X = 0;
  508. const mango::int32 BGMOTIONRATE_Y = 1;
  509.  
  510. const mango::int32 BGUPDATETHRESHHOLD = 3;
  511.  
  512. if (BGUPDATETHRESHHOLD == m_UpdateCount)
  513. {
  514. if (nullptr != m_Background)
  515. {
  516. m_Background->Move(BGMOTIONRATE_X, BGMOTIONRATE_Y);
  517.  
  518. if (0 == m_Background->GetPosition().Y)
  519. {
  520. m_Background->SetPosition(engine::point(0, -600)); //Reset BG to initial position
  521. }
  522. }
  523.  
  524. m_UpdateCount = 0;
  525. }
  526. }
  527.  
  528. void UpdateShots()
  529. {
  530. const mango::int32 SHOTMOTIONRATE_X = 0;
  531. const mango::int32 SHOTMOTIONRATE_Y = -4;
  532.  
  533. if (m_Shots.size() > 0)
  534. {
  535. lambda((engine::actor_handle shot) { shot->Move(SHOTMOTIONRATE_X, SHOTMOTIONRATE_Y); return 0; }, 1);
  536.  
  537. m_Shots.for_each(exp1);
  538. }
  539. }
  540.  
  541. void UpdateEffects()
  542. {
  543. for (mango::int32 currentEffect = 0; m_Effects.size() > currentEffect; ++currentEffect)
  544. {
  545. m_Effects.key_at(currentEffect)->Update();
  546.  
  547. if (mango::npos == --m_Effects.at(currentEffect))
  548. {
  549. m_Effects.remove(m_Effects.key_at(currentEffect));
  550. --currentEffect;
  551. }
  552. }
  553. }
  554.  
  555. void UpdatePlayer()
  556. {
  557. const mango::int32 PLAYERMOTIONRATE = 3;
  558. const mango::int32 NOMOTION = 0;
  559.  
  560. const mango::int32 MINPLAYER_X = 5;
  561. const mango::int32 MAXPLAYER_X = 550;
  562.  
  563. const mango::int32 MINPLAYER_Y = 5;
  564. const mango::int32 MAXPLAYER_Y = 470;
  565.  
  566. if (0 != m_ActionCounter)
  567. {
  568. engine::point player = m_Actors.at(0)->GetPosition();
  569.  
  570. if (input::actions::left == m_PlayerAction)
  571. {
  572. if (player.X >= MINPLAYER_X)
  573. {
  574. MovePlayer( -PLAYERMOTIONRATE, NOMOTION);
  575. }
  576. --m_ActionCounter;
  577. }
  578. if (input::actions::right == m_PlayerAction)
  579. {
  580. if (player.X <= MAXPLAYER_X)
  581. {
  582. MovePlayer(PLAYERMOTIONRATE, NOMOTION);
  583. }
  584. --m_ActionCounter;
  585. }
  586. if (input::actions::up == m_PlayerAction)
  587. {
  588. if (player.Y >= MINPLAYER_Y)
  589. {
  590. MovePlayer(NOMOTION, -PLAYERMOTIONRATE);
  591. }
  592. --m_ActionCounter;
  593. }
  594. if (input::actions::down == m_PlayerAction)
  595. {
  596. if (player.Y <= MAXPLAYER_Y)
  597. {
  598. MovePlayer(NOMOTION, PLAYERMOTIONRATE);
  599. }
  600. --m_ActionCounter;
  601. }
  602. }
  603. else
  604. {
  605. m_PlayerAction = input::actions::invalid;
  606. }
  607. }
  608.  
  609. void Update()
  610. {
  611. UpdateActors();
  612. UpdateBackground();
  613. UpdateShots();
  614. }
  615.  
  616. void Present()
  617. {
  618. m_Graphics->Present();
  619. printScore();
  620. }
  621.  
  622. void ResetTimer(engine::timer& timer)
  623. {
  624. timer.stop();
  625. timer.reset();
  626. timer.start();
  627. }
  628.  
  629. void LoadSprite(const engine::mesh_name& name, mango::int32 frames, mango::int32 x, mango::int32 y, mango::int32 width, mango::int32 height)
  630. {
  631. engine::actor_handle actor;
  632.  
  633. actor = new engine::actor(engine::point(x, y), width, height);
  634. actor->LoadAnimation(0, name, frames);
  635.  
  636. m_Actors.add(name, actor);
  637. }
  638.  
  639. void LoadEnemy(const engine::mesh_name& name, mango::int32 frames, mango::int32 x, mango::int32 y, mango::int32 width, mango::int32 height)
  640. {
  641. static engine::large_counter ID = 0;
  642.  
  643. engine::actor_handle actor;
  644.  
  645. actor = new engine::actor(engine::point(x, y), width, height);
  646. actor->LoadAnimation(0, name, frames);
  647.  
  648. m_Actors.add(name + mango::to_string(ID), actor);
  649.  
  650. ++ID;
  651. }
  652.  
  653. void LoadShot(const engine::mesh_name& name, mango::int32 frames, mango::int32 x, mango::int32 y, mango::int32 width, mango::int32 height)
  654. {
  655. static engine::large_counter ID = 0;
  656.  
  657. engine::actor_handle actor;
  658.  
  659. actor = new engine::actor(engine::point(x, y), width, height);
  660. actor->LoadAnimation(0, name, frames);
  661.  
  662. m_Shots.push_back(actor);
  663. m_Actors.add(name + mango::to_string(ID), actor);
  664.  
  665. ++ID;
  666. }
  667.  
  668. void LoadEffect(const engine::mesh_name& name, mango::int32 frames, mango::int32 x, mango::int32 y, mango::int32 width, mango::int32 height)
  669. {
  670. const mango::int32 EFFECTFRAMES = 5;
  671.  
  672. engine::actor_handle actor;
  673.  
  674. actor = new engine::actor(engine::point(x, y), width, height);
  675. actor->LoadAnimation(0, name, frames);
  676.  
  677. m_Effects.add(actor, EFFECTFRAMES);
  678. }
  679.  
  680. void LoadBackground()
  681. {
  682. m_Background = new engine::actor(engine::point(0, -600), 640, 1200);
  683. m_Background->LoadAnimation(0, "background", 1);
  684. }
  685.  
  686. void MoveActor(std::string name, mango::int32 x, mango::int32 y)
  687. {
  688. m_Actors.at(name)->Move(x, y);
  689. }
  690.  
  691. void MovePlayer(mango::int32 x, mango::int32 y)
  692. {
  693. m_Actors.at(0)->Move(x, y);
  694. }
  695.  
  696. void SpawnShot(std::string actor_name)
  697. {
  698. m_ShotTimer.tick();
  699.  
  700. if (0.20 <= m_ShotTimer.totalTime())
  701. {
  702. ResetTimer(m_ShotTimer);
  703.  
  704. engine::point spawnPosition = m_Actors.at(actor_name)->GetPosition();
  705.  
  706. if ("player" == actor_name)
  707. {
  708. spawnPosition.X += 22;
  709. spawnPosition.Y -= 25;
  710.  
  711. LoadShot("playerShot", 1, spawnPosition.X, spawnPosition.Y, 10, 20);
  712. }
  713. }
  714. }
  715.  
  716. void SpawnEffect(actor_handle actor, std::string effect_name)
  717. {
  718. engine::point spawnPosition = actor->GetPosition();
  719.  
  720. LoadEffect(effect_name, 5, spawnPosition.X, spawnPosition.Y, 50, 50);
  721. }
  722.  
  723. void SpawnEffect(std::string actor_name, std::string effect_name)
  724. {
  725. engine::point spawnPosition = m_Actors.at(actor_name)->GetPosition();
  726.  
  727. LoadEffect(effect_name, 5, spawnPosition.X, spawnPosition.Y, 50, 50);
  728. }
  729.  
  730. input::action m_PlayerAction;
  731. engine::counter m_ActionCounter; //While Counter != 0 PlayerAction (except shooting) will be repeated for control smoothing
  732.  
  733. engine::seconds m_UpdateRate;
  734. engine::seconds m_SpawnRate;
  735. engine::counter m_UpdateCount;
  736.  
  737. engine::timer m_Timer;
  738. engine::timer m_ShotTimer;
  739. engine::timer m_SpawnTimer;
  740. engine::timer m_DifficultyTimer;
  741.  
  742. engine::sprite_pipeline m_Actors;
  743. engine::graphic_handle m_Graphics;
  744. engine::input_handle m_Input;
  745.  
  746. engine::actor_pipeline m_Shots;
  747. engine::effect_pipeline m_Effects;
  748.  
  749. engine::background_handle m_Background;
  750.  
  751. engine::flag m_IsRunning;
  752. engine::counter m_Score;
  753. };
  754.  
  755. typedef mango::pair<engine::Game::game_handle, engine::key> input_package;
  756. }
  757.  
  758.  
  759. #endif//GUARD_MANGO_ENGINE_H
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement