@@ -38,8 +38,11 @@ bool Player::Start()
3838 winTex = app->tex ->Load (" Assets/Textures/win.png" );
3939 bombTex = app->tex ->Load (" Assets/Textures/bomb.png" );
4040 loseTex = app->tex ->Load (" Assets/Textures/lose.png" );
41+ pl1Tex = app->tex ->Load (" Assets/Textures/planet1.png" );
42+ pl2Tex = app->tex ->Load (" Assets/Textures/planet2.png" );
4143 oceanTex = app->tex ->Load (" Assets/Textures/ocean.png" );
4244 cloudTex = app->tex ->Load (" Assets/Textures/clouds.png" );
45+ fuelTex = app->tex ->Load (" Assets/Textures/fuel.png" );
4346 fxWin = app->audio ->PlayMusic (" Assets/Audio/Hymn.wav" );
4447 app->fxList .Add (&fxWin);
4548
@@ -101,13 +104,20 @@ bool Player::PreUpdate()
101104
102105 fire = true ;
103106 landed = false ;
107+
108+
109+ if (fuelC < 750 )
110+ {
111+ fuelC++;
112+ }
113+ if (fuelC == 750 )
114+ {
115+ fuelC = 0 ;
116+ fuel--;
117+ }
104118 }
105119 else if (acc > 0 )acc -= 0.05 ;
106120
107- if (app->input ->GetKey (SDL_SCANCODE_P) == KEY_REPEAT)
108- {
109- ship->position .y += 5 ;
110- }
111121
112122 if (landed == false )
113123 {
@@ -141,7 +151,12 @@ bool Player::PreUpdate()
141151 }
142152
143153 // meteor harcoded hitbox (as all hitboxes will be cuz idk any other way rn)
144- // if (ship->position.x < 50 + 58 && ship->position.x + 55 > 50 && ship->position.y < 50 + 58 && ship->position.y + 175 > 50) alive = false;
154+
155+ if (ship->position .x < 250 + 58 && ship->position .x + 55 > 250 && ship->position .y < -2500 + 58 && ship->position .y + 175 > -2500 ) alive = false ;
156+
157+ if (ship->position .x < 570 + 58 && ship->position .x + 55 > 570 && ship->position .y < -3550 + 58 && ship->position .y + 175 > -3550 ) alive = false ;
158+
159+ if (ship->position .x < 700 + 58 && ship->position .x + 55 > 700 && ship->position .y < -4100 + 58 && ship->position .y + 175 > -4100 ) alive = false ;
145160
146161 // No you cant go to the center of the earth Verne
147162 if (ship->position .y > 70 && angle > 355 && ship->velocity .y < 3 .0f && ship->velocity .x < 3 .0f || ship->position .y > 70 && angle < 5 && velocity < 100 && ship->velocity .y < 5 .0f && ship->velocity .x < 5 .0f )
@@ -153,6 +168,8 @@ bool Player::PreUpdate()
153168 }
154169 else if (ship->position .y > 75 ) alive = false ;
155170
171+ if (fuel == 0 )alive = false ;
172+
156173 if (ship->position .y == 70 && alive == true && bomb == true )
157174 {
158175 win = true ;
@@ -179,13 +196,16 @@ bool Player::PreUpdate()
179196 // enter to revive (as in real life)
180197 if (app->input ->GetKey (SDL_SCANCODE_RETURN) == KEY_DOWN)
181198 {
199+ win = false ;
182200 alive = true ;
183201 ship->SetPosition (startingPos);
184202 angle = 0 ;
185203 acc = 0 ;
186204 bomb = false ;
187205 ship->velocity .x = 0 .0f ;
188206 ship->velocity .y = 0 .0f ;
207+ fuel = 4 ;
208+ fuelC = 0 ;
189209 }
190210 return true ;
191211}
@@ -212,13 +232,27 @@ bool Player::Update(float dt)
212232
213233bool Player::PostUpdate ()
214234{
235+
236+ SDL_Rect pl1Rec = { 0 , 0 , 884 , 884 };
237+ app->render ->DrawTexture (pl1Tex, 800 , -2600 , &pl1Rec);
238+
239+ SDL_Rect pl2Rec = { 0 , 0 , 884 , 884 };
240+ app->render ->DrawTexture (pl2Tex, -200 , -3800 , &pl2Rec);
241+
215242 app->audio ->PlayFx (fxWin);
216243 // meteor texture
217244 Animation* meteor = &meteorAnim;
218245 meteor->Update ();
219246
220247 SDL_Rect meteorRec = meteor->GetCurrentFrame ();
221- app->render ->DrawTexture (meteorTex, 50 , 50 , &meteorRec);
248+ app->render ->DrawTexture (meteorTex, 250 , -2500 , &meteorRec);
249+
250+ SDL_Rect meteorRec2 = meteor->GetCurrentFrame ();
251+ app->render ->DrawTexture (meteorTex, 570 , -3550 , &meteorRec2);
252+
253+ SDL_Rect meteorRec3 = meteor->GetCurrentFrame ();
254+ app->render ->DrawTexture (meteorTex, 700 , -4100 , &meteorRec3);
255+
222256
223257 // bomb print
224258 if (bomb == true )
@@ -227,6 +261,8 @@ bool Player::PostUpdate()
227261 app->render ->DrawTexture (bombTex, bombPos, -5800 , &bombRec);
228262 }
229263
264+
265+
230266 // ocean print
231267 /* if (bomb == true)
232268 {
@@ -260,12 +296,38 @@ bool Player::PostUpdate()
260296 }
261297
262298
263-
264299 SDL_Rect cloudRec = { 0 , 0 , 2360 , 984 };
265300 app->render ->DrawTexture (cloudTex, -500 , -1500 , &cloudRec);
266-
267301
302+ if (fuel == 4 )
303+ {
304+ SDL_Rect fuelRec1 = { 0 , 0 , 46 , 20 };
305+ app->render ->DrawTexture (fuelTex, 0 , -app->render ->camera .y , &fuelRec1);
306+ }
307+
308+ if (fuel == 3 )
309+ {
310+ SDL_Rect fuelRec2 = { 47 , 0 , 46 , 20 };
311+ app->render ->DrawTexture (fuelTex, 0 , -app->render ->camera .y , &fuelRec2);
312+ }
268313
314+ if (fuel == 2 )
315+ {
316+ SDL_Rect fuelRec3 = { 94 , 0 , 46 , 20 };
317+ app->render ->DrawTexture (fuelTex, 0 , -app->render ->camera .y , &fuelRec3);
318+ }
319+
320+ if (fuel == 1 )
321+ {
322+ SDL_Rect fuelRec4 = { 141 , 0 , 46 , 20 };
323+ app->render ->DrawTexture (fuelTex, 0 , -app->render ->camera .y , &fuelRec4);
324+ }
325+
326+ if (fuel == 0 )
327+ {
328+ SDL_Rect fuelRec5 = { 188 , 0 , 46 , 20 };
329+ app->render ->DrawTexture (fuelTex, 0 , -app->render ->camera .y , &fuelRec5);
330+ }
269331 // lose screen print
270332 if (alive == false && explosionAnim.HasFinished () == true )
271333 {
0 commit comments