a10f5eea93
Sarrg was friendly enough to provide us some power item support. Looks like in the orignal in some way.
320 lines
No EOL
7.9 KiB
Diff
320 lines
No EOL
7.9 KiB
Diff
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
|