power items.
Sarrg was friendly enough to provide us some power item support. Looks like in the orignal in some way.
This commit is contained in:
parent
05fb40b7f4
commit
a10f5eea93
18 changed files with 766 additions and 10 deletions
|
@ -4,5 +4,15 @@ cmake_minimum_required(VERSION 2.6)
|
||||||
|
|
||||||
add_subdirectory(src)
|
add_subdirectory(src)
|
||||||
|
|
||||||
|
set(CMAKE_CFLAGS="--std=c99")
|
||||||
|
|
||||||
set(DATA_DIR "share/taisei")
|
set(DATA_DIR "share/taisei")
|
||||||
install(DIRECTORY gfx DESTINATION ${DATA_DIR})
|
install(DIRECTORY gfx DESTINATION ${DATA_DIR})
|
||||||
|
# uninstall target
|
||||||
|
configure_file(
|
||||||
|
"${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
|
||||||
|
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
|
||||||
|
IMMEDIATE @ONLY)
|
||||||
|
|
||||||
|
add_custom_target(uninstall
|
||||||
|
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
|
10
CMakeLists.txt.orig
Normal file
10
CMakeLists.txt.orig
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
project(taisei)
|
||||||
|
|
||||||
|
cmake_minimum_required(VERSION 2.6)
|
||||||
|
|
||||||
|
add_subdirectory(src)
|
||||||
|
|
||||||
|
set(CMAKE_CFLAGS="--std=c99")
|
||||||
|
|
||||||
|
set(DATA_DIR "share/taisei")
|
||||||
|
install(DIRECTORY gfx DESTINATION ${DATA_DIR})
|
21
cmake_uninstall.cmake.in
Normal file
21
cmake_uninstall.cmake.in
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
if (NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
|
||||||
|
message(FATAL_ERROR "Cannot find install manifest: \"@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt\"")
|
||||||
|
endif(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
|
||||||
|
|
||||||
|
file(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files)
|
||||||
|
string(REGEX REPLACE "\n" ";" files "${files}")
|
||||||
|
foreach (file ${files})
|
||||||
|
message(STATUS "Uninstalling \"$ENV{DESTDIR}${file}\"")
|
||||||
|
if (EXISTS "$ENV{DESTDIR}${file}")
|
||||||
|
execute_process(
|
||||||
|
COMMAND @CMAKE_COMMAND@ -E remove "$ENV{DESTDIR}${file}"
|
||||||
|
OUTPUT_VARIABLE rm_out
|
||||||
|
RESULT_VARIABLE rm_retval
|
||||||
|
)
|
||||||
|
if(NOT ${rm_retval} EQUAL 0)
|
||||||
|
message(FATAL_ERROR "Problem when removing \"$ENV{DESTDIR}${file}\"")
|
||||||
|
endif (NOT ${rm_retval} EQUAL 0)
|
||||||
|
else (EXISTS "$ENV{DESTDIR}${file}")
|
||||||
|
message(STATUS "File \"$ENV{DESTDIR}${file}\" does not exist.")
|
||||||
|
endif (EXISTS "$ENV{DESTDIR}${file}")
|
||||||
|
endforeach(file)
|
BIN
gfx/power.png
Normal file
BIN
gfx/power.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 609 B |
132
gfx/power.svg
Normal file
132
gfx/power.svg
Normal file
|
@ -0,0 +1,132 @@
|
||||||
|
<?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:xlink="http://www.w3.org/1999/xlink"
|
||||||
|
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||||
|
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||||
|
width="232.38969"
|
||||||
|
height="232.38969"
|
||||||
|
id="svg2"
|
||||||
|
version="1.1"
|
||||||
|
inkscape:version="0.48.1 r9760"
|
||||||
|
sodipodi:docname="power.svg"
|
||||||
|
inkscape:export-filename="/home/laochailan/power.png"
|
||||||
|
inkscape:export-xdpi="6.1964884"
|
||||||
|
inkscape:export-ydpi="6.1964884">
|
||||||
|
<defs
|
||||||
|
id="defs4">
|
||||||
|
<linearGradient
|
||||||
|
id="linearGradient3795">
|
||||||
|
<stop
|
||||||
|
style="stop-color:#ffffff;stop-opacity:1;"
|
||||||
|
offset="0"
|
||||||
|
id="stop3797" />
|
||||||
|
<stop
|
||||||
|
style="stop-color:#ff8a65;stop-opacity:1;"
|
||||||
|
offset="1"
|
||||||
|
id="stop3799" />
|
||||||
|
</linearGradient>
|
||||||
|
<linearGradient
|
||||||
|
id="linearGradient3763">
|
||||||
|
<stop
|
||||||
|
style="stop-color:#800000;stop-opacity:1;"
|
||||||
|
offset="0"
|
||||||
|
id="stop3765" />
|
||||||
|
<stop
|
||||||
|
style="stop-color:#ff4800;stop-opacity:1;"
|
||||||
|
offset="1"
|
||||||
|
id="stop3767" />
|
||||||
|
</linearGradient>
|
||||||
|
<linearGradient
|
||||||
|
inkscape:collect="always"
|
||||||
|
xlink:href="#linearGradient3763"
|
||||||
|
id="linearGradient3769"
|
||||||
|
x1="98.428574"
|
||||||
|
y1="251.6479"
|
||||||
|
x2="323"
|
||||||
|
y2="251.6479"
|
||||||
|
gradientUnits="userSpaceOnUse"
|
||||||
|
gradientTransform="matrix(0.89238176,0,0,0.89238176,-439.68548,26.182169)" />
|
||||||
|
<radialGradient
|
||||||
|
inkscape:collect="always"
|
||||||
|
xlink:href="#linearGradient3795"
|
||||||
|
id="radialGradient3801"
|
||||||
|
cx="250.74817"
|
||||||
|
cy="251.64787"
|
||||||
|
fx="250.74817"
|
||||||
|
fy="251.64787"
|
||||||
|
r="73.50135"
|
||||||
|
gradientTransform="matrix(1,0,0,1.1626409,0,-40.928237)"
|
||||||
|
gradientUnits="userSpaceOnUse" />
|
||||||
|
</defs>
|
||||||
|
<sodipodi:namedview
|
||||||
|
id="base"
|
||||||
|
pagecolor="#606060"
|
||||||
|
bordercolor="#666666"
|
||||||
|
borderopacity="1.0"
|
||||||
|
inkscape:pageopacity="0"
|
||||||
|
inkscape:pageshadow="2"
|
||||||
|
inkscape:zoom="0.35"
|
||||||
|
inkscape:cx="-99.396394"
|
||||||
|
inkscape:cy="60.585693"
|
||||||
|
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(-134.55331,-135.45305)">
|
||||||
|
<rect
|
||||||
|
transform="matrix(0,-1,1,0,0,0)"
|
||||||
|
ry="22.554321"
|
||||||
|
y="134.55331"
|
||||||
|
x="-367.84274"
|
||||||
|
height="232.38969"
|
||||||
|
width="232.38969"
|
||||||
|
id="rect3813"
|
||||||
|
style="fill:#970d00;fill-opacity:1;stroke:none" />
|
||||||
|
<rect
|
||||||
|
style="fill:url(#linearGradient3769);fill-opacity:1;stroke:#ffffff;stroke-width:19.52022361999999944;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
|
||||||
|
id="rect2985"
|
||||||
|
width="195.04915"
|
||||||
|
height="195.04915"
|
||||||
|
x="-349.17249"
|
||||||
|
y="153.22359"
|
||||||
|
ry="18.930275"
|
||||||
|
transform="matrix(0,-1,1,0,0,0)" />
|
||||||
|
<path
|
||||||
|
id="path3847"
|
||||||
|
style="fill:#ffffff;fill-opacity:1;stroke:none"
|
||||||
|
d="m 229.75045,202.95593 c 11.5343,-8.31412 40.88286,-0.7841 42.72511,12.14286 1.83113,12.84898 -24.31631,26.22078 -37.79529,20.71428 -11.4988,-4.69755 -14.71028,-25.80721 -4.92982,-32.85714 z m -44.3684,-8.57142 c -1.44723,30.77936 0.71692,92.49464 2.4649,127.14285 0.59399,11.77379 33.83542,15.3775 40.26021,5 10.81049,-17.46139 5.89667,-65.67221 8.21638,-65 0,0 88.11291,13.93991 79.69879,-55.71428 -4.62903,-38.32027 -128.83009,-49.92742 -130.64028,-11.42857 z"
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
sodipodi:nodetypes="ssssssscss" />
|
||||||
|
</g>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 4.3 KiB |
|
@ -7,6 +7,7 @@ set(SRCs
|
||||||
projectile.c
|
projectile.c
|
||||||
animation.c
|
animation.c
|
||||||
fairy.c
|
fairy.c
|
||||||
|
poweritem.c
|
||||||
list.c
|
list.c
|
||||||
font.c
|
font.c
|
||||||
stages/stage0.c)
|
stages/stage0.c)
|
||||||
|
|
|
@ -28,6 +28,7 @@ void create_fairy(int x, int y, int v, int angle, int hp, FairyRule rule) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void delete_fairy(Fairy *fairy) {
|
void delete_fairy(Fairy *fairy) {
|
||||||
|
if(global.plr.power < 6) create_poweritem(fairy->x, fairy->y,0.03,0,simpleItem);
|
||||||
delete_element((void **)&global.fairies, fairy);
|
delete_element((void **)&global.fairies, fairy);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,6 @@ typedef void (*FairyRule)(struct Fairy*);
|
||||||
typedef struct Fairy {
|
typedef struct Fairy {
|
||||||
struct Fairy *next;
|
struct Fairy *next;
|
||||||
struct Fairy *prev;
|
struct Fairy *prev;
|
||||||
|
|
||||||
long birthtime;
|
long birthtime;
|
||||||
char hp;
|
char hp;
|
||||||
|
|
||||||
|
|
|
@ -11,12 +11,13 @@
|
||||||
|
|
||||||
Global global;
|
Global global;
|
||||||
|
|
||||||
void init_textures() {
|
void init_textures() { // TODO: dynamic loader.
|
||||||
load_texture(FILE_PREFIX "gfx/wasser.png", &global.textures.water);
|
load_texture(FILE_PREFIX "gfx/wasser.png", &global.textures.water);
|
||||||
load_texture(FILE_PREFIX "gfx/stage1/border.png", &global.textures.border);
|
load_texture(FILE_PREFIX "gfx/stage1/border.png", &global.textures.border);
|
||||||
load_texture(FILE_PREFIX "gfx/hud.png", &global.textures.hud);
|
load_texture(FILE_PREFIX "gfx/hud.png", &global.textures.hud);
|
||||||
load_texture(FILE_PREFIX "gfx/fairy_circle.png", &global.textures.fairy_circle);
|
load_texture(FILE_PREFIX "gfx/fairy_circle.png", &global.textures.fairy_circle);
|
||||||
load_texture(FILE_PREFIX "gfx/focus.png", &global.textures.focus);
|
load_texture(FILE_PREFIX "gfx/focus.png", &global.textures.focus);
|
||||||
|
load_texture(FILE_PREFIX "gfx/power.png", &global.textures.poweritems);
|
||||||
|
|
||||||
init_animation(&global.textures.fairy, 2, 2, 15, FILE_PREFIX "gfx/fairy.png");
|
init_animation(&global.textures.fairy, 2, 2, 15, FILE_PREFIX "gfx/fairy.png");
|
||||||
}
|
}
|
||||||
|
@ -31,6 +32,7 @@ void init_global() {
|
||||||
|
|
||||||
global.projs = NULL;
|
global.projs = NULL;
|
||||||
global.fairies = NULL;
|
global.fairies = NULL;
|
||||||
|
global.poweritems = NULL;
|
||||||
|
|
||||||
global.frames = 0;
|
global.frames = 0;
|
||||||
global.game_over = 0;
|
global.game_over = 0;
|
||||||
|
@ -43,12 +45,11 @@ void init_global() {
|
||||||
|
|
||||||
void game_over() {
|
void game_over() {
|
||||||
global.game_over = 1;
|
global.game_over = 1;
|
||||||
printf("Game Over!");
|
printf("Game Over!\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void frame_rate() {
|
void frame_rate() {
|
||||||
int t = global.lasttime + 1000/FPS - SDL_GetTicks();
|
int t = global.lasttime + 1000/FPS - SDL_GetTicks();
|
||||||
global.time = SDL_GetTicks();
|
|
||||||
if(t > 0)
|
if(t > 0)
|
||||||
SDL_Delay(t);
|
SDL_Delay(t);
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* This software is licensed under the terms of the MIT-License
|
* This software is licensed under the terms of the MIT-License
|
||||||
* See COPYING for further information.
|
* See COPYING for further information.
|
||||||
* ---
|
* ---
|
||||||
* Copyright (C) 2011, Lukas Weber <laochailan@web.de>
|
* Copyright (C) 2011, Lukas Weber <laochailan@web.de>
|
||||||
*/
|
*/
|
||||||
|
@ -12,6 +12,7 @@
|
||||||
#include "player.h"
|
#include "player.h"
|
||||||
#include "projectile.h"
|
#include "projectile.h"
|
||||||
#include "fairy.h"
|
#include "fairy.h"
|
||||||
|
#include "poweritem.h"
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
RESX = 800,
|
RESX = 800,
|
||||||
|
@ -34,6 +35,7 @@ typedef struct {
|
||||||
Player plr;
|
Player plr;
|
||||||
Projectile *projs;
|
Projectile *projs;
|
||||||
Fairy *fairies;
|
Fairy *fairies;
|
||||||
|
Poweritem *poweritems;
|
||||||
|
|
||||||
int frames;
|
int frames;
|
||||||
|
|
||||||
|
@ -45,13 +47,13 @@ typedef struct {
|
||||||
Texture border;
|
Texture border;
|
||||||
Texture fairy_circle;
|
Texture fairy_circle;
|
||||||
Texture focus;
|
Texture focus;
|
||||||
|
Texture poweritems;
|
||||||
|
|
||||||
Animation fairy;
|
Animation fairy;
|
||||||
} textures;
|
} textures;
|
||||||
|
|
||||||
int game_over;
|
int game_over;
|
||||||
|
|
||||||
int time;
|
|
||||||
|
|
||||||
int fpstime; // frame counter
|
int fpstime; // frame counter
|
||||||
int fps;
|
int fps;
|
||||||
|
|
68
src/global.h.orig
Normal file
68
src/global.h.orig
Normal file
|
@ -0,0 +1,68 @@
|
||||||
|
/*
|
||||||
|
* 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 GLOBAL_H
|
||||||
|
#define GLOBAL_H
|
||||||
|
|
||||||
|
#include <SDL/SDL.h>
|
||||||
|
#include "player.h"
|
||||||
|
#include "projectile.h"
|
||||||
|
#include "fairy.h"
|
||||||
|
|
||||||
|
enum {
|
||||||
|
RESX = 800,
|
||||||
|
RESY = 600,
|
||||||
|
|
||||||
|
SCREEN_W = 800,
|
||||||
|
SCREEN_H = 600,
|
||||||
|
|
||||||
|
VIEWPORT_X = 40,
|
||||||
|
VIEWPORT_Y = 20,
|
||||||
|
VIEWPORT_W = 480,
|
||||||
|
VIEWPORT_H = 560,
|
||||||
|
|
||||||
|
FPS = 60
|
||||||
|
};
|
||||||
|
|
||||||
|
#define FILE_PREFIX PREFIX "/share/taisei/"
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
Player plr;
|
||||||
|
Projectile *projs;
|
||||||
|
Fairy *fairies;
|
||||||
|
|
||||||
|
int frames;
|
||||||
|
|
||||||
|
struct {
|
||||||
|
Texture hud;
|
||||||
|
|
||||||
|
Texture projwave;
|
||||||
|
Texture water;
|
||||||
|
Texture border;
|
||||||
|
Texture fairy_circle;
|
||||||
|
Texture focus;
|
||||||
|
|
||||||
|
Animation fairy;
|
||||||
|
} textures;
|
||||||
|
|
||||||
|
int game_over;
|
||||||
|
|
||||||
|
|
||||||
|
int fpstime; // frame counter
|
||||||
|
int fps;
|
||||||
|
|
||||||
|
int lasttime;
|
||||||
|
} Global;
|
||||||
|
|
||||||
|
extern Global global;
|
||||||
|
|
||||||
|
void init_global();
|
||||||
|
void game_over();
|
||||||
|
|
||||||
|
void frame_rate();
|
||||||
|
|
||||||
|
#endif
|
73
src/global.h.rej
Normal file
73
src/global.h.rej
Normal file
|
@ -0,0 +1,73 @@
|
||||||
|
--- src/global.h
|
||||||
|
+++ src/global.h
|
||||||
|
@@ -8,54 +8,58 @@
|
||||||
|
#ifndef GLOBAL_H
|
||||||
|
#define GLOBAL_H
|
||||||
|
|
||||||
|
+#include <SDL/SDL_opengl.h>
|
||||||
|
#include <SDL/SDL.h>
|
||||||
|
#include "player.h"
|
||||||
|
#include "projectile.h"
|
||||||
|
#include "fairy.h"
|
||||||
|
+#include "poweritem.h"
|
||||||
|
|
||||||
|
enum {
|
||||||
|
RESX = 800,
|
||||||
|
RESY = 600,
|
||||||
|
-
|
||||||
|
+
|
||||||
|
SCREEN_W = 800,
|
||||||
|
SCREEN_H = 600,
|
||||||
|
-
|
||||||
|
+
|
||||||
|
VIEWPORT_X = 40,
|
||||||
|
VIEWPORT_Y = 20,
|
||||||
|
VIEWPORT_W = 480,
|
||||||
|
VIEWPORT_H = 560,
|
||||||
|
-
|
||||||
|
+
|
||||||
|
FPS = 60
|
||||||
|
};
|
||||||
|
|
||||||
|
#define FILE_PREFIX PREFIX "/share/taisei/"
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
- Player plr;
|
||||||
|
+ Player plr;
|
||||||
|
Projectile *projs;
|
||||||
|
Fairy *fairies;
|
||||||
|
-
|
||||||
|
+ Poweritem *poweritems;
|
||||||
|
+
|
||||||
|
int frames;
|
||||||
|
-
|
||||||
|
+
|
||||||
|
struct {
|
||||||
|
Texture hud;
|
||||||
|
-
|
||||||
|
+
|
||||||
|
Texture projwave;
|
||||||
|
Texture water;
|
||||||
|
Texture border;
|
||||||
|
Texture fairy_circle;
|
||||||
|
Texture focus;
|
||||||
|
-
|
||||||
|
+ Texture poweritems;
|
||||||
|
+
|
||||||
|
Animation fairy;
|
||||||
|
} textures;
|
||||||
|
-
|
||||||
|
+
|
||||||
|
int game_over;
|
||||||
|
-
|
||||||
|
+
|
||||||
|
int time;
|
||||||
|
-
|
||||||
|
+
|
||||||
|
int fpstime; // frame counter
|
||||||
|
int fps;
|
||||||
|
-
|
||||||
|
+
|
||||||
|
int lasttime;
|
||||||
|
} Global;
|
||||||
|
|
75
src/poweritem.c
Normal file
75
src/poweritem.c
Normal file
|
@ -0,0 +1,75 @@
|
||||||
|
/*
|
||||||
|
* This software is licensed under the terms of the MIT-License
|
||||||
|
* See COPYING for further information.
|
||||||
|
* ---
|
||||||
|
* Copyright (C) 2011, Lukas Weber <laochailan@web.de>
|
||||||
|
* Code by Juergen Kieslich
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "poweritem.h"
|
||||||
|
#include "global.h"
|
||||||
|
#include "list.h"
|
||||||
|
|
||||||
|
void create_poweritem(int x, int y, float acc, int angle, ItemRule rule) {
|
||||||
|
Poweritem *p = create_element((void **)&global.poweritems, sizeof(Poweritem));
|
||||||
|
p->x = x;
|
||||||
|
p->y = y;
|
||||||
|
p->sy = y;
|
||||||
|
p->acc = acc;
|
||||||
|
p->velo = -3;
|
||||||
|
p->angle = angle;
|
||||||
|
p->birthtime = global.frames;
|
||||||
|
p->tex = &global.textures.poweritems;
|
||||||
|
p->rule = rule;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void delete_poweritem(Poweritem *poweritem) {
|
||||||
|
delete_element((void **)&global.poweritems, poweritem);
|
||||||
|
}
|
||||||
|
|
||||||
|
void draw_poweritems() {
|
||||||
|
Poweritem *p;
|
||||||
|
Texture *tex = &global.textures.poweritems;
|
||||||
|
|
||||||
|
for(p = global.poweritems; p; p = p->next){
|
||||||
|
draw_texture(p->x, p->y, &global.textures.poweritems);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void free_poweritems() {
|
||||||
|
delete_all_elements((void **)&global.poweritems);
|
||||||
|
}
|
||||||
|
|
||||||
|
void simpleItem(int *y,int sy, float acc, long t, float *velo) {
|
||||||
|
if(*velo < 3 ) *velo += acc;
|
||||||
|
*y = sy + (*velo * t);
|
||||||
|
}
|
||||||
|
|
||||||
|
void process_poweritems() {
|
||||||
|
Poweritem *poweritem = global.poweritems, *del = NULL;
|
||||||
|
int v;
|
||||||
|
while(poweritem != NULL) {
|
||||||
|
poweritem->rule(&poweritem->y, poweritem->sy, poweritem->acc, global.frames - poweritem->birthtime, &poweritem->velo);
|
||||||
|
v = collision(poweritem);
|
||||||
|
if(v == 1) {
|
||||||
|
global.plr.power += 0.1;
|
||||||
|
}
|
||||||
|
if(v == 1 || poweritem->x < -20 || poweritem->x > VIEWPORT_W + 20 || poweritem->y < -20 || poweritem->y > VIEWPORT_H + 20) {
|
||||||
|
del = poweritem;
|
||||||
|
poweritem = poweritem->next;
|
||||||
|
delete_poweritem(del);
|
||||||
|
} else {
|
||||||
|
poweritem = poweritem->next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int collision(Poweritem *p) {
|
||||||
|
float angle = atan((float)(global.plr.y - p->y)/(global.plr.x - p->x));
|
||||||
|
|
||||||
|
if(sqrt(pow(p->x-global.plr.x,2) + pow(p->y-global.plr.y,2)) < 10)
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
40
src/poweritem.h
Normal file
40
src/poweritem.h
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
/*
|
||||||
|
* This software is licensed under the terms of the MIT-License
|
||||||
|
* See COPYING for further information.
|
||||||
|
* ---
|
||||||
|
* Copyright (C) 2011, Lukas Weber <laochailan@web.de>
|
||||||
|
* Code by: Juergen Kieslich
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef POWERITEM_H
|
||||||
|
#define POWERITEM_H
|
||||||
|
|
||||||
|
#include "texture.h"
|
||||||
|
|
||||||
|
struct Poweritem;
|
||||||
|
typedef void (*ItemRule)(int *y,int sy, float acc, long time, float *velo);
|
||||||
|
|
||||||
|
typedef struct Poweritem{
|
||||||
|
struct Poweritem *next;
|
||||||
|
struct Poweritem *prev;
|
||||||
|
|
||||||
|
long birthtime;
|
||||||
|
int x, y, sy;
|
||||||
|
char angle;
|
||||||
|
float acc;
|
||||||
|
float velo;
|
||||||
|
Texture *tex;
|
||||||
|
|
||||||
|
ItemRule rule;
|
||||||
|
} Poweritem;
|
||||||
|
|
||||||
|
void create_poweritem(int x, int y, float acc, int angle, ItemRule rule);
|
||||||
|
void delete_poweritem(Poweritem *poweritem);
|
||||||
|
void draw_poweritems();
|
||||||
|
void free_poweritems();
|
||||||
|
|
||||||
|
int collision(Poweritem *p);
|
||||||
|
void process_poweritems();
|
||||||
|
|
||||||
|
void simpleItem(int *y, int sy, float acc, long time, float *velo);
|
||||||
|
#endif
|
|
@ -73,7 +73,6 @@ int test_collision(Projectile *p) {
|
||||||
int projr = sqrt(pow(p->tex->w/4*cos(angle),2)*8/10 + pow(p->tex->h/2*sin(angle)*8/10,2));
|
int projr = sqrt(pow(p->tex->w/4*cos(angle),2)*8/10 + pow(p->tex->h/2*sin(angle)*8/10,2));
|
||||||
if(sqrt(pow(p->x-f->x,2) + pow(p->y-f->y,2)) < projr+10) {
|
if(sqrt(pow(p->x-f->x,2) + pow(p->y-f->y,2)) < projr+10) {
|
||||||
f->hp--;
|
f->hp--;
|
||||||
if(global.plr.power < 6) global.plr.power += 0.1;
|
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
f = f->next;
|
f = f->next;
|
||||||
|
|
|
@ -82,6 +82,7 @@ void stage_draw() {
|
||||||
|
|
||||||
draw_projectiles();
|
draw_projectiles();
|
||||||
draw_fairies();
|
draw_fairies();
|
||||||
|
draw_poweritems();
|
||||||
|
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
|
|
||||||
|
@ -97,6 +98,7 @@ void stage_logic() {
|
||||||
|
|
||||||
process_fairies();
|
process_fairies();
|
||||||
process_projectiles();
|
process_projectiles();
|
||||||
|
process_poweritems();
|
||||||
|
|
||||||
global.frames++;
|
global.frames++;
|
||||||
|
|
||||||
|
@ -112,6 +114,7 @@ void stage_logic() {
|
||||||
void stage_end() {
|
void stage_end() {
|
||||||
free_projectiles();
|
free_projectiles();
|
||||||
free_fairies();
|
free_fairies();
|
||||||
|
free_poweritems();
|
||||||
global.frames = 0;
|
global.frames = 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,7 +86,7 @@ void stage0_events() {
|
||||||
// int i;
|
// int i;
|
||||||
// for(i = 0; i < VIEWPORT_W/15; i++)
|
// for(i = 0; i < VIEWPORT_W/15; i++)
|
||||||
// create_projectile(&_projs.ball, i*VIEWPORT_W/15, 0, 90 + i*10, ((Color) {0,0,1}), simple, 2);
|
// create_projectile(&_projs.ball, i*VIEWPORT_W/15, 0, 90 + i*10, ((Color) {0,0,1}), simple, 2);
|
||||||
// create_fairy(0, 100, 1, 180, 2, simpleFairy);
|
create_fairy(0, 100, 1, 180, 2, simpleFairy);
|
||||||
// create_fairy(VIEWPORT_W-1, 10, -1, 180, 3, simpleFairy);
|
// create_fairy(VIEWPORT_W-1, 10, -1, 180, 3, simpleFairy);
|
||||||
// create_fairy(VIEWPORT_W-1, 200, -1, 180, 3, simpleFairy);
|
// create_fairy(VIEWPORT_W-1, 200, -1, 180, 3, simpleFairy);
|
||||||
create_projectile(&_projs.ball, VIEWPORT_W/2, 0, 180, ((Color) {0,0,1}), simple, 2);
|
create_projectile(&_projs.ball, VIEWPORT_W/2, 0, 180, ((Color) {0,0,1}), simple, 2);
|
||||||
|
@ -108,9 +108,10 @@ void stage0_loop() {
|
||||||
|
|
||||||
stage0_draw();
|
stage0_draw();
|
||||||
stage_draw();
|
stage_draw();
|
||||||
SDL_GL_SwapBuffers();
|
|
||||||
|
glPopMatrix();
|
||||||
|
|
||||||
// SDL_Delay(1000/FPS);
|
SDL_GL_SwapBuffers();
|
||||||
frame_rate();
|
frame_rate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
320
taisei.diff
Normal file
320
taisei.diff
Normal file
|
@ -0,0 +1,320 @@
|
||||||
|
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
||||||
|
index 62fbe80..723e0ac 100644
|
||||||
|
--- a/CMakeLists.txt
|
||||||
|
+++ b/CMakeLists.txt
|
||||||
|
@@ -6,3 +6,11 @@ add_subdirectory(src)
|
||||||
|
|
||||||
|
set(DATA_DIR "share/taisei")
|
||||||
|
install(DIRECTORY gfx DESTINATION ${DATA_DIR})
|
||||||
|
+# uninstall target
|
||||||
|
+configure_file(
|
||||||
|
+ "${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
|
||||||
|
+ "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
|
||||||
|
+ IMMEDIATE @ONLY)
|
||||||
|
+
|
||||||
|
+add_custom_target(uninstall
|
||||||
|
+ COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
|
||||||
|
\ No newline at end of file
|
||||||
|
diff --git a/cmake_uninstall.cmake.in b/cmake_uninstall.cmake.in
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000..97b93af
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/cmake_uninstall.cmake.in
|
||||||
|
@@ -0,0 +1,21 @@
|
||||||
|
+if (NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
|
||||||
|
+ message(FATAL_ERROR "Cannot find install manifest: \"@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt\"")
|
||||||
|
+endif(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
|
||||||
|
+
|
||||||
|
+file(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files)
|
||||||
|
+string(REGEX REPLACE "\n" ";" files "${files}")
|
||||||
|
+foreach (file ${files})
|
||||||
|
+ message(STATUS "Uninstalling \"$ENV{DESTDIR}${file}\"")
|
||||||
|
+ if (EXISTS "$ENV{DESTDIR}${file}")
|
||||||
|
+ execute_process(
|
||||||
|
+ COMMAND @CMAKE_COMMAND@ -E remove "$ENV{DESTDIR}${file}"
|
||||||
|
+ OUTPUT_VARIABLE rm_out
|
||||||
|
+ RESULT_VARIABLE rm_retval
|
||||||
|
+ )
|
||||||
|
+ if(NOT ${rm_retval} EQUAL 0)
|
||||||
|
+ message(FATAL_ERROR "Problem when removing \"$ENV{DESTDIR}${file}\"")
|
||||||
|
+ endif (NOT ${rm_retval} EQUAL 0)
|
||||||
|
+ else (EXISTS "$ENV{DESTDIR}${file}")
|
||||||
|
+ message(STATUS "File \"$ENV{DESTDIR}${file}\" does not exist.")
|
||||||
|
+ endif (EXISTS "$ENV{DESTDIR}${file}")
|
||||||
|
+endforeach(file)
|
||||||
|
\ No newline at end of file
|
||||||
|
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
|
||||||
|
index 910f5a4..1862cab 100644
|
||||||
|
--- a/src/CMakeLists.txt
|
||||||
|
+++ b/src/CMakeLists.txt
|
||||||
|
@@ -7,6 +7,7 @@ set(SRCs
|
||||||
|
projectile.c
|
||||||
|
animation.c
|
||||||
|
fairy.c
|
||||||
|
+ poweritem.c
|
||||||
|
list.c
|
||||||
|
font.c
|
||||||
|
stages/stage0.c)
|
||||||
|
diff --git a/src/fairy.c b/src/fairy.c
|
||||||
|
index d14d8ca..b98c51e 100644
|
||||||
|
--- a/src/fairy.c
|
||||||
|
+++ b/src/fairy.c
|
||||||
|
@@ -28,6 +28,7 @@ void create_fairy(int x, int y, int v, int angle, int hp, FairyRule rule) {
|
||||||
|
}
|
||||||
|
|
||||||
|
void delete_fairy(Fairy *fairy) {
|
||||||
|
+ if(global.plr.power < 6) create_poweritem(fairy->x, fairy->y,0.03,0,simpleItem);
|
||||||
|
delete_element((void **)&global.fairies, fairy);
|
||||||
|
}
|
||||||
|
|
||||||
|
diff --git a/src/fairy.h b/src/fairy.h
|
||||||
|
index 7f90755..221199c 100644
|
||||||
|
--- a/src/fairy.h
|
||||||
|
+++ b/src/fairy.h
|
||||||
|
@@ -17,7 +17,6 @@ typedef void (*FairyRule)(struct Fairy*);
|
||||||
|
typedef struct Fairy {
|
||||||
|
struct Fairy *next;
|
||||||
|
struct Fairy *prev;
|
||||||
|
-
|
||||||
|
long birthtime;
|
||||||
|
char hp;
|
||||||
|
|
||||||
|
diff --git a/src/global.c b/src/global.c
|
||||||
|
index 69d29b8..c05af37 100644
|
||||||
|
--- a/src/global.c
|
||||||
|
+++ b/src/global.c
|
||||||
|
@@ -17,6 +17,7 @@ void init_textures() {
|
||||||
|
load_texture(FILE_PREFIX "gfx/hud.png", &global.textures.hud);
|
||||||
|
load_texture(FILE_PREFIX "gfx/fairy_circle.png", &global.textures.fairy_circle);
|
||||||
|
load_texture(FILE_PREFIX "gfx/focus.png", &global.textures.focus);
|
||||||
|
+ load_texture(FILE_PREFIX "gfx/item_power.png", &global.textures.poweritems);
|
||||||
|
|
||||||
|
init_animation(&global.textures.fairy, 2, 2, 15, FILE_PREFIX "gfx/fairy.png");
|
||||||
|
}
|
||||||
|
@@ -31,6 +32,7 @@ void init_global() {
|
||||||
|
|
||||||
|
global.projs = NULL;
|
||||||
|
global.fairies = NULL;
|
||||||
|
+ global.poweritems = NULL;
|
||||||
|
|
||||||
|
global.frames = 0;
|
||||||
|
global.game_over = 0;
|
||||||
|
diff --git a/src/global.h b/src/global.h
|
||||||
|
index 559ef2f..a477d0a 100644
|
||||||
|
--- a/src/global.h
|
||||||
|
+++ b/src/global.h
|
||||||
|
@@ -1,6 +1,6 @@
|
||||||
|
/*
|
||||||
|
* This software is licensed under the terms of the MIT-License
|
||||||
|
- * See COPYING for further information.
|
||||||
|
+ * See COPYING for further information.
|
||||||
|
* ---
|
||||||
|
* Copyright (C) 2011, Lukas Weber <laochailan@web.de>
|
||||||
|
*/
|
||||||
|
@@ -8,54 +8,58 @@
|
||||||
|
#ifndef GLOBAL_H
|
||||||
|
#define GLOBAL_H
|
||||||
|
|
||||||
|
+#include <SDL/SDL_opengl.h>
|
||||||
|
#include <SDL/SDL.h>
|
||||||
|
#include "player.h"
|
||||||
|
#include "projectile.h"
|
||||||
|
#include "fairy.h"
|
||||||
|
+#include "poweritem.h"
|
||||||
|
|
||||||
|
enum {
|
||||||
|
RESX = 800,
|
||||||
|
RESY = 600,
|
||||||
|
-
|
||||||
|
+
|
||||||
|
SCREEN_W = 800,
|
||||||
|
SCREEN_H = 600,
|
||||||
|
-
|
||||||
|
+
|
||||||
|
VIEWPORT_X = 40,
|
||||||
|
VIEWPORT_Y = 20,
|
||||||
|
VIEWPORT_W = 480,
|
||||||
|
VIEWPORT_H = 560,
|
||||||
|
-
|
||||||
|
+
|
||||||
|
FPS = 60
|
||||||
|
};
|
||||||
|
|
||||||
|
#define FILE_PREFIX PREFIX "/share/taisei/"
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
- Player plr;
|
||||||
|
+ Player plr;
|
||||||
|
Projectile *projs;
|
||||||
|
Fairy *fairies;
|
||||||
|
-
|
||||||
|
+ Poweritem *poweritems;
|
||||||
|
+
|
||||||
|
int frames;
|
||||||
|
-
|
||||||
|
+
|
||||||
|
struct {
|
||||||
|
Texture hud;
|
||||||
|
-
|
||||||
|
+
|
||||||
|
Texture projwave;
|
||||||
|
Texture water;
|
||||||
|
Texture border;
|
||||||
|
Texture fairy_circle;
|
||||||
|
Texture focus;
|
||||||
|
-
|
||||||
|
+ Texture poweritems;
|
||||||
|
+
|
||||||
|
Animation fairy;
|
||||||
|
} textures;
|
||||||
|
-
|
||||||
|
+
|
||||||
|
int game_over;
|
||||||
|
-
|
||||||
|
+
|
||||||
|
int time;
|
||||||
|
-
|
||||||
|
+
|
||||||
|
int fpstime; // frame counter
|
||||||
|
int fps;
|
||||||
|
-
|
||||||
|
+
|
||||||
|
int lasttime;
|
||||||
|
} Global;
|
||||||
|
|
||||||
|
diff --git a/src/poweritem.c b/src/poweritem.c
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000..7e1775e
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/src/poweritem.c
|
||||||
|
@@ -0,0 +1,80 @@
|
||||||
|
+/*
|
||||||
|
+ * This software is licensed under the terms of the MIT-License
|
||||||
|
+ * See COPYING for further information.
|
||||||
|
+ * ---
|
||||||
|
+ * Copyright (C) 2011, Lukas Weber <laochailan@web.de>
|
||||||
|
+ * Code by Juergen Kieslich
|
||||||
|
+ */
|
||||||
|
+
|
||||||
|
+#include "poweritem.h"
|
||||||
|
+#include "global.h"
|
||||||
|
+#include "list.h"
|
||||||
|
+
|
||||||
|
+void create_poweritem(int x, int y, float acc, int angle, ItemRule rule) {
|
||||||
|
+ Poweritem *p = create_element((void **)&global.poweritems, sizeof(Poweritem));
|
||||||
|
+ p->x = x;
|
||||||
|
+ p->y = y;
|
||||||
|
+ p->sy = y;
|
||||||
|
+ p->acc = acc;
|
||||||
|
+ p->velo = -3;
|
||||||
|
+ p->angle = angle;
|
||||||
|
+ p->birthtime = global.frames;
|
||||||
|
+ p->tex = &global.textures.poweritems;
|
||||||
|
+ p->rule = rule;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+
|
||||||
|
+void delete_poweritem(Poweritem *poweritem) {
|
||||||
|
+ delete_element((void **)&global.poweritems, poweritem);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+void draw_poweritems() {
|
||||||
|
+ Poweritem *p;
|
||||||
|
+ Texture *tex = &global.textures.poweritems;
|
||||||
|
+
|
||||||
|
+ for(p = global.poweritems; p; p = p->next){
|
||||||
|
+ draw_texture(p->x, p->y, &global.textures.poweritems);
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+void free_poweritems() {
|
||||||
|
+ delete_all_elements((void **)&global.poweritems);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+void simpleItem(int *y,int sy, float acc, long t, float *velo) {
|
||||||
|
+ if(*velo < 3 ) *velo += acc;
|
||||||
|
+ *y = sy + (*velo * t);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+void process_poweritems() {
|
||||||
|
+ Poweritem *poweritem = global.poweritems, *del = NULL;
|
||||||
|
+ int v;
|
||||||
|
+ while(poweritem != NULL) {
|
||||||
|
+ poweritem->rule(&poweritem->y, poweritem->sy, poweritem->acc, global.frames - poweritem->birthtime, &poweritem->velo);
|
||||||
|
+ v = collision(poweritem);
|
||||||
|
+ if(v == 1) {
|
||||||
|
+ global.plr.power += 0.1;
|
||||||
|
+ }
|
||||||
|
+ if(v == 1 || poweritem->x < -20 || poweritem->x > VIEWPORT_W + 20 || poweritem->y < -20 || poweritem->y > VIEWPORT_H + 20) {
|
||||||
|
+ del = poweritem;
|
||||||
|
+ poweritem = poweritem->next;
|
||||||
|
+ delete_poweritem(del);
|
||||||
|
+ } else {
|
||||||
|
+ poweritem = poweritem->next;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+int collision(Poweritem *p) {
|
||||||
|
+ float angle = atan((float)(global.plr.y - p->y)/(global.plr.x - p->x));
|
||||||
|
+
|
||||||
|
+ int projr = sqrt(pow(p->tex->w/4*cos(angle),2)*8/10 + pow(p->tex->h/2*sin(angle)*8/10,2));
|
||||||
|
+ if(sqrt(pow(p->x-global.plr.x,2) + pow(p->y-global.plr.y,2)) < projr+1) {
|
||||||
|
+ // most magic line in the game.
|
||||||
|
+ // i tried to get some touhou feel.
|
||||||
|
+ // +/- 9 didn't really work so i used +1
|
||||||
|
+ return 1;
|
||||||
|
+ return 0;
|
||||||
|
+
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
diff --git a/src/poweritem.h b/src/poweritem.h
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000..a7b01c1
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/src/poweritem.h
|
||||||
|
@@ -0,0 +1,40 @@
|
||||||
|
+/*
|
||||||
|
+ * This software is licensed under the terms of the MIT-License
|
||||||
|
+ * See COPYING for further information.
|
||||||
|
+ * ---
|
||||||
|
+ * Copyright (C) 2011, Lukas Weber <laochailan@web.de>
|
||||||
|
+ * Code by: Juergen Kieslich
|
||||||
|
+ */
|
||||||
|
+
|
||||||
|
+#ifndef POWERITEM_H
|
||||||
|
+#define POWERITEM_H
|
||||||
|
+
|
||||||
|
+#include "texture.h"
|
||||||
|
+
|
||||||
|
+struct Poweritem;
|
||||||
|
+typedef void (*ItemRule)(int *y,int sy, float acc, long time, float *velo);
|
||||||
|
+
|
||||||
|
+typedef struct Poweritem{
|
||||||
|
+ struct Poweritem *next;
|
||||||
|
+ struct Poweritem *prev;
|
||||||
|
+
|
||||||
|
+ long birthtime;
|
||||||
|
+ int x, y, sy;
|
||||||
|
+ char angle;
|
||||||
|
+ float acc;
|
||||||
|
+ float velo;
|
||||||
|
+ Texture *tex;
|
||||||
|
+
|
||||||
|
+ ItemRule rule;
|
||||||
|
+} Poweritem;
|
||||||
|
+
|
||||||
|
+void create_poweritem(int x, int y, float acc, int angle, ItemRule rule);
|
||||||
|
+void delete_poweritem(Poweritem *poweritem);
|
||||||
|
+void draw_poweritems();
|
||||||
|
+void free_poweritems();
|
||||||
|
+
|
||||||
|
+int collision(Poweritem *p);
|
||||||
|
+void process_poweritems();
|
||||||
|
+
|
||||||
|
+void simpleItem(int *y, int sy, float acc, long time, float *velo);
|
||||||
|
+#endif
|
||||||
|
diff --git a/src/projectile.c b/src/projectile.c
|
||||||
|
index 0b2226d..bba6df7 100644
|
||||||
|
--- a/src/projectile.c
|
||||||
|
+++ b/src/projectil
|
Loading…
Reference in a new issue