initial
authorTobias Gläßer <tobi.web@gmx.de>
Wed, 18 Feb 2004 00:15:36 +0000 (00:15 +0000)
committerTobias Gläßer <tobi.web@gmx.de>
Wed, 18 Feb 2004 00:15:36 +0000 (00:15 +0000)
SVN-Revision: 127

21 files changed:
data/images/icons/default-icon.png [new file with mode: 0644]
data/images/icons/down.png [new file with mode: 0644]
data/images/icons/rubber.png [new file with mode: 0644]
data/images/icons/test-level.png [new file with mode: 0644]
data/images/icons/up.png [new file with mode: 0644]
data/images/status/checkbox-checked.png [new file with mode: 0644]
data/images/status/checkbox-checked.xcf [new file with mode: 0644]
data/images/status/checkbox.png [new file with mode: 0644]
data/images/status/checkbox.xcf [new file with mode: 0644]
data/images/status/choose-level-subset.png [new file with mode: 0644]
data/images/status/choose-level-subset.xcf [new file with mode: 0644]
data/images/status/choose-subset.png [new file with mode: 0644]
data/images/status/choose-subset.xcf [new file with mode: 0644]
data/images/status/letters-white-small.png [new file with mode: 0644]
data/images/status/letters-white.png [new file with mode: 0644]
data/images/status/level-subset-info.png [new file with mode: 0644]
src/button.c [new file with mode: 0644]
src/button.h [new file with mode: 0644]
src/globals.c [new file with mode: 0644]
src/physic.c [new file with mode: 0644]
src/physic.h [new file with mode: 0644]

