#define ZeichnenAnfangen() BeginDrawing()
#define ZeichnenAufhören() EndDrawing()
-#define SPEED 20
+#define SPEED 30
#define GRAVITY 20
#define FRAMELENGTH 0.1
-#define JUMPVELOCITY -90
+#define JUMPVELOCITY -130
+
+#define LEVELS 3
struct character *spielersetup(void);
-#define STAGECOUNT 2
-#define DIALOGUECOUNT 4
-#define PLATFORMCOUNT 3
+#define STAGECOUNT 3
+#define DIALOGUECOUNT 6
+#define PLATFORMCOUNT 5
#include "game.h"
{"Hello!! [press 'H' to advance dialogue]", "Ai-chan", "dialogue-img/aichan-default.png", GREEN},
{"My name is Ai-chan, and i;m the AI of the Hyperion battleship :3", "Ai-chan", "dialogue-img/aichan-default.png", GREEN},
{"(for context thsi is a honkai impact 3 reference... i swear it makes sense", "context", "dialogue-img/aichan-default.png", BLACK},
- {"Please press 'A' and 'D' to move LEFT and RIGHT; advance to the RIGHT side of the screen to finish this level!!", "Ai-chan", "dialogue-img/aichan-default.png", GREEN}};
+ {"Please press 'A' and 'D' to move LEFT and RIGHT; advance to the RIGHT side of the screen to finish this level!!", "Ai-chan", "dialogue-img/aichan-default.png", GREEN},
+ {"Press 'H' to JUMP", "Ai-chan", "dialogue-img/aichan-default.png", GREEN},
+ {"YOU WIN!!", "Ai-chan", "dialogue-img/aichan-default.png", GREEN}
+};
struct platform platforms[PLATFORMCOUNT] = {
{{0,320,640,160},GREEN},
{{0,320,640,160},GREEN},
- {{310, 300, 40, 20}, GREEN}
+ {{310, 300, 40, 20}, GREEN},
+ {{0, 320, 640, 160}, GREEN},
+ {{320, 0, 320, 480}, GREEN}
};
struct stage stages[STAGECOUNT] = {
{"Level 0", platforms, 1, dialogues, 4},
- {"Level 1", platforms+1, 2, dialogues+4, 1}
+ {"Level 1", platforms+1, 2, dialogues+4, 1},
+ {"End", platforms+3, 2, dialogues+5, 1}
};
while (!WindowShouldClose()) {
//variables.
- variables(GetFrameTime(), player);
- ZeichnenAnfangen();
- bühnezeichnen();
- spielerzeichnen();
- ZeichnenAufhören();
+ variables(GetFrameTime(), player);
+ ZeichnenAnfangen();
+ bühnezeichnen();
+ spielerzeichnen();
+ ZeichnenAufhören();
}
CloseWindow();
{
gravity(delta, player);
move_player(delta,player);
+ if (player->rect.x > SCREENWIDTH) {
+ level++;
+ player->rect.x = 15; player->rect.y = 120;
+ if (level == LEVELS) {
+ //end game
+ };
+ };
return 1;
}
{
int veloy, velox; velox = p->velocity.x; veloy = p->velocity.y;
//printf("x velocity: %d; y velocity: %d; delta: %f\n", velox, veloy, d);
- int distancex, distancey; distancex = ceil(p->velocity.x *d); distancey= ceil(p->velocity.y*d);
+ int distancex, distancey;
+ distancex = (p->velocity.x *d) > 0 ? ceil(p->velocity.x *d) : floor(p->velocity.x *d);
+ distancey= (p->velocity.y *d) > 0 ? ceil(p->velocity.y *d) : floor(p->velocity.y *d);
Vector2 distance;
distance.x = distancex; distance.y = distancey;
//printf("x distance: %d; y distance: %d\n", distance.x, distance.y);
int steps_phys, stepx, stepy;
steps_phys = stepx = stepy = 0;
- if (distance.x == 0) {
- steps_phys = abs(distance.y); stepy = ceil(distance.y/steps_phys); stepx = 0;
+ if (distance.x == 0 && distance.y == 0) {
+ steps_phys = 0; stepy = 0; stepx = 0;
+ } else if (distance.x == 0) {
+ steps_phys = abs(distance.y); stepy = distance.y/steps_phys; stepx = 0;
} else if (distance.y == 0) {
- steps_phys = abs(distance.x); stepx = ceil(distance.x/steps_phys); stepy = 0;
+ steps_phys = abs(distance.x); stepx = (distance.x/steps_phys); stepy = 0;
} else if (abs(distance.x) > abs(distance.y)) { steps_phys = abs(distance.y); stepy = ceil(distance.y/steps_phys); stepx = ceil(distance.x/steps_phys); } else { steps_phys = abs(distance.x); stepx = ceil(distance.x/steps_phys); stepy = round(distance.y/steps_phys); };
//printf("stepx:%d; stepy:%d; steps: %d\n", stepx, stepy, steps_phys);
{
p->rect.x += stepx;
p->rect.y += stepy;
- if (in_floor(&p->rect)) {
+ if (!on_floor(&p->rect) && in_floor(&p->rect)) {
p->rect.x -= stepx; p->rect.y -= stepy;
for (;i < steps_phys; i++) {
if (stepx > 0) {p->rect.x += 1; if (in_floor(&p->rect)) { p->rect.x-=1; };} else if (stepx < 0) {p->rect.x -= 1; if (in_floor(&p->rect)) { p->rect.x+=1; };};
};
int direction;
- if ((IsKeyDown(inputs[0]) && IsKeyDown(inputs[1])) || (!IsKeyDown(inputs[1]) && !IsKeyDown(inputs[0]))) {
- direction = 0;
+ if (IsKeyDown(inputs[1])) {
+ direction = 1;
} else if (IsKeyDown(inputs[0]) == 1) {
direction = -1;
} else {
- direction = 1;
+ direction = 0;
};
player.velocity.x = direction * SPEED;