Update 20/01 : remarche

This commit is contained in:
attilavs2 2025-01-20 08:55:15 +01:00
parent 64fdf83576
commit b9038faec2

View file

@ -35,7 +35,7 @@ Rectangle plane_coll = {.width = PLANE_W, .height = PLANE_H};
int lost = 0;
int planen;
int planen = 0;
Plane plane_queue[PQUEUE_SIZE];
@ -64,7 +64,7 @@ void pop_plane(int pos){
#define COLL_HEIGHT 30
void update_planes(int diff, int xpos){
while(planen < diff){
Vector2 pos;
//Split into zones to spawn where visible and avoidable
@ -78,9 +78,10 @@ void update_planes(int diff, int xpos){
pos.x = rand()%170 + 253;
break;
case 2:
pos.x = rand()%200 + 520
pos.x = rand()%200 + 520;
break;
}
spawn_plane(pos);
}
float x;
@ -90,6 +91,10 @@ void update_planes(int diff, int xpos){
float fxpos = xpos/100.0;
Rectangle tcoll = {.width = TOW_W, .height = COLL_HEIGHT};
for(int j = 0; j < planen; j++){
plane_queue[j].dist += 0.01;
}
for(y = 0; y < WINDOW_H; y+=COLL_HEIGHT){
//x = (5*(xpos/100)/WINDOW_W*y)^2
x = (WINDOW_H-y)*((5.0*fxpos)/(float)WINDOW_W);
@ -97,16 +102,21 @@ void update_planes(int diff, int xpos){
tcoll.y = y;
for(int i = 0; i < planen; i++){
Plane *pln = &plane_queue[i];
if(pln->dist < 0.9)
continue;
plane_coll.x = pln->pos.x;
plane_coll.y = pln->pos.y;
tcoll.x = TOW0_OFF + x;
if(CheckCollisionRecs(plane_coll,tcoll)){
lost |= 1;
return;
}
tcoll.x = TOW1_OFF + x;
if(CheckCollisionRecs(plane_coll,tcoll)){
lost |= 2;
return;
}
pop_plane(i);
}
}
@ -128,8 +138,8 @@ void draw_towers(Texture2D *towers, int xpos){
(Vector2){round(x),y},WHITE);
}
if(!(lost&2)){
DrawTextureRec(*towers,(Rectangle){.height=1,.width=800,.x=TOW1_OFF,.y=y},
(Vector2){round(x),y},WHITE);
/*DrawTextureRec(*towers,(Rectangle){.height=1,.width=800,.x=TOW1_OFF,.y=y},
(Vector2){round(x),y},WHITE);*/
}
}
}
@ -154,7 +164,7 @@ void lost_men(int *score){
}
while(planen){
pop_plane();
pop_plane(0);
}
*score = 0;
@ -188,11 +198,11 @@ int main(){
ClearBackground(BLUE);
if(IsKeyDown(KEY_LEFT) && xpos > WINDOW_W/-2)
xpos-=3;
xpos-=5;
if(IsKeyDown(KEY_RIGHT) && xpos < WINDOW_W/2)
xpos+=3;
xpos+=5;
update_planes(3, xpos);
update_planes(2 + score/1000, xpos);
draw_planes(&plane);