diff --git a/data/images/icons/default-icon.png b/data/images/icons/default-icon.png
new file mode 100644 (file)
index 0000000..20e58ea
Binary files /dev/null and b/data/images/icons/default-icon.png differ
diff --git a/data/images/icons/down.png b/data/images/icons/down.png
new file mode 100644 (file)
index 0000000..206495b
Binary files /dev/null and b/data/images/icons/down.png differ
diff --git a/data/images/icons/rubber.png b/data/images/icons/rubber.png
new file mode 100644 (file)
index 0000000..af8a243
Binary files /dev/null and b/data/images/icons/rubber.png differ
diff --git a/data/images/icons/test-level.png b/data/images/icons/test-level.png
new file mode 100644 (file)
index 0000000..7702c8c
Binary files /dev/null and b/data/images/icons/test-level.png differ
diff --git a/data/images/icons/up.png b/data/images/icons/up.png
new file mode 100644 (file)
index 0000000..4498ece
Binary files /dev/null and b/data/images/icons/up.png differ
diff --git a/data/images/status/checkbox-checked.png b/data/images/status/checkbox-checked.png
new file mode 100644 (file)
index 0000000..53d3bab
Binary files /dev/null and b/data/images/status/checkbox-checked.png differ
diff --git a/data/images/status/checkbox-checked.xcf b/data/images/status/checkbox-checked.xcf
new file mode 100644 (file)
index 0000000..d371f8c
Binary files /dev/null and b/data/images/status/checkbox-checked.xcf differ
diff --git a/data/images/status/checkbox.png b/data/images/status/checkbox.png
new file mode 100644 (file)
index 0000000..d58b1a0
Binary files /dev/null and b/data/images/status/checkbox.png differ
diff --git a/data/images/status/checkbox.xcf b/data/images/status/checkbox.xcf
new file mode 100644 (file)
index 0000000..a5aa7a0
Binary files /dev/null and b/data/images/status/checkbox.xcf differ
diff --git a/data/images/status/choose-level-subset.png b/data/images/status/choose-level-subset.png
new file mode 100644 (file)
index 0000000..ea8b1dc
Binary files /dev/null and b/data/images/status/choose-level-subset.png differ
diff --git a/data/images/status/choose-level-subset.xcf b/data/images/status/choose-level-subset.xcf
new file mode 100644 (file)
index 0000000..dee84b3
Binary files /dev/null and b/data/images/status/choose-level-subset.xcf differ
diff --git a/data/images/status/choose-subset.png b/data/images/status/choose-subset.png
new file mode 100644 (file)
index 0000000..148952b
Binary files /dev/null and b/data/images/status/choose-subset.png differ
diff --git a/data/images/status/choose-subset.xcf b/data/images/status/choose-subset.xcf
new file mode 100644 (file)
index 0000000..43661c2
Binary files /dev/null and b/data/images/status/choose-subset.xcf differ
diff --git a/data/images/status/letters-white-small.png b/data/images/status/letters-white-small.png
new file mode 100644 (file)
index 0000000..fce3852
Binary files /dev/null and b/data/images/status/letters-white-small.png differ
diff --git a/data/images/status/letters-white.png b/data/images/status/letters-white.png
new file mode 100644 (file)
index 0000000..3f99953
Binary files /dev/null and b/data/images/status/letters-white.png differ
diff --git a/data/images/status/level-subset-info.png b/data/images/status/level-subset-info.png
new file mode 100644 (file)
index 0000000..9c02c4b
Binary files /dev/null and b/data/images/status/level-subset-info.png differ
diff --git a/src/button.c b/src/button.c
new file mode 100644 (file)
index 0000000..ee7dbc7
--- /dev/null
@@ -0,0 +1,80 @@
+//
+// C Implementation: button
+//
+// Description:
+//
+//
+// Author: Tobias Glaesser <tobi.web@gmx.de>, (C) 2004
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+
+#include <string.h>
+#include <stdlib.h>
+#include "setup.h"
+#include "screen.h"
+#include "button.h"
+
+void button_load(button_type* pbutton,char* icon_file, char* text, char* info, int x, int y)
+{
+char filename[1024];
+
+if(icon_file != NULL)
+{
+  snprintf(filename, 1024, "%s/%s", DATA_PREFIX, icon_file);
+  if(!faccessible(filename))
+    snprintf(filename, 1024, "%s/images/icons/default-icon.png", DATA_PREFIX);
+}
+else
+{
+snprintf(filename, 1024, "%s/images/icons/default-icon.png", DATA_PREFIX);
+}
+texture_load(&pbutton->icon,filename,USE_ALPHA);
+
+  if(text == NULL)
+    {
+      pbutton->text = NULL;
+    }
+  else
+    {
+      pbutton->text = (char*) malloc(sizeof(char)*(strlen(text) + 1));
+      strcpy(pbutton->text,text);
+    }
+  if(info == NULL)
+    {
+      pbutton->info = NULL;
+    }
+  else
+    {
+      pbutton->info = (char*) malloc(sizeof(char)*(strlen(info) + 1));
+      strcpy(pbutton->info,info);
+    }
+  pbutton->x = x;
+  pbutton->y = y;
+  pbutton->w = pbutton->icon.w;
+  pbutton->h = pbutton->icon.h;
+  pbutton->state = -1;
+}
+
+void button_draw(button_type* pbutton)
+{
+  fillrect(pbutton->x,pbutton->y,pbutton->w,pbutton->h,75,75,75,200);
+  fillrect(pbutton->x+1,pbutton->y+1,pbutton->w-2,pbutton->h-2,175,175,175,200);
+  texture_draw(&pbutton->icon,pbutton->x,pbutton->y,NO_UPDATE);
+}
+
+void button_free(button_type* pbutton)
+{
+free(pbutton->text);
+free(pbutton->info);
+texture_free(&pbutton->icon);
+}
+
+int button_pressed(button_type* pbutton, int x, int y)
+{
+if(x >= pbutton->x && x <= pbutton->x + pbutton->w && y >= pbutton->y && y <= pbutton->y + pbutton->h)
+return YES;
+else
+return NO;
+}
diff --git a/src/button.h b/src/button.h
new file mode 100644 (file)
index 0000000..12925fa
--- /dev/null
@@ -0,0 +1,39 @@
+//
+// C Interface: button
+//
+// Description: 
+//
+//
+// Author: Tobias Glaesser <tobi.web@gmx.de>, (C) 2004
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+
+#ifndef SUPERTUX_BUTTON_H
+#define SUPERTUX_BUTTON_H
+
+#include "texture.h"
+
+typedef struct button_type
+  {
+    texture_type icon;
+    char *info;
+    char *text;
+    int x;
+    int y;
+    int w;
+    int h;
+    int state;
+  } button_type;
+  
+void button_load(button_type* pbutton,char* icon_file, char* text, char* info, int x, int y);
+void button_draw(button_type* pbutton);
+void button_free(button_type* pbutton);
+int button_pressed(button_type* pbutton, int x, int y);
+
+enum {
+  BN_PRESSED
+};
+
+#endif /*SUPERTUX_BUTTON_H*/
diff --git a/src/globals.c b/src/globals.c
new file mode 100644 (file)
index 0000000..ab059fb
--- /dev/null
@@ -0,0 +1,27 @@
+//
+// C Implementation: globals
+//
+// Description:
+//
+//
+// Author: Tobias Glaesser <tobi.web@gmx.de>, (C) 2004
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+
+#include "globals.h"
+
+SDL_Surface * screen;
+text_type black_text, gold_text, blue_text, red_text, yellow_nums, white_text, white_small_text;
+
+int use_gl, use_joystick, use_fullscreen, debug_mode, show_fps;
+
+/* SuperTux directory ($HOME/.supertux) and save directory($HOME/.supertux/save) */
+char *st_dir, *st_save_dir;
+
+#ifdef JOY_YES
+SDL_Joystick * js;
+#endif
+
+
diff --git a/src/physic.c b/src/physic.c
new file mode 100644 (file)
index 0000000..7f3c256
--- /dev/null
@@ -0,0 +1,53 @@
+//
+// C Implementation: physic
+//
+// Description: 
+//
+//
+// Author: Tobias Glaesser <tobi.web@gmx.de>, (C) 2004
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+
+#include <stdio.h>
+#include "physic.h"
+
+void physic_init(physic_type* pphysic)
+{
+pphysic->state = -1;
+pphysic->start_time = 0;
+}
+
+int physic_get_state(physic_type* pphysic)
+{
+return pphysic->state;
+}
+
+void physic_set_state(physic_type* pphysic, int nstate)
+{
+pphysic->state = nstate;
+pphysic->start_time = st_get_ticks();
+}
+
+float physic_get_velocity(physic_type* pphysic, float start_velocity)
+{
+return - (start_velocity - 10.* ((float)(st_get_ticks() - pphysic->start_time))/1000.);
+}
+
+float physic_get_max_distance(physic_type* pphysic, float start_velocity)
+{
+return (start_velocity * start_velocity / 2.*10.);
+}
+
+unsigned int physic_get_max_time(physic_type* pphysic, float start_velocity)
+{
+return (unsigned int)((start_velocity / 10.) * 1000);
+}
+
+unsigned int physic_get_time_gone(physic_type* pphysic)
+{
+return st_get_ticks() - pphysic->start_time;
+}
+
+
diff --git a/src/physic.h b/src/physic.h
new file mode 100644 (file)
index 0000000..3730285
--- /dev/null
@@ -0,0 +1,39 @@
+//
+// C++ Interface: physic
+//
+// Description: 
+//
+//
+// Author: Tobias Glaesser <tobi.web@gmx.de>, (C) 2004
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+
+#ifndef SUPERTUX_PHYSIC_H
+#define SUPERTUX_PHYSIC_H
+
+#include "timer.h"
+
+enum {
+  PH_VTU /* Vertical throw up. */
+};
+
+/* Physic type: */
+
+typedef struct physic_type
+  {
+      int state;
+      unsigned int start_time;
+  }
+physic_type;
+
+void physic_init(physic_type* pphysic);
+int physic_get_state(physic_type* pphysic);
+void physic_set_state(physic_type* pphysic, int nstate);
+float physic_get_velocity(physic_type* pphysic, float start_velocity);
+float physic_get_max_distance(physic_type* pphysic, float start_velocity);
+unsigned int physic_get_max_time(physic_type* pphysic, float start_velocity);
+unsigned int physic_get_time_gone(physic_type* pphysic);
+
+#endif /*SUPERTUX_PHYSIC_H*/