--- /dev/null
+//
+// 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;
+}
--- /dev/null
+//
+// 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*/
--- /dev/null
+//
+// 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
+
+
--- /dev/null
+//
+// 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;
+}
+
+
--- /dev/null
+//
+// 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*/