Marisa and difficulty menu

This commit is contained in:
laochailan 2011-06-24 12:35:03 +02:00
parent 924091b7be
commit bd44c8b570
24 changed files with 1544 additions and 136 deletions

View file

@ -13,3 +13,6 @@ key_focus = shift
key_shot = z
# key_shot = y # if you are qwertz-fag
key_bomb = x
# if your favourite keysym isn't supported, look it up in SDL/SDL_keysym.h
# key_bomb = K42 # Syntax: K${value} where value is the value defined in the header.

BIN
gfx/dialog/marisa.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 112 KiB

1373
gfx/dialog/marisa.svg Normal file

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 160 KiB

View file

@ -744,7 +744,7 @@
inkscape:pageshadow="2"
inkscape:zoom="0.35"
inkscape:cx="481.4612"
inkscape:cy="705.47182"
inkscape:cy="988.31453"
inkscape:document-units="px"
inkscape:current-layer="layer2"
showgrid="false"
@ -1180,5 +1180,12 @@
inkscape:connector-curvature="0"
sodipodi:nodetypes="ccc"
transform="matrix(2.136847,0,0,2.2696295,-841.94607,-901.52374)" />
<path
style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 422.24376,301.7432 c 0,0 -14.33713,12.08859 -12.6269,19.69798 1.04485,4.64891 12.12183,7.57614 12.12183,7.57614"
id="path5654"
inkscape:connector-curvature="0"
transform="translate(232.05519,39.629467)"
sodipodi:nodetypes="csc" />
</g>
</svg>

Before

Width:  |  Height:  |  Size: 544 KiB

After

Width:  |  Height:  |  Size: 544 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

View file

@ -1,74 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="573.80933"
height="494.6991"
id="svg2"
version="1.1"
inkscape:version="0.48.1 r9760"
sodipodi:docname="gate_pi.svg"
inkscape:export-filename="/home/laochailan/src/taisei/gfx/gate_pi.png"
inkscape:export-xdpi="90"
inkscape:export-ydpi="90">
<defs
id="defs4" />
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="0.98994949"
inkscape:cx="303.54778"
inkscape:cy="184.05854"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="false"
fit-margin-top="0"
fit-margin-left="0"
fit-margin-right="0"
fit-margin-bottom="0"
inkscape:window-width="1920"
inkscape:window-height="1039"
inkscape:window-x="0"
inkscape:window-y="-2"
inkscape:window-maximized="1" />
<metadata
id="metadata7">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Ebene 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(-46.452218,-181.31553)">
<text
xml:space="preserve"
style="font-size:674.61383057px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Mathematical Pi LT Std;-inkscape-font-specification:Mathematical Pi LT Std"
x="68.603226"
y="669.9538"
id="text3012"
sodipodi:linespacing="125%"><tspan
sodipodi:role="line"
id="tspan3014"
x="68.603226"
y="669.9538">Π</tspan></text>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 2.3 KiB

View file

