From: Tobias Gläßer Date: Wed, 18 Feb 2004 00:15:36 +0000 (+0000) Subject: initial X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=44a86f89d388d66dc47c0614217eba32f1aea22f;p=supertux.git initial SVN-Revision: 127 --- diff --git a/data/images/icons/default-icon.png b/data/images/icons/default-icon.png new file mode 100644 index 000000000..20e58ea04 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 index 000000000..206495bfd 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 index 000000000..af8a2433a 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 index 000000000..7702c8ca0 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 index 000000000..4498ece83 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 index 000000000..53d3babc6 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 index 000000000..d371f8cb5 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 index 000000000..d58b1a05c 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 index 000000000..a5aa7a033 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 index 000000000..ea8b1dcec 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 index 000000000..dee84b3a6 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 index 000000000..148952b91 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 index 000000000..43661c22a 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 index 000000000..fce3852e1 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 index 000000000..3f9995344 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 index 000000000..9c02c4b15 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 index 000000000..ee7dbc740 --- /dev/null +++ b/src/button.c @@ -0,0 +1,80 @@ +// +// C Implementation: button +// +// Description: +// +// +// Author: Tobias Glaesser , (C) 2004 +// +// Copyright: See COPYING file that comes with this distribution +// +// + +#include +#include +#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 index 000000000..12925fa5d --- /dev/null +++ b/src/button.h @@ -0,0 +1,39 @@ +// +// C Interface: button +// +// Description: +// +// +// Author: Tobias Glaesser , (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 index 000000000..ab059fbbb --- /dev/null +++ b/src/globals.c @@ -0,0 +1,27 @@ +// +// C Implementation: globals +// +// Description: +// +// +// Author: Tobias Glaesser , (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 index 000000000..7f3c25676 --- /dev/null +++ b/src/physic.c @@ -0,0 +1,53 @@ +// +// C Implementation: physic +// +// Description: +// +// +// Author: Tobias Glaesser , (C) 2004 +// +// Copyright: See COPYING file that comes with this distribution +// +// + +#include +#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 index 000000000..3730285b7 --- /dev/null +++ b/src/physic.h @@ -0,0 +1,39 @@ +// +// C++ Interface: physic +// +// Description: +// +// +// Author: Tobias Glaesser , (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*/