2022-04-04 08:16:10 +02:00
|
|
|
|
#include "main.h"
|
|
|
|
|
#include "attack.h"
|
2022-04-04 15:31:01 +02:00
|
|
|
|
#include "bullet.h"
|
2022-04-04 08:16:10 +02:00
|
|
|
|
#include "level.h"
|
2022-04-04 15:31:01 +02:00
|
|
|
|
#include "lzy.h"
|
2022-04-04 08:16:10 +02:00
|
|
|
|
#include "overlay.h"
|
|
|
|
|
#include "particle.h"
|
2022-04-04 15:31:01 +02:00
|
|
|
|
#include "player.h"
|
|
|
|
|
#include "sandbag.h"
|
2022-02-28 15:38:08 +01:00
|
|
|
|
|
2022-04-04 08:16:10 +02:00
|
|
|
|
#include <math.h>
|
2022-04-04 15:31:01 +02:00
|
|
|
|
#include <stdlib.h>
|
2022-02-28 21:47:26 +01:00
|
|
|
|
|
2022-04-04 08:16:10 +02:00
|
|
|
|
static int frame, chara, level;
|
|
|
|
|
static int log_init(int x);
|
|
|
|
|
static int init(int argc, const char **argv);
|
|
|
|
|
static void update(void);
|
|
|
|
|
static void draw(int frame);
|
|
|
|
|
static int menu(void);
|
|
|
|
|
static void draw_bg(int frame);
|
2022-02-28 18:01:06 +01:00
|
|
|
|
|
2022-04-04 08:16:10 +02:00
|
|
|
|
/* debug */
|
|
|
|
|
|
2022-04-04 15:31:01 +02:00
|
|
|
|
int init(int argc, const char **argv) {
|
|
|
|
|
srand(69);
|
|
|
|
|
if (LZY_Init(argc, argv, "lzy example", 30, "res/tset.png", "res/font.png")) {
|
|
|
|
|
LZY_Log(LZY_GetError());
|
|
|
|
|
LZY_Quit();
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
menu();
|
|
|
|
|
|
|
|
|
|
level_init(level, chara);
|
|
|
|
|
frame = 0;
|
|
|
|
|
return 0;
|
2022-04-04 08:16:10 +02:00
|
|
|
|
}
|
|
|
|
|
|
2022-04-04 15:31:01 +02:00
|
|
|
|
void update(void) {
|
|
|
|
|
LZY_CycleEvents();
|
|
|
|
|
player_update();
|
|
|
|
|
sandbag_update(frame);
|
|
|
|
|
bullet_table_update();
|
|
|
|
|
attack_table_update();
|
|
|
|
|
particle_table_update();
|
2022-04-04 08:16:10 +02:00
|
|
|
|
}
|
|
|
|
|
|
2022-04-04 15:31:01 +02:00
|
|
|
|
void draw(int frame) {
|
|
|
|
|
/* draw */
|
|
|
|
|
LZY_DrawBegin();
|
|
|
|
|
{
|
|
|
|
|
level_draw();
|
|
|
|
|
player_draw(frame);
|
|
|
|
|
sandbag_draw(frame);
|
|
|
|
|
bullet_table_draw(frame);
|
|
|
|
|
attack_table_draw(frame);
|
|
|
|
|
particle_table_draw(frame);
|
|
|
|
|
|
|
|
|
|
overlay_draw(114, 176, chara, player_get_life());
|
|
|
|
|
overlay_draw(210, 176, -1, sandbag_get_life());
|
|
|
|
|
}
|
|
|
|
|
LZY_DrawEnd();
|
2022-04-04 08:16:10 +02:00
|
|
|
|
}
|
|
|
|
|
|
2022-04-04 15:31:01 +02:00
|
|
|
|
int main(int argc, const char **argv) {
|
|
|
|
|
if (init(argc, argv)) {
|
|
|
|
|
return 1;
|
|
|
|
|
} /* error */
|
2022-03-10 21:14:59 +01:00
|
|
|
|
|
2022-04-04 15:31:01 +02:00
|
|
|
|
while (!LZY_ShouldQuit()) {
|
|
|
|
|
update();
|
|
|
|
|
draw(frame);
|
2022-03-10 21:14:59 +01:00
|
|
|
|
|
2022-04-04 15:31:01 +02:00
|
|
|
|
frame += 1;
|
|
|
|
|
}
|
2022-04-04 08:16:10 +02:00
|
|
|
|
|
2022-04-04 15:31:01 +02:00
|
|
|
|
LZY_Log("cya");
|
|
|
|
|
LZY_Quit();
|
2022-04-04 08:16:10 +02:00
|
|
|
|
|
2022-04-04 15:31:01 +02:00
|
|
|
|
return 0;
|
2022-04-04 08:16:10 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int menu(void) {
|
2022-04-04 15:31:01 +02:00
|
|
|
|
/* main loop of the menu */
|
|
|
|
|
int running = 1;
|
|
|
|
|
int frame = 0;
|
|
|
|
|
while (running) {
|
|
|
|
|
LZY_CycleEvents();
|
|
|
|
|
|
|
|
|
|
LZY_DrawBegin();
|
|
|
|
|
{
|
|
|
|
|
draw_bg(frame);
|
|
|
|
|
LZY_DrawTileEx(247, LZY_DISPLAY_WIDTH / 2 - 72, 30, 6, 5);
|
|
|
|
|
if (frame % 16 < 8) {
|
|
|
|
|
LZY_DrawText("- PRESS SHIFT -", 134, 181);
|
|
|
|
|
LZY_DrawText("- PRESS SHIFT -", 134, 180);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
LZY_DrawEnd();
|
|
|
|
|
running = !LZY_KeyDown(LZYK_O);
|
|
|
|
|
frame += 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
while (LZY_KeyDown(LZYK_O)) {
|
|
|
|
|
LZY_CycleEvents();
|
|
|
|
|
}
|
|
|
|
|
running = 1;
|
|
|
|
|
int selec = 1;
|
|
|
|
|
int wait = 0;
|
|
|
|
|
|
|
|
|
|
while (running) {
|
|
|
|
|
LZY_CycleEvents();
|
|
|
|
|
|
|
|
|
|
LZY_DrawBegin();
|
|
|
|
|
{
|
|
|
|
|
draw_bg(frame);
|
|
|
|
|
LZY_DrawTile(61, 186 + (selec - 2.5) * 48,
|
|
|
|
|
64.0f + sin((float)frame / 5) * 5.0f);
|
|
|
|
|
for (int i = 1; i < 5; ++i) {
|
|
|
|
|
LZY_DrawTile(i * 23, 186 + (i - 2.5) * 48, 100);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
switch (selec) {
|
|
|
|
|
case 1:
|
|
|
|
|
LZY_DrawText("DELTA", 178, 151);
|
|
|
|
|
LZY_DrawText("DELTA", 178, 150);
|
|
|
|
|
LZY_DrawText("PAR MASSENA", 16, 200);
|
|
|
|
|
LZY_DrawText("DANS FROZEN FRENZY", 16, 208);
|
|
|
|
|
break;
|
|
|
|
|
case 2:
|
|
|
|
|
LZY_DrawText("GRAVITY DUCK", 150, 151);
|
|
|
|
|
LZY_DrawText("GRAVITY DUCK", 150, 150);
|
|
|
|
|
LZY_DrawText("PAR PIEROTLL", 16, 200);
|
|
|
|
|
LZY_DrawText("DANS GRAVITY DUCK", 16, 208);
|
|
|
|
|
break;
|
|
|
|
|
case 3:
|
|
|
|
|
LZY_DrawText("AVENTURIER POUDINGUE", 118, 151);
|
|
|
|
|
LZY_DrawText("AVENTURIER POUDINGUE", 118, 150);
|
|
|
|
|
LZY_DrawText("PAR DRAK", 16, 200);
|
|
|
|
|
LZY_DrawText("DANS AVENTURA, LE ROYAUME POUDINGUE", 16, 208);
|
|
|
|
|
break;
|
|
|
|
|
case 4:
|
|
|
|
|
LZY_DrawText("SAKIMI HAKYU", 150, 151);
|
|
|
|
|
LZY_DrawText("SAKIMI HAKYU", 150, 150);
|
|
|
|
|
LZY_DrawText("PAR REDEYES", 16, 200);
|
|
|
|
|
LZY_DrawText("DANS SWORD BURST ZERO", 16, 208);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
LZY_DrawEnd();
|
|
|
|
|
running = !LZY_KeyDown(LZYK_O);
|
|
|
|
|
if (LZY_KeyDown(LZYK_LEFT) && selec > 1 && !wait) {
|
|
|
|
|
selec -= 1;
|
|
|
|
|
wait = 5;
|
|
|
|
|
};
|
|
|
|
|
if (LZY_KeyDown(LZYK_RIGHT) && selec < 4 && !wait) {
|
|
|
|
|
selec += 1;
|
|
|
|
|
wait = 5;
|
|
|
|
|
};
|
|
|
|
|
frame += 1;
|
|
|
|
|
if (wait > 0)
|
|
|
|
|
--wait;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
while (LZY_KeyDown(LZYK_O)) {
|
|
|
|
|
LZY_CycleEvents();
|
|
|
|
|
}
|
|
|
|
|
running = 1;
|
|
|
|
|
int selec_level = 1;
|
|
|
|
|
wait = 0;
|
|
|
|
|
|
|
|
|
|
while (running) {
|
|
|
|
|
LZY_CycleEvents();
|
|
|
|
|
|
|
|
|
|
LZY_DrawBegin();
|
|
|
|
|
{
|
|
|
|
|
draw_bg(frame);
|
|
|
|
|
LZY_DrawTile(61, 90 + (selec_level - 1) * 96,
|
|
|
|
|
40.0f + sin((float)frame / 5) * 5.0f);
|
|
|
|
|
for (int i = 1; i < 4; ++i) {
|
|
|
|
|
LZY_DrawTileEx(307 + (i - 1) * 3, 66 + (i - 1) * 96, 76, 3, 2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
switch (selec_level) {
|
|
|
|
|
case 1:
|
|
|
|
|
LZY_DrawText("GRAVITY FOREST DX", 130, 151);
|
|
|
|
|
LZY_DrawText("GRAVITY FOREST DX", 130, 150);
|
|
|
|
|
break;
|
|
|
|
|
case 2:
|
|
|
|
|
LZY_DrawText("SANCTUAIRE DE RECUPERATION", 90, 151);
|
|
|
|
|
LZY_DrawText("SANCTUAIRE DE RECUPERATION", 90, 150);
|
|
|
|
|
break;
|
|
|
|
|
case 3:
|
|
|
|
|
LZY_DrawText("PLANETE PLATFORMER", 126, 151);
|
|
|
|
|
LZY_DrawText("PLANETE PLATFORMER", 126, 150);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
LZY_DrawEnd();
|
|
|
|
|
running = !LZY_KeyDown(LZYK_O);
|
|
|
|
|
if (LZY_KeyDown(LZYK_LEFT) && selec_level > 1 && !wait) {
|
|
|
|
|
selec_level -= 1;
|
|
|
|
|
wait = 5;
|
|
|
|
|
};
|
|
|
|
|
if (LZY_KeyDown(LZYK_RIGHT) && selec_level < 3 && !wait) {
|
|
|
|
|
selec_level += 1;
|
|
|
|
|
wait = 5;
|
|
|
|
|
};
|
|
|
|
|
frame += 1;
|
|
|
|
|
if (wait > 0)
|
|
|
|
|
--wait;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
chara = selec - 1;
|
|
|
|
|
level = selec_level - 1;
|
|
|
|
|
return 1;
|
2022-04-04 08:16:10 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void draw_bg(int frame) {
|
2022-04-04 15:31:01 +02:00
|
|
|
|
LZY_DrawSetColor(240, 181, 65);
|
|
|
|
|
LZY_DrawClear();
|
|
|
|
|
LZY_DrawSetColor(255, 137, 51);
|
|
|
|
|
|
|
|
|
|
for (int x = frame % 32 - 32; x < LZY_DISPLAY_WIDTH + 32; x += 32) {
|
|
|
|
|
for (int y = frame % 32 - 32; y < LZY_DISPLAY_HEIGHT + 32; y += 32) {
|
|
|
|
|
LZY_DrawRect(x - 1, y - 1, 32, 32);
|
|
|
|
|
LZY_DrawRect(x, y, 32, 32);
|
|
|
|
|
LZY_DrawRect(x + 1, y + 1, 32, 32);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LZY_DrawSetColor(207, 117, 43);
|
|
|
|
|
for (int x = (frame * 2) % 32 - 32; x < LZY_DISPLAY_WIDTH + 32; x += 32) {
|
|
|
|
|
for (int y = (frame * 2) % 32 - 32; y < LZY_DISPLAY_HEIGHT + 32; y += 32) {
|
|
|
|
|
LZY_DrawRect(x, y, 32, 32);
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-02-28 21:47:26 +01:00
|
|
|
|
}
|