mirror of
https://gitlab.com/dosowisko.net/libsuperderpy.git
synced 2025-02-01 19:16:44 +01:00
s/obstracle/obstacle/ :D
This commit is contained in:
parent
1cfdd00764
commit
7b1893f9ad
2 changed files with 27 additions and 27 deletions
46
src/level.c
46
src/level.c
|
@ -151,21 +151,21 @@ bool Fly(struct Game *game, struct TM_Action *action, enum TM_ActionState state)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Obst_MoveUpDown(struct Game *game, struct Obstracle *obstracle) {
|
void Obst_MoveUpDown(struct Game *game, struct Obstacle *obstacle) {
|
||||||
if (obstracle->data) {
|
if (obstacle->data) {
|
||||||
obstracle->y -= 0.5;
|
obstacle->y -= 0.5;
|
||||||
if (obstracle->y<=0) {
|
if (obstacle->y<=0) {
|
||||||
obstracle->data=NULL;
|
obstacle->data=NULL;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
obstracle->y += 0.5;
|
obstacle->y += 0.5;
|
||||||
if (obstracle->y>=100) {
|
if (obstacle->y>=100) {
|
||||||
obstracle->data++;
|
obstacle->data++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GenerateObstracles(struct Game *game, struct TM_Action *action, enum TM_ActionState state) {
|
bool GenerateObstacles(struct Game *game, struct TM_Action *action, enum TM_ActionState state) {
|
||||||
/*float* tmp; bool* in;*/
|
/*float* tmp; bool* in;*/
|
||||||
int* count;
|
int* count;
|
||||||
if (!action->arguments) {
|
if (!action->arguments) {
|
||||||
|
@ -182,9 +182,9 @@ bool GenerateObstracles(struct Game *game, struct TM_Action *action, enum TM_Act
|
||||||
}
|
}
|
||||||
else if (state == TM_ACTIONSTATE_RUNNING) {
|
else if (state == TM_ACTIONSTATE_RUNNING) {
|
||||||
if (rand()%(10000/(int)tps(game, 60*100))<=1) {
|
if (rand()%(10000/(int)tps(game, 60*100))<=1) {
|
||||||
PrintConsole(game, "OBSTRACLE %d", *count);
|
PrintConsole(game, "OBSTACLE %d", *count);
|
||||||
(*count)++;
|
(*count)++;
|
||||||
struct Obstracle *obst = malloc(sizeof(struct Obstracle));
|
struct Obstacle *obst = malloc(sizeof(struct Obstacle));
|
||||||
obst->prev = NULL;
|
obst->prev = NULL;
|
||||||
obst->x = 100;
|
obst->x = 100;
|
||||||
obst->y = (rand()%91)-1;
|
obst->y = (rand()%91)-1;
|
||||||
|
@ -199,13 +199,13 @@ bool GenerateObstracles(struct Game *game, struct TM_Action *action, enum TM_Act
|
||||||
obst->bitmap = &(game->level.obst_bmps.muffin);
|
obst->bitmap = &(game->level.obst_bmps.muffin);
|
||||||
}
|
}
|
||||||
obst->data = (void*)(rand()%2);
|
obst->data = (void*)(rand()%2);
|
||||||
if (game->level.obstracles) {
|
if (game->level.obstacles) {
|
||||||
game->level.obstracles->prev = obst;
|
game->level.obstacles->prev = obst;
|
||||||
obst->next = game->level.obstracles;
|
obst->next = game->level.obstacles;
|
||||||
} else {
|
} else {
|
||||||
obst->next = NULL;
|
obst->next = NULL;
|
||||||
}
|
}
|
||||||
game->level.obstracles = obst;
|
game->level.obstacles = obst;
|
||||||
if (*count > 64) return true;
|
if (*count > 64) return true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -281,7 +281,7 @@ void Level_Draw(struct Game *game) {
|
||||||
int derpyw = al_get_bitmap_width(game->level.derpy);
|
int derpyw = al_get_bitmap_width(game->level.derpy);
|
||||||
int derpyh = al_get_bitmap_height(game->level.derpy);
|
int derpyh = al_get_bitmap_height(game->level.derpy);
|
||||||
bool colision = false;
|
bool colision = false;
|
||||||
struct Obstracle *tmp = game->level.obstracles;
|
struct Obstacle *tmp = game->level.obstacles;
|
||||||
while (tmp) {
|
while (tmp) {
|
||||||
/*PrintConsole(game, "DRAWING %f %f", tmp->x, tmp->y);*/
|
/*PrintConsole(game, "DRAWING %f %f", tmp->x, tmp->y);*/
|
||||||
if (tmp->x > -10) {
|
if (tmp->x > -10) {
|
||||||
|
@ -310,8 +310,8 @@ void Level_Draw(struct Game *game) {
|
||||||
if (tmp->prev)
|
if (tmp->prev)
|
||||||
tmp->prev->next = tmp->next;
|
tmp->prev->next = tmp->next;
|
||||||
else
|
else
|
||||||
game->level.obstracles = tmp->next;
|
game->level.obstacles = tmp->next;
|
||||||
struct Obstracle *t = tmp;
|
struct Obstacle *t = tmp;
|
||||||
tmp = tmp->next;
|
tmp = tmp->next;
|
||||||
free(t);
|
free(t);
|
||||||
}
|
}
|
||||||
|
@ -476,7 +476,7 @@ void Level_Load(struct Game *game) {
|
||||||
game->level.sheet_speed = tps(game, 60*2.4);
|
game->level.sheet_speed = tps(game, 60*2.4);
|
||||||
game->level.sheet_tmp = 0;
|
game->level.sheet_tmp = 0;
|
||||||
game->level.handle_input = false;
|
game->level.handle_input = false;
|
||||||
game->level.obstracles = NULL;
|
game->level.obstacles = NULL;
|
||||||
game->level.flying = false;
|
game->level.flying = false;
|
||||||
game->level.meter_alpha=0;
|
game->level.meter_alpha=0;
|
||||||
al_clear_to_color(al_map_rgb(0,0,0));
|
al_clear_to_color(al_map_rgb(0,0,0));
|
||||||
|
@ -498,12 +498,12 @@ void Level_Load(struct Game *game) {
|
||||||
/*TM_AddDelay(2*1000);*/
|
/*TM_AddDelay(2*1000);*/
|
||||||
/* first part gameplay goes here */
|
/* first part gameplay goes here */
|
||||||
|
|
||||||
/* actions for generating obstracles should go here
|
/* actions for generating obstacles should go here
|
||||||
* probably as regular actions. When one ends, harder one
|
* probably as regular actions. When one ends, harder one
|
||||||
* begins. After last one part with muffins starts.
|
* begins. After last one part with muffins starts.
|
||||||
* Should obstracles themselves be handled as objects
|
* Should obstacles themselves be handled as objects
|
||||||
* on timeline? (probably not). Hmm... */
|
* on timeline? (probably not). Hmm... */
|
||||||
TM_AddAction(&GenerateObstracles, NULL, "obstracles");
|
TM_AddAction(&GenerateObstacles, NULL, "obstacles");
|
||||||
TM_AddDelay(5*1000);
|
TM_AddDelay(5*1000);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -578,7 +578,7 @@ void Level_Unload(struct Game *game) {
|
||||||
else {
|
else {
|
||||||
TM_Destroy();
|
TM_Destroy();
|
||||||
}
|
}
|
||||||
struct Obstracle *t = game->level.obstracles;
|
struct Obstacle *t = game->level.obstacles;
|
||||||
if (t) {
|
if (t) {
|
||||||
while (t->next) {
|
while (t->next) {
|
||||||
if (t->prev) free(t->prev);
|
if (t->prev) free(t->prev);
|
||||||
|
|
|
@ -56,14 +56,14 @@ struct Moonwalk {
|
||||||
double derpy_pos; /*!< Position of Derpy on screen. */
|
double derpy_pos; /*!< Position of Derpy on screen. */
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Obstracle {
|
struct Obstacle {
|
||||||
ALLEGRO_BITMAP **bitmap;
|
ALLEGRO_BITMAP **bitmap;
|
||||||
float x, y, speed;
|
float x, y, speed;
|
||||||
int points;
|
int points;
|
||||||
bool hit;
|
bool hit;
|
||||||
void (*callback)(struct Game*, struct Obstracle*);
|
void (*callback)(struct Game*, struct Obstacle*);
|
||||||
void *data;
|
void *data;
|
||||||
struct Obstracle *prev, *next;
|
struct Obstacle *prev, *next;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Spritesheet {
|
struct Spritesheet {
|
||||||
|
@ -101,7 +101,7 @@ struct Level {
|
||||||
ALLEGRO_BITMAP *pie;
|
ALLEGRO_BITMAP *pie;
|
||||||
ALLEGRO_BITMAP *muffin;
|
ALLEGRO_BITMAP *muffin;
|
||||||
} obst_bmps;
|
} obst_bmps;
|
||||||
struct Obstracle *obstracles;
|
struct Obstacle *obstacles;
|
||||||
struct Moonwalk moonwalk;
|
struct Moonwalk moonwalk;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue