239 lines
5.4 KiB
C
239 lines
5.4 KiB
C
#include "main.h"
|
||
#include "attack.h"
|
||
#include "bullet.h"
|
||
#include "level.h"
|
||
#include "lzy.h"
|
||
#include "overlay.h"
|
||
#include "particle.h"
|
||
#include "player.h"
|
||
#include "sandbag.h"
|
||
|
||
#include <math.h>
|
||
#include <stdlib.h>
|
||
|
||
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);
|
||
|
||
/* debug */
|
||
|
||
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;
|
||
}
|
||
|
||
void update(void) {
|
||
LZY_CycleEvents();
|
||
player_update();
|
||
sandbag_update(frame);
|
||
bullet_table_update();
|
||
attack_table_update();
|
||
particle_table_update();
|
||
}
|
||
|
||
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();
|
||
}
|
||
|
||
int main(int argc, const char **argv) {
|
||
if (init(argc, argv)) {
|
||
return 1;
|
||
} /* error */
|
||
|
||
while (!LZY_ShouldQuit()) {
|
||
update();
|
||
draw(frame);
|
||
|
||
frame += 1;
|
||
}
|
||
|
||
LZY_Log("cya");
|
||
LZY_Quit();
|
||
|
||
return 0;
|
||
}
|
||
|
||
int menu(void) {
|
||
/* 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;
|
||
}
|
||
|
||
void draw_bg(int frame) {
|
||
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);
|
||
}
|
||
}
|
||
}
|