@ -30,6 +30,7 @@ set(SRCs
menu/menu.c
menu/mainmenu.c
menu/ingamemenu.c
menu/difficulty.c
stages/stage0.c
resource/texture.c
resource/animation.c

View file

@ -39,7 +39,7 @@ void spell_opening(Boss *b, int time) {
y = 20;
}
draw_text(AlRight, VIEWPORT_W, y, b->current->name, _fonts.standard);
draw_text(AL_Right, VIEWPORT_W, y, b->current->name, _fonts.standard);
}
void draw_boss(Boss *boss) {
@ -48,12 +48,12 @@ void draw_boss(Boss *boss) {
if(boss->current && (boss->current->type == AT_Spellcard || boss->current->type == AT_SurvivalSpell))
spell_opening(boss, global.frames - boss->current->starttime);
draw_text(AlLeft, 10, 20, boss->name, _fonts.standard);
draw_text(AL_Left, 10, 20, boss->name, _fonts.standard);
if(boss->current) {
char buf[16];
snprintf(buf, 16, "%.2f", (boss->current->timeout - global.frames + boss->current->starttime)/(float)FPS);
draw_text(AlCenter, VIEWPORT_W - 20, 10, buf, _fonts.standard);
draw_text(AL_Center, VIEWPORT_W - 20, 10, buf, _fonts.standard);
}
glPushMatrix();

View file

@ -28,20 +28,27 @@
"key_shot" { yylval = KEY_SHOT; return tKEY_SHOT; }
"key_bomb" { yylval = KEY_BOMB; return tKEY_BOMB; }
"shift" { yylval = SDLK_LSHIFT; return SKEY; }
"ctrl" { yylval = SDLK_LCTRL; return SKEY; }
"shift" { yylval = SDLK_LSHIFT; return SKEY; }
"ctrl" { yylval = SDLK_LCTRL; return SKEY; }
"return" { yylval = SDLK_RETURN; return SKEY; }
"alt" { yylval = SDLK_LALT; return SKEY; }
"alt" { yylval = SDLK_LALT; return SKEY; }
"up" { yylval = SDLK_UP; return SKEY; }
"down" { yylval = SDLK_DOWN; return SKEY; }
"right" { yylval = SDLK_RIGHT; return SKEY; }
"left" { yylval = SDLK_LEFT; return SKEY; }
"down" { yylval = SDLK_DOWN; return SKEY; }
"right" { yylval = SDLK_RIGHT; return SKEY; }
"left" { yylval = SDLK_LEFT; return SKEY; }
[0-9]+ { yylval = atoi(yytext); return NUMBER; }
[a-zA-Z] { yylval = yytext[0]; return CHAR; }
ä { yylval = SDLK_WORLD_68; return CHAR; }
ü { yylval = SDLK_WORLD_92; return CHAR; }
ö { yylval = SDLK_WORLD_86; return CHAR; }
ß { yylval = SDLK_WORLD_63; return CHAR; }
K[0-9]+ { yylval = atoi(yytext + 1); return CHAR; }
\n return LB;
[ \t] ;

View file

@ -100,7 +100,7 @@ void draw_dialog(Dialog *dialog) {
if(dialog->messages[dialog->pos].side == Right)
glColor3f(0.6,0.6,1);
draw_text(AlCenter, VIEWPORT_W/2, VIEWPORT_H-110, dialog->messages[dialog->pos].msg, _fonts.standard);
draw_text(AL_Center, VIEWPORT_W/2, VIEWPORT_H-110, dialog->messages[dialog->pos].msg, _fonts.standard);
glColor4f(1,1,1,1);
glPopMatrix();

View file

@ -15,7 +15,7 @@
#include <stdarg.h>
struct Enemy;
typedef struct Enemy Enemy;
typedef void (*EnemyLogicRule)(struct Enemy*, int t);
typedef EnemyLogicRule EnemyDrawRule;
@ -23,9 +23,9 @@ enum {
ENEMY_IMMUNE = -9000
};
typedef struct Enemy {
struct Enemy *next;
struct Enemy *prev;
struct Enemy {
Enemy *next;
Enemy *prev;
complex pos;
complex pos0;
@ -42,7 +42,7 @@ typedef struct Enemy {
void *parent;
complex args[RULE_ARGC];
} Enemy;
};
#define create_enemyg(drule, lrule, pos, hp, par, args) (create_enemy(&global.enemies, drule, lrule, pos, hp, par, args))
void create_enemy(Enemy **enemies, EnemyDrawRule draw_rule, EnemyLogicRule logic_rule,

View file

@ -48,4 +48,12 @@ void calc_fps(FPSCounter *fps) {
} else {
fps->fps++;
}
}
void set_ortho() {
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0, SCREEN_W, SCREEN_H, 0, -10, 10);
glMatrixMode(GL_MODELVIEW);
glDisable(GL_DEPTH_TEST);
}

View file

@ -101,6 +101,7 @@ typedef struct {
int points;
FPSCounter fps;
} Global;
extern Global global;
@ -111,4 +112,6 @@ void game_over();
void frame_rate();
void set_ortho();
#endif

View file

@ -11,7 +11,7 @@
#include <complex.h>
struct Item;
typedef struct Item Item;
typedef enum {
Power,
@ -21,9 +21,9 @@ typedef enum {
Bomb
} Type;
typedef struct Item{
struct Item *next;
struct Item *prev;
struct Item{
Item *next;
Item *prev;
int birthtime;
complex pos;
@ -33,7 +33,7 @@ typedef struct Item{
Type type;
complex v;
} Item;
};
Item *create_item(complex pos, complex v, Type type);
void delete_item(Item *item);

67
src/menu/difficulty.c Normal file
View file

@ -0,0 +1,67 @@
/*
* 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 "difficulty.h"
#include "mainmenu.h"
#include "global.h"
void set_difficulty(void *d) {
global.diff = (Difficulty) d;
}
void create_difficulty_menu(MenuData *m) {
create_menu(m);
add_menu_entry(m, "Easy\nfor fearful fairies", set_difficulty, (void *)D_Easy);
add_menu_entry(m, "Normal\nfor confident kappa", set_difficulty, (void *)D_Normal);
add_menu_entry(m, "Hard\nfor omnipotent oni", set_difficulty, (void *)D_Hard);
add_menu_entry(m, "Lunatic\nfor gods", set_difficulty, (void *)D_Lunatic);
}
void difficulty_menu_loop(MenuData *menu) {
set_ortho();
while(menu->quit != 2) {
menu_logic(menu);
menu_input(menu);
draw_difficulty_menu(menu);
SDL_GL_SwapBuffers();
SDL_Delay(16);
}
destroy_menu(menu);
}
void draw_difficulty_menu(MenuData *menu) {
draw_main_menu_bg(menu);
draw_text(AL_Left, 10, 30, "Difficulty", _fonts.mainmenu);
int i;
for(i = 0; i < menu->ecount; i++) {
glPushMatrix();
glTranslatef(SCREEN_W/3 - 30*(i==menu->cursor), 200 + 70*i,0);
glColor4f(1,1-0.1*i,1-0.1*i,0.7);
glBegin(GL_QUADS);
glVertex3f(-10,-30,0);
glVertex3f(-10,30,0);
glVertex3f(300,30,0);
glVertex3f(300,-30,0);
glEnd();
glColor4f(0,0,0,1);
if(i == menu->cursor)
glColor3f(0.2,0,0.1);
draw_text(AL_Left, 0, -15, menu->entries[i].name, _fonts.standard);
glColor3f(1,1,1);
glPopMatrix();
}
fade_out(menu->fade);
}

17
src/menu/difficulty.h Normal file
View file

@ -0,0 +1,17 @@
/*
* 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 DIFFICULTY_H
#define DIFFICULTY_H
#include "menu.h"
void create_difficulty_menu(MenuData *menu);
void draw_difficulty_menu(MenuData *m);
void difficulty_menu_loop(MenuData *m);
#endif

View file

@ -21,7 +21,7 @@ MenuData *create_ingame_menu() {
create_menu(m);
add_menu_entry(m, "Return to Game", return_to_game, NULL);
add_menu_entry(m, "Return to Title", return_to_title, NULL);
add_menu_entry(m, "Give Up and Retry", return_to_title, NULL);
add_menu_entry(m, "Give Up and Retry", NULL, NULL);
return m;
}
@ -83,7 +83,7 @@ void draw_ingame_menu(MenuData *menu) {
s = 0.3 + 0.2*sin(menu->frames/7.0);
glColor4f(1-s,1-s,1, 1.0 - menu->fade);
draw_text(AlCenter, 0, i*35, menu->entries[i].name, _fonts.standard);
draw_text(AL_Center, 0, i*35, menu->entries[i].name, _fonts.standard);
}
glColor4f(1,1,1,1);

View file

@ -15,9 +15,9 @@ void quit_menu(void *arg) {
}
void start_story(void *arg) {
// MenuData m;
// create_difficulty_menu(&m);
// difficulty_menu_loop(m);
MenuData m;
create_difficulty_menu(&m);
difficulty_menu_loop(&m);
//
// create_char_menu(&m);
// character_menu_loop(m);
@ -37,30 +37,25 @@ void create_main_menu(MenuData *m) {
m->type = MT_Persistent;
add_menu_entry(m, "Start Story", start_story, NULL);
add_menu_entry(m, "Start Extra", start_extra, NULL);
add_menu_entry(m, "Options", start_options, NULL);
add_menu_entry(m, "Start Extra", NULL, NULL);
add_menu_entry(m, "Options", NULL, NULL);
add_menu_entry(m, "Quit", quit_menu, m);
}
void draw_main_menu(MenuData *menu) {
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0, SCREEN_W, SCREEN_H, 0, -10, 10);
glMatrixMode(GL_MODELVIEW);
glDisable(GL_DEPTH_TEST);
void draw_main_menu_bg(MenuData* menu) {
draw_texture(SCREEN_W/2, SCREEN_H/2, "mainmenubgbg");
glColor4f(1,1,1,0.6 + 0.1*sin(menu->frames/100.0));
draw_texture(SCREEN_W/2, SCREEN_H/2, "mainmenubg");
glColor4f(1,1,1,1);
}
void draw_main_menu(MenuData *menu) {
draw_main_menu_bg(menu);
glColor4f(1,1,1,0.7);
draw_texture(SCREEN_W/2+40, SCREEN_H/2, "gate");
glColor4f(1,1,1,0.2 + 0.2*sin(menu->frames/70.0));
draw_texture(SCREEN_W/2+40, SCREEN_H/2, "gate_pi");
glPushMatrix();
glTranslatef(0, SCREEN_H-200, 0);
@ -80,8 +75,12 @@ void draw_main_menu(MenuData *menu) {
for(i = 0; i < menu->ecount; i++) {
float s = 5*sin(menu->frames/80.0 + 20*i);
glColor4f(1,1,1,0.7 + 0.1*sin(menu->frames/70.0));
draw_text(AlLeft, 50 + s, 35*i, menu->entries[i].name, _fonts.mainmenu);
float grey = 1;
if(menu->entries[i].action == NULL)
grey = 0.5;
glColor4f(grey,grey,grey,0.7);
draw_text(AL_Left, 50 + s, 35*i, menu->entries[i].name, _fonts.mainmenu);
}
glPopMatrix();
@ -94,6 +93,7 @@ void draw_main_menu(MenuData *menu) {
}
void main_menu_loop(MenuData *menu) {
set_ortho();
while(menu->quit != 2) {
menu_logic(menu);
menu_input(menu);

View file

@ -12,6 +12,8 @@ typedef struct MenuData MenuData;
void create_main_menu(MenuData *m);
void draw_main_menu_bg(MenuData *m);
void draw_main_menu(MenuData *m);
void main_menu_loop(MenuData *m);

View file

@ -43,7 +43,7 @@ void menu_input(MenuData *menu) {
} else if(sym == tconfig.intval[KEY_UP] && menu->cursor > 0) {
menu->drawdata[3] = 10;
menu->cursor--;
} else if(sym == tconfig.intval[KEY_SHOT] || sym == SDLK_RETURN) {
} else if((sym == tconfig.intval[KEY_SHOT] || sym == SDLK_RETURN) && menu->entries[menu->cursor].action) {
menu->quit = 1;
menu->selected = menu->cursor;
} else if(sym == SDLK_ESCAPE && menu->type == MT_Transient) {
@ -70,10 +70,8 @@ void menu_logic(MenuData *menu) {
if(menu->quit == 1 && menu->fade >= 1.0) {
menu->quit = menu->type == MT_Transient ? 2 : 0;
if(menu->selected != -1) {
if(menu->selected != -1 && menu->entries[menu->selected].action != NULL)
menu->entries[menu->selected].action(menu->entries[menu->selected].arg);
// menu->selected = -1;
}
}
}

View file

@ -35,20 +35,20 @@ void draw_text(Alignment align, float x, float y, const char *text, TTF_Font *fo
strcpy(buf, text);
if((nl = strchr(buf, '\n')) != NULL && strlen(nl) > 1) {
draw_text(AlCenter, x, y + 20, nl+1, font);
draw_text(align, x, y + 20, nl+1, font);
*nl = '\0';
}
Texture *tex = load_text(buf, font);
switch(align) {
case AlCenter:
case AL_Center:
draw_texture_p(x, y, tex);
break;
case AlLeft:
case AL_Left:
draw_texture_p(x + tex->w/2.0, y, tex);
break;
case AlRight:
case AL_Right:
draw_texture_p(x - tex->w/2.0, y, tex);
break;
}

View file

@ -13,9 +13,9 @@
#include "texture.h"
typedef enum {
AlCenter,
AlLeft,
AlRight
AL_Center,
AL_Left,
AL_Right
} Alignment;
Texture *load_text(const char *text, TTF_Font *font);

View file

@ -101,25 +101,21 @@ void draw_hud() {
glColor3f(1,1,1);
sprintf(buf, "%.2f", global.plr.power);
draw_text(AlCenter, 10, 236, buf, _fonts.standard);
draw_text(AL_Center, 10, 236, buf, _fonts.standard);
sprintf(buf, "%i", global.points);
draw_text(AlCenter, 13, 49, buf, _fonts.standard);
draw_text(AL_Center, 13, 49, buf, _fonts.standard);
glPopMatrix();
sprintf(buf, "%i fps", global.fps.show_fps);
draw_text(AlLeft, SCREEN_W, SCREEN_H-20, buf, _fonts.standard);
draw_text(AL_Left, SCREEN_W, SCREEN_H-20, buf, _fonts.standard);
}
void stage_draw() {
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0, SCREEN_W, SCREEN_H, 0, -10, 10);
glMatrixMode(GL_MODELVIEW);
glDisable(GL_DEPTH_TEST);
set_ortho();
glPushMatrix();
glTranslatef(VIEWPORT_X,VIEWPORT_Y,0);

View file

@ -29,7 +29,7 @@ void simpleEnemy(Enemy *e, int t) {
}
Dialog *test_dialog() {
Dialog *d = create_dialog("dialog/youmu", "dialog/youmu");
Dialog *d = create_dialog("dialog/marisa", "dialog/youmu");
dadd_msg(d, Left, "Hello");
dadd_msg(d, Right, "Hello you");