mirror of
https://gitlab.com/dosowisko.net/libsuperderpy.git
synced 2025-03-04 17:21:27 +01:00
some work on playability
This commit is contained in:
parent
3f16d776cf
commit
a13ef8d88d
4 changed files with 58 additions and 17 deletions
|
@ -1,3 +1,21 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) Sebastian Krzyszkowiak <dos@dosowisko.net>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
#include "allegro_utils.h"
|
#include "allegro_utils.h"
|
||||||
|
|
||||||
void al_draw_vertical_gradient_rect(float x, float y, float w, float h, ALLEGRO_COLOR top, ALLEGRO_COLOR bottom) {
|
void al_draw_vertical_gradient_rect(float x, float y, float w, float h, ALLEGRO_COLOR top, ALLEGRO_COLOR bottom) {
|
||||||
|
|
|
@ -1,7 +1,25 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) Sebastian Krzyszkowiak <dos@dosowisko.net>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
#include <allegro5/allegro.h>
|
#include <allegro5/allegro.h>
|
||||||
#include <allegro5/allegro_primitives.h>
|
#include <allegro5/allegro_primitives.h>
|
||||||
#include <allegro5/allegro_font.h>
|
#include <allegro5/allegro_font.h>
|
||||||
|
|
||||||
void al_draw_vertical_gradient_rect(float x, float y, float w, float h, ALLEGRO_COLOR top, ALLEGRO_COLOR bottom);
|
void al_draw_vertical_gradient_rect(float x, float y, float w, float h, ALLEGRO_COLOR top, ALLEGRO_COLOR bottom);
|
||||||
void al_draw_horizontal_gradient_rect(float x, float y, float w, float h, ALLEGRO_COLOR left, ALLEGRO_COLOR right);
|
void al_draw_horizontal_gradient_rect(float x, float y, float w, float h, ALLEGRO_COLOR left, ALLEGRO_COLOR right);
|
||||||
void al_draw_text_with_shadow(ALLEGRO_FONT *font, ALLEGRO_COLOR color, float x, float y, int flags, char const *text);
|
void al_draw_text_with_shadow(ALLEGRO_FONT *font, ALLEGRO_COLOR color, float x, float y, int flags, char const *text);
|
||||||
|
|
36
src/level.c
36
src/level.c
|
@ -90,8 +90,8 @@ void Level_Passed(struct Game *game) {
|
||||||
|
|
||||||
bool Accelerate(struct Game *game, struct TM_Action *action, enum TM_ActionState state) {
|
bool Accelerate(struct Game *game, struct TM_Action *action, enum TM_ActionState state) {
|
||||||
if (state != TM_ACTIONSTATE_RUNNING) return false;
|
if (state != TM_ACTIONSTATE_RUNNING) return false;
|
||||||
game->level.speed+=0.000005;
|
game->level.speed+=0.000015;
|
||||||
if (game->level.speed<0.0020) return false;
|
if (game->level.speed<0.0025) return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -167,7 +167,7 @@ bool GenerateObstracles(struct Game *game, struct TM_Action *action, enum TM_Act
|
||||||
*in = true;*/
|
*in = true;*/
|
||||||
}
|
}
|
||||||
else if (state == TM_ACTIONSTATE_RUNNING) {
|
else if (state == TM_ACTIONSTATE_RUNNING) {
|
||||||
if (rand()%(10000/(int)tps(game, 60*100))<=2) {
|
if (rand()%(10000/(int)tps(game, 60*100))<=1) {
|
||||||
PrintConsole(game, "OBSTRACLE %d", *count);
|
PrintConsole(game, "OBSTRACLE %d", *count);
|
||||||
(*count)++;
|
(*count)++;
|
||||||
struct Obstracle *obst = malloc(sizeof(struct Obstracle));
|
struct Obstracle *obst = malloc(sizeof(struct Obstracle));
|
||||||
|
@ -175,6 +175,8 @@ bool GenerateObstracles(struct Game *game, struct TM_Action *action, enum TM_Act
|
||||||
obst->x = 100;
|
obst->x = 100;
|
||||||
obst->y = (rand()%91)-1;
|
obst->y = (rand()%91)-1;
|
||||||
obst->speed = 0;
|
obst->speed = 0;
|
||||||
|
obst->points = -10;
|
||||||
|
obst->hit = false;
|
||||||
obst->bitmap = &(game->level.obst_bmps.pie);
|
obst->bitmap = &(game->level.obst_bmps.pie);
|
||||||
obst->callback = NULL;
|
obst->callback = NULL;
|
||||||
obst->data = (void*)(rand()%2);
|
obst->data = (void*)(rand()%2);
|
||||||
|
@ -227,14 +229,14 @@ void Level_Draw(struct Game *game) {
|
||||||
al_get_keyboard_state(&keyboard);
|
al_get_keyboard_state(&keyboard);
|
||||||
if (game->level.handle_input) {
|
if (game->level.handle_input) {
|
||||||
if (al_key_down(&keyboard, ALLEGRO_KEY_UP)) {
|
if (al_key_down(&keyboard, ALLEGRO_KEY_UP)) {
|
||||||
game->level.derpy_y -= tps(game, 60*0.005);
|
game->level.derpy_y -= tps(game, 60*0.0075);
|
||||||
/*PrintConsole(game, "Derpy Y position: %f", game->level.derpy_y);*/
|
/*PrintConsole(game, "Derpy Y position: %f", game->level.derpy_y);*/
|
||||||
}
|
}
|
||||||
if (al_key_down(&keyboard, ALLEGRO_KEY_DOWN)) {
|
if (al_key_down(&keyboard, ALLEGRO_KEY_DOWN)) {
|
||||||
game->level.derpy_y += tps(game, 60*0.005);
|
game->level.derpy_y += tps(game, 60*0.0075);
|
||||||
/*PrintConsole(game, "Derpy Y position: %f", game->level.derpy_y);*/
|
/*PrintConsole(game, "Derpy Y position: %f", game->level.derpy_y);*/
|
||||||
}
|
}
|
||||||
if ((game->level.derpy_y > 0.6) && (game->level.flying)) {
|
/*if ((game->level.derpy_y > 0.6) && (game->level.flying)) {
|
||||||
SelectDerpySpritesheet(game, "run");
|
SelectDerpySpritesheet(game, "run");
|
||||||
game->level.flying = false;
|
game->level.flying = false;
|
||||||
game->level.sheet_speed = tps(game, 60*0.0020/game->level.speed);
|
game->level.sheet_speed = tps(game, 60*0.0020/game->level.speed);
|
||||||
|
@ -243,7 +245,7 @@ void Level_Draw(struct Game *game) {
|
||||||
SelectDerpySpritesheet(game, "fly");
|
SelectDerpySpritesheet(game, "fly");
|
||||||
game->level.flying = true;
|
game->level.flying = true;
|
||||||
game->level.sheet_speed = tps(game, 60*2.4);
|
game->level.sheet_speed = tps(game, 60*2.4);
|
||||||
}
|
}*/
|
||||||
if (!game->level.flying) game->level.sheet_speed = tps(game, 60*0.0020/game->level.speed);
|
if (!game->level.flying) game->level.sheet_speed = tps(game, 60*0.0020/game->level.speed);
|
||||||
if (game->level.derpy_y < 0) game->level.derpy_y=0;
|
if (game->level.derpy_y < 0) game->level.derpy_y=0;
|
||||||
else if (game->level.derpy_y > 0.8) game->level.derpy_y=0.8;
|
else if (game->level.derpy_y > 0.8) game->level.derpy_y=0.8;
|
||||||
|
@ -266,16 +268,18 @@ void Level_Draw(struct Game *game) {
|
||||||
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) {
|
||||||
bool col = false;
|
|
||||||
int x = (tmp->x/100.0)*al_get_display_width(game->display);
|
int x = (tmp->x/100.0)*al_get_display_width(game->display);
|
||||||
int y = (tmp->y/100.0)*al_get_display_height(game->display);
|
int y = (tmp->y/100.0)*al_get_display_height(game->display);
|
||||||
int w = al_get_bitmap_width(*(tmp->bitmap));
|
int w = al_get_bitmap_width(*(tmp->bitmap));
|
||||||
int h = al_get_bitmap_height(*(tmp->bitmap));
|
int h = al_get_bitmap_height(*(tmp->bitmap));
|
||||||
if ((((x>=derpyx) && (x<=derpyx+derpyw)) || ((x+w>=derpyx) && (x+w<=derpyx+derpyw))) &&
|
if (!tmp->hit)
|
||||||
(((y>=derpyy) && (y<=derpyy+derpyh)) || ((y+h>=derpyy) && (y+h<=derpyy+derpyh))))
|
if ((((x>=derpyx+0.36*derpyw) && (x<=derpyx+0.94*derpyw)) || ((x+w>=derpyx+0.36*derpyw) && (x+w<=derpyx+0.94*derpyw))) &&
|
||||||
col = true;
|
(((y>=derpyy+0.26*derpyh) && (y<=derpyy+0.76*derpyh)) || ((y+h>=derpyy+0.26*derpyh) && (y+h<=derpyy+0.76*derpyh)))) {
|
||||||
al_draw_tinted_bitmap(*(tmp->bitmap), al_map_rgba(255,255-col*255,255-col*255,255), x, y, 0);
|
tmp->hit=true;
|
||||||
if (col) colision = true;
|
game->level.hp+=tps(game, 60*0.0002*tmp->points);
|
||||||
|
}
|
||||||
|
al_draw_bitmap(*(tmp->bitmap), x, y, 0);
|
||||||
|
if (tmp->hit) colision = true;
|
||||||
tmp->x -= tps(game, game->level.speed*60)*310;
|
tmp->x -= tps(game, game->level.speed*60)*310;
|
||||||
if (tmp->callback) tmp->callback(game, tmp);
|
if (tmp->callback) tmp->callback(game, tmp);
|
||||||
tmp = tmp->next;
|
tmp = tmp->next;
|
||||||
|
@ -291,7 +295,7 @@ void Level_Draw(struct Game *game) {
|
||||||
free(t);
|
free(t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (colision) game->level.hp-=0.0005;
|
if (colision) game->level.hp-=tps(game, 60*0.002);
|
||||||
al_hold_bitmap_drawing(false);
|
al_hold_bitmap_drawing(false);
|
||||||
|
|
||||||
al_set_target_bitmap(game->level.derpy);
|
al_set_target_bitmap(game->level.derpy);
|
||||||
|
@ -469,10 +473,10 @@ void Level_Load(struct Game *game) {
|
||||||
TM_AddAction(&Stop, NULL, "stop");
|
TM_AddAction(&Stop, NULL, "stop");
|
||||||
TM_AddDelay(1000);
|
TM_AddDelay(1000);
|
||||||
TM_AddAction(&Letter, NULL, "letter");
|
TM_AddAction(&Letter, NULL, "letter");
|
||||||
TM_AddDelay(500);
|
TM_AddDelay(200);
|
||||||
TM_AddQueuedBackgroundAction(&Accelerate, NULL, 0, "accelerate");
|
TM_AddQueuedBackgroundAction(&Accelerate, NULL, 0, "accelerate");
|
||||||
TM_AddAction(&Fly, NULL, "fly");
|
TM_AddAction(&Fly, NULL, "fly");
|
||||||
TM_AddDelay(5*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 obstracles should go here
|
||||||
|
|
|
@ -57,6 +57,7 @@ struct Obstracle {
|
||||||
ALLEGRO_BITMAP **bitmap;
|
ALLEGRO_BITMAP **bitmap;
|
||||||
float x, y, speed;
|
float x, y, speed;
|
||||||
int points;
|
int points;
|
||||||
|
bool hit;
|
||||||
void (*callback)(struct Game*, struct Obstracle*);
|
void (*callback)(struct Game*, struct Obstracle*);
|
||||||
void *data;
|
void *data;
|
||||||
struct Obstracle *prev, *next;
|
struct Obstracle *prev, *next;
|
||||||
|
|
Loading…
Add table
Reference in a new issue