Skip to content

Commit

Permalink
bug fixes, code improvements
Browse files Browse the repository at this point in the history
Engine Changes:
-adjusted logging
-improved saving/loading
-changes to settings file now reflect changes in game
-checkboxes may now be added to menus
-created a way to easily switch between menus
-buttons may now store function pointers that have an integer parameter
Demo Changes:
-fixed checkboxes not working after game load
-updated readme
  • Loading branch information
confuzedskull committed Nov 19, 2014
1 parent 26a5898 commit 2442cf9
Show file tree
Hide file tree
Showing 30 changed files with 273 additions and 194 deletions.
1 change: 1 addition & 0 deletions data/objects/object#10.rso
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
0
0
0

-1
-1
-1
Expand Down
1 change: 1 addition & 0 deletions data/objects/object#11.rso
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
0
0
0

-1
-1
-1
Expand Down
21 changes: 14 additions & 7 deletions data/objects/object#3.pso
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,31 @@
0
0
0
2 12 0
2 12 0
2 12 0
2 12 0
2 12 0
2 12 0

-1
-1
-1
-1
0
0.015
-8.000
0.000
0.000
-1.809
-1.809
0.000
0.000
177.081 114.318
179.737 116.033
0.000
0.000 0.000
0.000 0.000
0.000
1.468 0.948
0.000
2.656 1.715
0.000 0.000
0.000
0.022 0.014
0.000 0.000
0.000
0.000 0.000
21 changes: 14 additions & 7 deletions data/objects/object#4.pso
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@
0
0
0
4 12 0
4 12 0
4 12 0
4 12 0
4 12 0
4 12 0

-1
-1
-1
Expand All @@ -26,16 +33,16 @@
0.015
0.000
0.000
-1.809
-1.809
0.000
0.000
203.979 114.318
207.039 116.033
0.000
0.000
1.691 0.948
0.000 0.000
0.000 0.000
0.000
3.060 1.715
0.000
0.025 0.014
0.000 0.000
0.000
0.000 0.000
0.000
0.000 0.000
21 changes: 14 additions & 7 deletions data/objects/object#5.pso
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,31 @@
0
0
0
1 12 0
1 12 0
1 12 0
1 12 0
1 12 0
1 12 0

-1
-1
-1
-1
0
0.015
-0.000
0.000
0.000
-1.809
-1.809
0.000
0.000
203.979 87.420
207.039 88.731
0.000
0.000 0.000
0.000 0.000
0.000
1.691 0.725
0.000
3.060 1.311
0.000 0.000
0.000
0.025 0.011
0.000 0.000
0.000
0.000 0.000
21 changes: 14 additions & 7 deletions data/objects/object#6.pso
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@
0
0
0
3 12 0
3 12 0
3 12 0
3 12 0
3 12 0
3 12 0

-1
-1
-1
Expand All @@ -26,16 +33,16 @@
0.015
0.000
0.000
-1.809
-1.809
0.000
0.000
177.081 87.420
179.737 88.731
0.000
0.000
1.468 0.725
0.000 0.000
0.000 0.000
0.000
2.656 1.311
0.000
0.022 0.011
0.000 0.000
0.000
0.000 0.000
0.000
0.000 0.000
1 change: 1 addition & 0 deletions data/objects/object#7.dro
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
0
0
0

-1
-1
-1
Expand Down
1 change: 1 addition & 0 deletions data/objects/object#8.rso
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
0
0
0

-1
-1
-1
Expand Down
1 change: 1 addition & 0 deletions data/objects/object#9.rso
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
0
0
0

-1
-1
-1
Expand Down
3 changes: 3 additions & 0 deletions data/settings.ini
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@ origin_y = 431
[rts_object]
origin_x = 1224
origin_y = 360
[ui]
overlay_margin = 10
[window]
height = 720
position_x = 0
position_y = 0
refresh_rate = 60
width = 1360
10 changes: 7 additions & 3 deletions include/button.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,22 @@ class button: public clickable_object
protected:
label text;
std::string text_allignment;
int int_param1;
public:
int margin;//space between label and button border
bool performed_action;//whether or not the button action executed
void (*action)();//a function pointer which will be called when clicked
void (*action1i)(int i);//a function pointer which will be called when clicked
void format();//adjusts the size of the button to fit the label
void set_label(std::string l);
void set_action(void (*a)());
void allign_label(std::string allignment);
void set_action(void (*a)(int),int i);
void mouse_function();
void render();
void render() override;
void update();
virtual void set_label(std::string l);
virtual void allign_label(std::string allignment);
static void action_placeholder();
static void action_placeholder1i(int i);
button();
button(float x, float y, char* l, void (*a)(void));
};
Expand Down
21 changes: 9 additions & 12 deletions include/checkbox.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,22 @@

#ifndef CHECKBOX_H
#define CHECKBOX_H
#include "clickable_object.h"
#include "label.h"
#include "button.h"

class checkbox: public clickable_object
class checkbox: public button
{
protected:
int checked;
label text;
public:
int* option;
int margin;
color check_color;
void set_label(std::string text);
void set_label(std::string text,std::string pos);
void put_label(std::string pos);
int checkmark_margin;
color checkmark_color;
void bind_option(int*);
void mouse_function();
void render();
void update();
void set_label(std::string l) override;
void allign_label(std::string allignment) override;
void mouse_function() override;
void update() override;
void render() override;
checkbox();
};

Expand Down
4 changes: 1 addition & 3 deletions include/cursor.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,8 @@ class cursor
static point2i right_down;
static point2i right_up;
static point2i right_drag;
static point2i rally;
static clickable_object* left_clicked_object;
static clickable_object* right_clicked_object;
static bool set_rally;
static bool left_click;
static bool left_dragging;
static bool right_click;
Expand All @@ -52,7 +50,7 @@ class cursor
static int selected_object;
static int objects_selected();
static void calc_boundaries();
static void selection_box();
static void render_box();
static void reset();
};
#endif // CURSOR_H
13 changes: 8 additions & 5 deletions include/game.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
//stores important functions and variables related to the game
namespace game
{
extern float time;//stores the current game time in seconds
extern double time;//stores the current game time in seconds
extern clock_t time_started;//start time
extern double time_elapsed;//time since start
extern int state;//whether the game is active or not
Expand All @@ -42,7 +42,10 @@ namespace game
void add_setting(std::string section, std::string property, int* variable);//associates a property with a variable
void add_condition(std::string section, std::string property, int value, void (*action)());//specifies what action should be performed when a property has a specific value
void initialize();//initialize the objects
void load_settings();
void save_settings();
void collision_detection();//handles object collision
void switch_menu(int index);
void show_draggable_objects();//show all draggable objects in current scene
void hide_draggable_objects();//hide all draggable objects in current scene
void show_physics_objects();//show all physics objects in current scene
Expand All @@ -54,12 +57,11 @@ namespace game
void add_rts_object();//add an rts object to the current scene
void create_object();//creates an object of the previously created type
void delete_selected();//remove the selected object from the game
void play();//open game screen
void pause();//open pause screen
void play();//open play scene
void pause();//pause the game
void resume();//unpause the game
void warn_quit();//warn user before quitting
void warn_return();//warn user before returning to main menu
void return_menu();//open main menu
void warn_quit();
void quit();//close the program
void update();//update variables
void load();//loads the game
Expand All @@ -69,4 +71,5 @@ namespace game
const int PAUSED=0;
const int PLAYING=1;
const int LOADING=2;
const int SAVING=3;
#endif // GAME_H
1 change: 1 addition & 0 deletions include/scene.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class scene
void add_button(button*);//add button to the scene
void add_menu(menu*);//add menu to the scene
void add_menu(dropdown_menu*);//add dropdown menu to the scene
void switch_menu(int index);//make the menu at given index current and hide other menus
void bind_key(unsigned char key, int* toggle);//associate a key which will toggle a game option on/off
void bind_key(std::string special_key, int* toggle);//associate a key which will toggle a game option on/off
void bind_key(unsigned char key, void (*action)());//associate a key with an action
Expand Down
2 changes: 1 addition & 1 deletion include/ui.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
//This namespace contains functions and variables related to the user interface
namespace ui
{
extern int margin;//space between window edge and text
extern int overlay_margin;//space between window edge and overlay text
void check_clicked();//check every clickable object to see if the cursor clicked it
void show_text();//makes the text of the current scene visible
void hide_text();//makes the text of the current scene invisible
Expand Down
2 changes: 1 addition & 1 deletion include/window.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace window
extern int height;
extern point2i center;
extern point2i position;//this refers to the upper left corner of the window
extern double refresh_rate;
extern int refresh_rate;//frequency of screen updates (in hertz)
void change_size(int w, int h);
void initialize();
void render();
Expand Down
1 change: 0 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ A. Global
1. The "insert" key doesn't work on Macs.
2. When navigating menus with the arrow keys, the selector sometimes gets stuck.
3. Some objects appear to twitch when moving.
4. After loading a game, the checkboxes no longer work.
B. Draggable Objects
1. While dragging, an object may get stuck on top of another object when they collide.
C. Physics Objects
Expand Down
Loading

0 comments on commit 2442cf9

Please sign in to comment.