1 //  $Id: type.h 1026 2004-05-07 20:48:22Z tobgle $
2 //
3 //  SuperTux
4 //  Copyright (C) 2004 Tobias Glaesser <tobi.web@gmx.de>
5 //
6 //  This program is free software; you can redistribute it and/or
7 //  modify it under the terms of the GNU General Public License
8 //  as published by the Free Software Foundation; either version 2
9 //  of the License, or (at your option) any later version.
10 //
11 //  This program is distributed in the hope that it will be useful,
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 //  GNU General Public License for more details.
15 //
16 //  You should have received a copy of the GNU General Public License
17 //  along with this program; if not, write to the Free Software
18 //  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
19 //  02111-1307, USA.
20 
21 #ifndef SUPERTUX_TYPE_H
22 #define SUPERTUX_TYPE_H
23 
24 #include <string>
25 #include "SDL.h"
26 #include "scene.h"
27 
28 /* 'Base' type for game objects */
29 
30 struct base_type
31 {
32   float x;
33   float y;
34   float xm;
35   float ym;
36   float width;
37   float height;
38 };
39 
40 
41 /* Base class for all dynamic game object. */
42 class GameObject
43 {
44 
45 public:
GameObject()46   GameObject() {};
~GameObject()47   virtual ~GameObject() {};
48   virtual void action(double frame_ratio) = 0;
49   virtual void draw() = 0;
50   virtual std::string type() = 0;
51   /* Draw ignoring the scroll_x value. FIXME: Hack? Should be discussed. @tobgle*/
52   void draw_on_screen(float x = -1, float y = -1)
53   {
54     base_type btmp = base;
55     if(x != -1 || y != -1)
56     {
57       btmp = base;
58       if(x != -1)
59         base.x = x;
60       if(y != -1)
61         base.y = y;
62     }
63     float tmp = scroll_x;
64     scroll_x = 0; draw();
65     scroll_x = tmp;
66     base = btmp;
67   };
move_to(float x,float y)68 void move_to(float x, float y) { base.x = x; base.y = y; };
69 
70   base_type base;
71   base_type old_base;
72 };
73 
74 struct string_list_type
75 {
76   int num_items;
77   int active_item;
78   char **item;
79 };
80 
81 void  string_list_init(string_list_type* pstring_list);
82 char* string_list_active(string_list_type* pstring_list);
83 void  string_list_copy(string_list_type* pstring_list, string_list_type pstring_list_orig);
84 int   string_list_find(string_list_type* pstring_list, const char* str);
85 void  string_list_sort(string_list_type* pstring_list);
86 void  string_list_add_item(string_list_type* pstring_list, const char* str);
87 void  string_list_free(string_list_type* pstring_list);
88 
89 #endif /*SUPERTUX_TYPE_H*/
90 
91