Player Selection.
may also include traces of minor fixes i forgot.
This commit is contained in:
parent
bd44c8b570
commit
e2ec67bc39
21 changed files with 231 additions and 34 deletions
Binary file not shown.
Before Width: | Height: | Size: 112 KiB After Width: | Height: | Size: 88 KiB |
|
@ -31,6 +31,7 @@ set(SRCs
|
|||
menu/mainmenu.c
|
||||
menu/ingamemenu.c
|
||||
menu/difficulty.c
|
||||
menu/charselect.c
|
||||
stages/stage0.c
|
||||
resource/texture.c
|
||||
resource/animation.c
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
#include <complex.h>
|
||||
|
||||
typedef struct Animation Animation;
|
||||
#include <resource/animation.h>
|
||||
struct Boss;
|
||||
|
||||
typedef void (*BossRule)(struct Boss*, int time);
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#ifndef DIALOG_H
|
||||
#define DIALOG_H
|
||||
|
||||
typedef struct Texture Texture;
|
||||
#include "resource/texture.h"
|
||||
|
||||
struct DialogMessage;
|
||||
struct DialogSpeaker;
|
||||
|
|
|
@ -53,7 +53,7 @@ void calc_fps(FPSCounter *fps) {
|
|||
void set_ortho() {
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glOrtho(0, SCREEN_W, SCREEN_H, 0, -10, 10);
|
||||
glOrtho(0, SCREEN_W, SCREEN_H, 0, -100, 100);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
}
|
|
@ -67,9 +67,12 @@ typedef struct {
|
|||
} FPSCounter;
|
||||
|
||||
typedef struct {
|
||||
Player plr;
|
||||
Difficulty diff;
|
||||
Character plrtype;
|
||||
ShotMode plrmode;
|
||||
|
||||
Player plr;
|
||||
|
||||
Projectile *projs;
|
||||
Enemy *enemies;
|
||||
Item *items;
|
||||
|
|
|
@ -63,8 +63,6 @@ int main(int argc, char** argv) {
|
|||
errx(-1, "Error initializing audio: %s", alutGetErrorString(alutGetError()));
|
||||
init_global();
|
||||
|
||||
init_player(&global.plr, Youmu, YoumuOpposite);
|
||||
|
||||
MenuData menu;
|
||||
create_main_menu(&menu);
|
||||
|
||||
|
|
150
src/menu/charselect.c
Normal file
150
src/menu/charselect.c
Normal file
|
@ -0,0 +1,150 @@
|
|||
/*
|
||||
* This software is licensed under the terms of the MIT-License
|
||||
* See COPYING for further information.
|
||||
* ---
|
||||
* Copyright (C) 2011, Lukas Weber <laochailan@web.de>
|
||||
*/
|
||||
|
||||
#include "menu.h"
|
||||
#include "mainmenu.h"
|
||||
#include "global.h"
|
||||
|
||||
void set_player(void *p) {
|
||||
global.plrtype = (Character) p;
|
||||
}
|
||||
|
||||
void set_shotmode(void *p) {
|
||||
global.plrmode = (ShotMode) p;
|
||||
}
|
||||
|
||||
void create_char_menu(MenuData *m) {
|
||||
create_menu(m);
|
||||
|
||||
add_menu_entry(m, "dialog/marisa|Kirisame Marisa|Black Magician", set_player, (void *)Marisa);
|
||||
add_menu_entry(m, "dialog/youmu|Konpaku Youmu|Half Ghost Girl", set_player, (void *)Youmu);
|
||||
}
|
||||
|
||||
void create_shottype_menu(MenuData *m) {
|
||||
create_menu(m);
|
||||
|
||||
add_menu_entry(m, "Foo Sign|Mirror Sign", set_shotmode, (void *) YoumuOpposite);
|
||||
add_menu_entry(m, "Bar Sign|Haunting Sign", set_shotmode, (void *) YoumuHoming);
|
||||
}
|
||||
|
||||
void draw_char_menu(MenuData *menu, MenuData *mod) {
|
||||
draw_main_menu_bg(menu);
|
||||
draw_text(AL_Right, 220*(1-menu->fade), 30, "Player Select", _fonts.mainmenu);
|
||||
|
||||
glPushMatrix();
|
||||
glColor4f(0,0,0,0.7);
|
||||
glTranslatef(SCREEN_W/4*3, 0, 0);
|
||||
|
||||
glBegin(GL_QUADS);
|
||||
glVertex3f(-150,0, 0);
|
||||
glVertex3f(-150,SCREEN_H, 0);
|
||||
glVertex3f(150,SCREEN_H, 0);
|
||||
glVertex3f(150,0, 0);
|
||||
glEnd();
|
||||
glPopMatrix();
|
||||
|
||||
char buf[128];
|
||||
int i;
|
||||
for(i = 0; i < menu->ecount; i++) {
|
||||
strncpy(buf, menu->entries[i].name, sizeof(buf));
|
||||
|
||||
char *tex = strtok(buf,"|");
|
||||
char *name = strtok(NULL, "|");
|
||||
char *title = strtok(NULL, "|");
|
||||
|
||||
if(!(tex && name && title))
|
||||
continue;
|
||||
|
||||
menu->entries[i].drawdata += 0.08*(1.0*(menu->cursor != i) - menu->entries[i].drawdata);
|
||||
|
||||
glColor4f(1,1,1,1-menu->entries[i].drawdata*2);
|
||||
draw_texture(SCREEN_W/3-200*menu->entries[i].drawdata, 2*SCREEN_H/3, tex);
|
||||
|
||||
glPushMatrix();
|
||||
glTranslatef(SCREEN_W/4*3, SCREEN_H/3, 0);
|
||||
|
||||
glPushMatrix();
|
||||
glTranslatef(0,-300*menu->entries[i].drawdata, 0);
|
||||
glRotatef(180*menu->entries[i].drawdata, 1,0,0);
|
||||
draw_text(AL_Center, 0, 0, name, _fonts.mainmenu);
|
||||
glPopMatrix();
|
||||
|
||||
glColor4f(1,1,1,1-menu->entries[i].drawdata*3);
|
||||
draw_text(AL_Center, 0, 70, title, _fonts.standard);
|
||||
|
||||
strncpy(buf, mod->entries[i].name, sizeof(buf));
|
||||
|
||||
char *mari = strtok(buf, "|");
|
||||
char *youmu = strtok(NULL, "|");
|
||||
|
||||
char *use = menu->entries[menu->cursor].arg == (void *)Marisa ? mari : youmu;
|
||||
|
||||
glColor4f(1,1,1,1);
|
||||
if(mod->cursor == i)
|
||||
glColor4f(0.9,0.6,0.2,1);
|
||||
draw_text(AL_Center, 0, 200+40*i, use, _fonts.standard);
|
||||
|
||||
glPopMatrix();
|
||||
}
|
||||
glColor4f(1,1,1,1);
|
||||
|
||||
fade_out(menu->fade);
|
||||
}
|
||||
|
||||
void char_menu_input(MenuData *menu, MenuData *mod) {
|
||||
SDL_Event event;
|
||||
while(SDL_PollEvent(&event)) {
|
||||
int sym = event.key.keysym.sym;
|
||||
if(event.type == SDL_KEYDOWN) {
|
||||
if(sym == tconfig.intval[KEY_RIGHT]) {
|
||||
menu->cursor++;
|
||||
menu->cursor = abs(menu->cursor % menu->ecount);
|
||||
} else if(sym == tconfig.intval[KEY_LEFT]) {
|
||||
menu->cursor--;
|
||||
menu->cursor = abs(menu->cursor % menu->ecount);
|
||||
} else if(sym == tconfig.intval[KEY_DOWN]) {
|
||||
mod->cursor++;
|
||||
mod->cursor = abs(mod->cursor % mod->ecount);
|
||||
} else if(sym == tconfig.intval[KEY_UP]) {
|
||||
mod->cursor--;
|
||||
mod->cursor = abs(mod->cursor % mod->ecount);
|
||||
} else if((sym == tconfig.intval[KEY_SHOT] || sym == SDLK_RETURN) && menu->entries[menu->cursor].action) {
|
||||
menu->quit = 1;
|
||||
menu->selected = menu->cursor;
|
||||
mod->quit = 1;
|
||||
mod->selected = mod->cursor;
|
||||
mod->fade = 1;
|
||||
} else if(sym == SDLK_ESCAPE && menu->type == MT_Transient) {
|
||||
menu->quit = 1;
|
||||
}
|
||||
|
||||
} else if(event.type == SDL_QUIT) {
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int char_menu_loop(MenuData *menu) {
|
||||
set_ortho();
|
||||
|
||||
MenuData mod;
|
||||
create_shottype_menu(&mod);
|
||||
|
||||
while(menu->quit != 2) {
|
||||
menu_logic(menu);
|
||||
menu_logic(&mod);
|
||||
char_menu_input(menu, &mod);
|
||||
|
||||
draw_char_menu(menu, &mod);
|
||||
SDL_GL_SwapBuffers();
|
||||
SDL_Delay(16);
|
||||
}
|
||||
destroy_menu(menu);
|
||||
|
||||
|
||||
return menu->selected;
|
||||
}
|
18
src/menu/charselect.h
Normal file
18
src/menu/charselect.h
Normal file
|
@ -0,0 +1,18 @@
|
|||
/*
|
||||
* This software is licensed under the terms of the MIT-License
|
||||
* See COPYING for further information.
|
||||
* ---
|
||||
* Copyright (C) 2011, Lukas Weber <laochailan@web.de>
|
||||
*/
|
||||
|
||||
#ifndef CHARSELECT_H
|
||||
#define CHARSELECT_H
|
||||
|
||||
#include "menu.h"
|
||||
|
||||
void create_char_menu(MenuData *m);
|
||||
void draw_char_menu(MenuData *menu);
|
||||
int char_menu_loop(MenuData *menu);
|
||||
|
||||
|
||||
#endif
|
|
@ -23,7 +23,7 @@ void create_difficulty_menu(MenuData *m) {
|
|||
|
||||
}
|
||||
|
||||
void difficulty_menu_loop(MenuData *menu) {
|
||||
int difficulty_menu_loop(MenuData *menu) {
|
||||
set_ortho();
|
||||
while(menu->quit != 2) {
|
||||
menu_logic(menu);
|
||||
|
@ -34,16 +34,20 @@ void difficulty_menu_loop(MenuData *menu) {
|
|||
SDL_Delay(16);
|
||||
}
|
||||
destroy_menu(menu);
|
||||
|
||||
return menu->selected;
|
||||
}
|
||||
|
||||
void draw_difficulty_menu(MenuData *menu) {
|
||||
draw_main_menu_bg(menu);
|
||||
draw_text(AL_Left, 10, 30, "Difficulty", _fonts.mainmenu);
|
||||
draw_text(AL_Right, 210*(1-menu->fade), 30, "Rank Select", _fonts.mainmenu);
|
||||
|
||||
int i;
|
||||
for(i = 0; i < menu->ecount; i++) {
|
||||
menu->entries[i].drawdata += 0.2 * (30*(i == menu->cursor) - menu->entries[i].drawdata);
|
||||
|
||||
glPushMatrix();
|
||||
glTranslatef(SCREEN_W/3 - 30*(i==menu->cursor), 200 + 70*i,0);
|
||||
glTranslatef(SCREEN_W/3 - menu->entries[i].drawdata, 200 + 70*i,0);
|
||||
|
||||
glColor4f(1,1-0.1*i,1-0.1*i,0.7);
|
||||
glBegin(GL_QUADS);
|
||||
|
|
|
@ -12,6 +12,6 @@
|
|||
|
||||
void create_difficulty_menu(MenuData *menu);
|
||||
void draw_difficulty_menu(MenuData *m);
|
||||
void difficulty_menu_loop(MenuData *m);
|
||||
int difficulty_menu_loop(MenuData *m);
|
||||
|
||||
#endif
|
|
@ -57,9 +57,7 @@ void draw_ingame_menu(MenuData *menu) {
|
|||
glPushMatrix();
|
||||
glTranslatef(0, menu->drawdata[0], 0);
|
||||
glScalef(menu->drawdata[1],15,1);
|
||||
glRotatef(menu->drawdata[3],0,0,1);
|
||||
|
||||
|
||||
|
||||
glBegin(GL_QUADS);
|
||||
glVertex3f(-1,-1,0);
|
||||
glVertex3f(-1,1,0);
|
||||
|
@ -74,7 +72,6 @@ void draw_ingame_menu(MenuData *menu) {
|
|||
menu->drawdata[1] += (strlen(menu->entries[menu->cursor].name)*5 - menu->drawdata[1])/10.0;
|
||||
|
||||
menu->drawdata[2] -= menu->drawdata[3]*0.3 + menu->drawdata[2]*0.1;
|
||||
menu->drawdata[3] += menu->drawdata[2]*0.3;
|
||||
|
||||
int i;
|
||||
for(i = 0; i < menu->ecount; i++) {
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#ifndef INGAMEMENU_H
|
||||
#define INGAMEMENU_H
|
||||
|
||||
typedef struct MenuData MenuData;
|
||||
#include "menu.h"
|
||||
|
||||
MenuData *create_ingame_menu();
|
||||
void draw_ingame_menu(MenuData *menu);
|
||||
|
|
|
@ -7,6 +7,10 @@
|
|||
|
||||
#include "mainmenu.h"
|
||||
#include "menu.h"
|
||||
|
||||
#include "difficulty.h"
|
||||
#include "charselect.h"
|
||||
|
||||
#include "global.h"
|
||||
|
||||
void quit_menu(void *arg) {
|
||||
|
@ -16,11 +20,17 @@ void quit_menu(void *arg) {
|
|||
|
||||
void start_story(void *arg) {
|
||||
MenuData m;
|
||||
|
||||
troll:
|
||||
create_difficulty_menu(&m);
|
||||
difficulty_menu_loop(&m);
|
||||
//
|
||||
// create_char_menu(&m);
|
||||
// character_menu_loop(m);
|
||||
if(difficulty_menu_loop(&m) == -1)
|
||||
return;
|
||||
|
||||
create_char_menu(&m);
|
||||
if(char_menu_loop(&m) == -1)
|
||||
goto troll;
|
||||
|
||||
init_player(&global.plr, global.plrtype, global.plrmode);
|
||||
|
||||
stage0_loop();
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#ifndef MAINMENU_H
|
||||
#define MAINMENU_H
|
||||
|
||||
typedef struct MenuData MenuData;
|
||||
#include "menu.h"
|
||||
|
||||
void create_main_menu(MenuData *m);
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@ void add_menu_entry(MenuData *menu, char *name, void (*action)(void *), void *ar
|
|||
strcpy(menu->entries[menu->ecount-1].name, name);
|
||||
menu->entries[menu->ecount-1].action = action;
|
||||
menu->entries[menu->ecount-1].arg = arg;
|
||||
menu->entries[menu->ecount-1].drawdata = 0;
|
||||
}
|
||||
|
||||
void destroy_menu(MenuData *menu) {
|
||||
|
|
|
@ -15,6 +15,7 @@ typedef struct {
|
|||
char *name;
|
||||
void (*action)(void* arg);
|
||||
void *arg;
|
||||
float drawdata;
|
||||
} MenuEntry;
|
||||
|
||||
typedef enum MenuType { // whether to close on selection or not.
|
||||
|
|
26
src/player.c
26
src/player.c
|
@ -87,10 +87,8 @@ void player_draw(Player* plr) {
|
|||
glPopMatrix();
|
||||
}
|
||||
|
||||
void player_logic(Player* plr) {
|
||||
process_enemies(&plr->slaves);
|
||||
|
||||
if(plr->fire && plr->cha == Youmu) {
|
||||
void youmu_shot(Player *plr) {
|
||||
if(plr->fire) {
|
||||
if(!(global.frames % 4)) {
|
||||
create_projectile("youmu", plr->pos + 10 - I*20, NULL, linear, rarg(-20I))->type = PlrProj;
|
||||
create_projectile("youmu", plr->pos - 10 - I*20, NULL, linear, rarg(-20I))->type = PlrProj;
|
||||
|
@ -117,14 +115,28 @@ void player_logic(Player* plr) {
|
|||
create_projectile("hghost", plr->pos, NULL, youmu_homing, rarg(a*cexp(I*rand()), ref))->type = PlrProj;
|
||||
}
|
||||
}
|
||||
|
||||
if(plr->focus < 0 || (plr->focus > 0 && plr->focus < 30))
|
||||
plr->focus++;
|
||||
|
||||
if(plr->shot == YoumuOpposite && plr->slaves == NULL)
|
||||
create_enemy(&plr->slaves, youmu_opposite_draw, youmu_opposite_logic, plr->pos, ENEMY_IMMUNE, plr, 0);
|
||||
}
|
||||
|
||||
void marisa_shot(Player *plr) {
|
||||
}
|
||||
|
||||
void player_logic(Player* plr) {
|
||||
process_enemies(&plr->slaves);
|
||||
|
||||
if(plr->focus < 0 || (plr->focus > 0 && plr->focus < 30))
|
||||
plr->focus++;
|
||||
|
||||
switch(plr->cha) {
|
||||
case Youmu:
|
||||
youmu_shot(plr);
|
||||
case Marisa:
|
||||
marisa_shot(plr);
|
||||
}
|
||||
}
|
||||
|
||||
void plr_bomb(Player *plr) {
|
||||
if(global.frames - plr->recovery >= 0 && plr->bombs > 0) {
|
||||
Enemy *e;
|
||||
|
|
|
@ -25,7 +25,10 @@ typedef enum {
|
|||
|
||||
typedef enum {
|
||||
YoumuOpposite,
|
||||
YoumuHoming
|
||||
YoumuHoming,
|
||||
|
||||
MarisaFoo = YoumuOpposite,
|
||||
MarisaBar = YoumuHoming
|
||||
} ShotMode;
|
||||
|
||||
typedef struct {
|
||||
|
|
|
@ -167,7 +167,7 @@ void process_projectiles(Projectile **projs, char collision) {
|
|||
clr = malloc(sizeof(Color));
|
||||
memcpy(clr, proj->clr, sizeof(Color));
|
||||
}
|
||||
create_projectile_p(Pa, proj->tex, proj->pos, clr, DeathShrink, timeout_linear, rarg(15, -20I*cexp(proj->angle)));
|
||||
create_projectile_p(Pa, proj->tex, proj->pos, clr, DeathShrink, timeout_linear, rarg(10, 5*cexp(proj->angle*I)));
|
||||
}
|
||||
|
||||
|
||||
|
@ -222,7 +222,7 @@ void Shrink(Projectile *p, int t) {
|
|||
glPushMatrix();
|
||||
float s = 2.0-t/p->args[0]*2;
|
||||
glTranslatef(creal(p->pos), cimag(p->pos), 0);
|
||||
glRotatef(p->angle, 0, 0, 1);
|
||||
glRotatef(p->angle*180/M_PI+90, 0, 0, 1);
|
||||
glScalef(s, s, 1);
|
||||
|
||||
_ProjDraw(p, t);
|
||||
|
@ -233,9 +233,9 @@ void DeathShrink(Projectile *p, int t) {
|
|||
glPushMatrix();
|
||||
float s = 2.0-t/p->args[0]*2;
|
||||
glTranslatef(creal(p->pos), cimag(p->pos), 0);
|
||||
glRotatef(p->angle, 0, 0, 1);
|
||||
glRotatef(p->angle*180/M_PI+90, 0, 0, 1);
|
||||
glScalef(s, 1, 1);
|
||||
|
||||
|
||||
_ProjDraw(p, t);
|
||||
glPopMatrix();
|
||||
}
|
||||
|
|
|
@ -10,8 +10,7 @@
|
|||
|
||||
#include <stdarg.h>
|
||||
#include <complex.h>
|
||||
|
||||
typedef struct Texture Texture;
|
||||
#include "resource/texture.h"
|
||||
|
||||
typedef struct {
|
||||
float r;
|
||||
|
|
Loading…
Reference in a new issue