start of main menu (EXE to play)
This commit is contained in:
parent
1771e691ec
commit
01caf4d589
|
@ -14,9 +14,11 @@ set(SOURCES
|
|||
src/render.c
|
||||
src/physics.c
|
||||
src/text.c
|
||||
src/menu.c
|
||||
)
|
||||
set(ASSETS
|
||||
assets-cg/font.png
|
||||
assets-cg/title.png
|
||||
assets-cg/level/level1.txt
|
||||
assets-cg/level/level2.txt
|
||||
assets-cg/level/level3.txt
|
||||
|
|
|
@ -7,3 +7,8 @@ font.png:
|
|||
grid.border: 0
|
||||
proportional: true
|
||||
height: 10
|
||||
|
||||
title.png:
|
||||
type: bopti-image
|
||||
name: img_title
|
||||
profile: p4
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 349 B |
|
@ -105,7 +105,7 @@ void dtriangle(int x1, int y1, int x2, int y2, int x3, int y3, int color);
|
|||
|
||||
void drectoid(rect_t const *r, int color);
|
||||
|
||||
void render_player(float angle);
|
||||
void render_player(int x, int y, float angle);
|
||||
|
||||
//---
|
||||
// Duet Text
|
||||
|
@ -137,3 +137,10 @@ void rect_physics(rect_t *r, rectmeta_t const *meta, float time);
|
|||
extern level_t level1, level2, level3, level4;
|
||||
extern level_t level5, level6, level7, level8;
|
||||
extern level_t level9, level10;
|
||||
|
||||
//---
|
||||
// Menu
|
||||
//---
|
||||
|
||||
/* Main menu, returns selected level or -1. */
|
||||
int main_menu(void);
|
||||
|
|
|
@ -55,7 +55,7 @@ int main(void)
|
|||
&level1, &level2, &level3, &level4, &level5, &level6, &level7,
|
||||
&level8, &level9, &level10, NULL,
|
||||
};
|
||||
int story_position = 5;
|
||||
int story_position = main_menu();
|
||||
|
||||
game_t game;
|
||||
load_level(&game, story_levels[story_position]);
|
||||
|
@ -189,7 +189,7 @@ int main(void)
|
|||
}
|
||||
}
|
||||
|
||||
render_player(game.player_rota);
|
||||
render_player(PLAYER_X, DHEIGHT/2, game.player_rota);
|
||||
for(int i = 0; i < game.rect_count; i++)
|
||||
drectoid(&game.rects[i], C_WHITE);
|
||||
dupdate();
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
#include <gint/display.h>
|
||||
#include <gint/keyboard.h>
|
||||
#include <gint/timer.h>
|
||||
#include <gint/gint.h>
|
||||
|
||||
#include "duet.h"
|
||||
|
||||
extern bopti_image_t img_title;
|
||||
|
||||
int main_menu(void)
|
||||
{
|
||||
volatile int need_frame = 1;
|
||||
int timer = timer_configure(TIMER_ANY, 33000, GINT_CALL_SET(&need_frame));
|
||||
timer_start(timer);
|
||||
|
||||
float time = 0;
|
||||
int selected_level = 0;
|
||||
|
||||
while(1) {
|
||||
time += 1.0 / 30;
|
||||
|
||||
/* Keyboard input */
|
||||
|
||||
key_event_t e;
|
||||
bool input_finished = false;
|
||||
|
||||
while((e = pollevent()).type != KEYEV_NONE) {
|
||||
if(e.type == KEYEV_DOWN && e.key == KEY_MENU)
|
||||
gint_osmenu();
|
||||
if(e.type == KEYEV_DOWN && e.key == KEY_EXE) {
|
||||
input_finished = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(input_finished)
|
||||
break;
|
||||
|
||||
/* Rendering */
|
||||
|
||||
dclear(C_BLACK);
|
||||
dimage(330, DHEIGHT/2 - img_title.height / 2,
|
||||
&img_title);
|
||||
render_player(265, DHEIGHT/2, time * 0.8);
|
||||
dupdate();
|
||||
}
|
||||
|
||||
timer_stop(timer);
|
||||
return selected_level;
|
||||
}
|
|
@ -105,14 +105,18 @@ void drectoid(rect_t const *r, int color)
|
|||
dtriangle(x[2], y[2], x[3], y[3], x[0], y[0], color);
|
||||
}
|
||||
|
||||
void render_player(float angle)
|
||||
void render_player(int x, int y, float angle)
|
||||
{
|
||||
int x=PLAYER_X, y=DHEIGHT/2;
|
||||
dcircle(x, y, PLAYER_R, C_RGB(10, 10, 10), false);
|
||||
|
||||
float x1, y1, x2, y2;
|
||||
player_position(angle, &x1, &y1, &x2, &y2);
|
||||
|
||||
x1 = x1 - PLAYER_X + x;
|
||||
y1 = y1 - DHEIGHT/2 + y;
|
||||
x2 = x2 - PLAYER_X + x;
|
||||
y2 = y2 - DHEIGHT/2 + y;
|
||||
|
||||
dcircle(x1, y1, PLAYER_SIZE, C_RGB(0, 16, 26), true);
|
||||
dcircle(x2, y2, PLAYER_SIZE, C_RGB(31, 6, 0), true);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue