more obstacles

This commit is contained in:
Sebastian Krzyszkowiak 2012-05-21 18:47:17 +02:00
parent d0f2ab8575
commit bd2e62f651
5 changed files with 39 additions and 7 deletions

View file

@ -456,7 +456,7 @@ void Level_UnloadBitmaps(struct Game *game) {
}
void Level_PreloadBitmaps(struct Game *game, void (*progress)(struct Game*, float)) {
PROGRESS_INIT(13);
PROGRESS_INIT(15);
int x = 0;
struct Spritesheet *tmp = game->level.derpy_sheets;
while (tmp) {
@ -494,8 +494,12 @@ void Level_PreloadBitmaps(struct Game *game, void (*progress)(struct Game*, floa
PROGRESS;
game->level.obst_bmps.pig = LoadScaledBitmap("levels/pig.png", (int)(al_get_display_width(game->display)*0.15)*3, (int)(al_get_display_height(game->display)*0.2)*3);
PROGRESS;
game->level.obst_bmps.screwball = LoadScaledBitmap("levels/screwball.png", (int)(al_get_display_height(game->display)*0.2)*4*1.4, (int)(al_get_display_height(game->display)*0.2)*4);
PROGRESS;
game->level.obst_bmps.muffin = LoadScaledBitmap("levels/muffin.png", al_get_display_width(game->display)*0.07, al_get_display_height(game->display)*0.1);
PROGRESS;
game->level.obst_bmps.badmuffin = LoadScaledBitmap("levels/badmuffin.png", al_get_display_width(game->display)*0.07, al_get_display_height(game->display)*0.1);
PROGRESS;
game->level.owl = LoadScaledBitmap("levels/owl.png", al_get_display_width(game->display)*0.08, al_get_display_width(game->display)*0.08);
PROGRESS;
game->level.welcome = al_create_bitmap(al_get_display_width(game->display), al_get_display_height(game->display)/2);

View file

@ -117,17 +117,26 @@ bool GenerateObstacles(struct Game *game, struct TM_Action *action, enum TM_Acti
obst->anim_speed = 0;
obst->tmp_pos = 0;
obst->angle = 0;
if (rand()%100<=15) {
if (rand()%100<=50) {
obst->callback= NULL;
obst->data = NULL;
obst->points = -5;
obst->bitmap = &(game->level.obst_bmps.badmuffin);
obst->speed = 1.2;
} else if (rand()%100<=12) {
obst->callback= &Obst_RotateSin;
obst->data = malloc(sizeof(float));
*((float*)obst->data) = 0;
obst->points = 5;
obst->bitmap = &(game->level.obst_bmps.muffin);
} else if (rand()%100<=75) {
obst->callback= &Obst_MoveUpDown;
} else if (rand()%100<=70) {
obst->callback= &Obst_MoveUp;
obst->bitmap = &(game->level.obst_bmps.pie);
obst->data = (void*)(rand()%2);
} else {
obst->data = malloc(sizeof(float));
*((float*)obst->data) = 0.5+(rand()%25/100.0);
obst->y*=1.8;
obst->angle = ((rand()%50)/100.0)-0.25;
} else if (rand()%100<=70) {
obst->callback = &Obst_MoveSin;
obst->data = malloc(sizeof(float));
*((float*)obst->data) = 0;
@ -137,6 +146,15 @@ bool GenerateObstacles(struct Game *game, struct TM_Action *action, enum TM_Acti
obst->speed = 1.2;
obst->anim_speed = 2;
obst->points = -20;
} else {
obst->callback = &Obst_MoveUpDown;
obst->bitmap = &(game->level.obst_bmps.screwball);
obst->data = (void*)(rand()%2);
obst->rows = 4;
obst->cols = 4;
obst->speed = 1.2;
obst->anim_speed = 2;
obst->points = -25;
}
if (game->level.obstacles) {
game->level.obstacles->prev = obst;

View file

@ -36,6 +36,11 @@ void Obst_MoveUpDown(struct Game *game, struct Obstacle *obstacle) {
}
}
void Obst_MoveUp(struct Game *game, struct Obstacle *obstacle) {
float* a = (float*)obstacle->data;
obstacle->y -= *a;
}
void Obst_RotateSin(struct Game *game, struct Obstacle *obstacle) {
float* a = (float*)obstacle->data;
/*PrintConsole(game, "%p - %f", obstacle, obstacle->y);*/

View file

@ -24,6 +24,9 @@
/*! \brief Move up or down until reaching the edge of the screen. After that - change direction. */
void Obst_MoveUpDown(struct Game *game, struct Obstacle *obstacle);
/*! \brief Move up at constant speed. */
void Obst_MoveUp(struct Game *game, struct Obstacle *obstacle);
/*! \brief Move in sinusoidal way in Y-axis relative to position at beginning. */
void Obst_MoveSin(struct Game *game, struct Obstacle *obstacle);

View file

@ -137,8 +137,10 @@ struct Level {
struct Spritesheet* pony_sheets; /*!< List of sprite sheets of character rescued by Derpy. */
struct {
ALLEGRO_BITMAP *pie; /*!< Pie bitmap. */
ALLEGRO_BITMAP *muffin; /*!< Muffin bitmap. */
ALLEGRO_BITMAP *muffin; /*!< Good muffin bitmap. */
ALLEGRO_BITMAP *badmuffin; /*!< Bad muffin bitmap. */
ALLEGRO_BITMAP *pig; /*!< Pig spritesheet bitmap. */
ALLEGRO_BITMAP *screwball; /*!< Screwball spritesheet bitmap. */
} obst_bmps; /*!< Obstacle bitmaps. */
struct Obstacle *obstacles; /*!< List of obstacles being currently rendered. */
struct Moonwalk moonwalk; /*!< Moonwalk placeholder data. */