Skip to content

Commit

Permalink
major improvements to "scene" class
Browse files Browse the repository at this point in the history
Engine Changes:
-added more methods to "scene" class
-scene class now loads/saves more data
-added foreground, middleground, and background to "scene" class

Demo Changes:
-added Starcraft 2 background, portal middleground, and angrybirds
foreground
-added checkboxes to show/hide foreground,middleground, and background
-added checkbox to show/hide textures
-added checkbox to mute/unmute all sounds
  • Loading branch information
confuzedskull committed Dec 20, 2014
1 parent dbd47d4 commit 6cf6649
Show file tree
Hide file tree
Showing 27 changed files with 481 additions and 88 deletions.
File renamed without changes.
4 changes: 2 additions & 2 deletions data/objects/object#4.pso → data/objects/object#13.pso
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ clack.wav
728.000 408.000
90.000
0.015
nan
0.000
-0.031
0.000
0.000
0.000
0.000
0.000
Expand Down
4 changes: 2 additions & 2 deletions data/objects/object#5.pso → data/objects/object#14.pso
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ clack.wav
728.000 312.000
90.000
0.015
nan
0.000
0.031
0.000
0.000
0.000
0.000
0.000
Expand Down
4 changes: 2 additions & 2 deletions data/objects/object#6.pso → data/objects/object#15.pso
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ clack.wav
632.000 312.000
90.000
0.015
nan
0.000
-0.008
0.000
0.000
0.000
0.000
0.000
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
57 changes: 48 additions & 9 deletions data/scenes/scene#4.scn
Original file line number Diff line number Diff line change
@@ -1,9 +1,48 @@
object#7.dro
object#3.pso
object#4.pso
object#5.pso
object#6.pso
object#8.rso
object#9.rso
object#10.rso
object#11.rso
680.000 120.000
0.000
1360 240
0.5 0.5 0.5
0 0 0
0 0 0
1
0
1
1
0
0
angrybirds_ground.bmp
680.000 360.000
0.000
340 240
0.25 0.25 0.25
0 0 0
0 0 0
1
0
1
1
0
0
portals.bmp
680.000 360.000
0.000
1360 720
0 0 0
0 0 0
0 0 0
1
0
1
1
0
0
SC2background.bmp
object#16.dro
object#12.pso
object#13.pso
object#14.pso
object#15.pso
object#17.rso
object#18.rso
object#19.rso
object#20.rso
17 changes: 11 additions & 6 deletions data/settings.ini
Original file line number Diff line number Diff line change
@@ -1,28 +1,33 @@
[draggable_object]
default_height = 64
default_width = 64
default_x = 1224
default_x = 64
default_y = 503
[game]
mute_all = 1
show_background = 1
show_draggable_objects = 1
show_foreground = 1
show_info_overlay = 0
show_middleground = 1
show_physics_objects = 1
show_rts_objects = 1
show_textures = 1
[physics_object]
default_height = 32
default_width = 32
default_x = 1224
default_y = 432
default_x = 64
default_y = 431
[rts_object]
default_height = 64
default_width = 64
default_x = 1224
default_x = 64
default_y = 360
[ui]
overlay_margin = 10
[window]
height = 705
height = 720
position_x = 0
position_y = 0
refresh_rate = 60
width = 1362
width = 1360
Binary file added graphics/SC2background.bmp
Binary file not shown.
Binary file added graphics/angrybirds_ground.bmp
Binary file not shown.
Binary file modified graphics/confuzedskull.bmp
Binary file not shown.
Binary file added graphics/portals.bmp
Binary file not shown.
1 change: 1 addition & 0 deletions include/basic_object.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class basic_object
int get_height();
float get_radius();
float get_rotation();
std::string get_texture();
bool filled;//whether the body of the object is visible
bool bordered;//whether or not the object has a border
bool textured;//whether the object has a texture
Expand Down
4 changes: 3 additions & 1 deletion include/checkbox.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@

class checkbox: public button
{
protected:
private:
int checked;
public:
static std::string default_click_sound;
static std::string default_hover_sound;
int* option;
int checkmark_margin;
color checkmark_color;
Expand Down
28 changes: 19 additions & 9 deletions include/game.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,25 @@ namespace game
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
void hide_physics_objects();//hide all physics objects in current scene
void show_rts_objects();//show all rts objects in current scene
void hide_rts_objects();//hide all rts objects in current scene
void add_draggable_object();//add a draggable object to the current scene
void add_physics_object();//add a physics object to the current scene
void add_rts_object();//add an rts object to the current scene
void show_foreground();
void hide_foreground();
void show_middleground();
void hide_middleground();
void show_background();
void hide_background();
void show_draggable_objects();//show all draggable objects in play scene
void hide_draggable_objects();//hide all draggable objects in play scene
void show_physics_objects();//show all physics objects in play scene
void hide_physics_objects();//hide all physics objects in play scene
void show_rts_objects();//show all rts objects in play scene
void hide_rts_objects();//hide all rts objects in play scene
void show_textures();//show all textures
void hide_textures();//hide all textures
void mute_all();//mute all sounds
void unmute_all();//unmute all sounds
void add_draggable_object();//add a draggable object to the play scene
void add_physics_object();//add a physics object to the play scene
void add_rts_object();//add an rts object to the play 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 play scene
Expand Down
25 changes: 19 additions & 6 deletions include/scene.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,12 @@

class scene
{
private:
int number;
public:
static int total_scenes;
std::string file_name;
int number;
color background_color;
basic_object foreground, middleground, background;
basic_object* last_object;
menu* current_menu;
//maps are used because we need to access the objects by referencing a common identifier (object.number)
Expand Down Expand Up @@ -72,20 +73,32 @@ class scene
void hide_rts_objects();//hide all rts objects
void show_text();//show the text
void hide_text();//hide the text
void show_objects();//show all objects
void hide_objects();//hide all objects
void enable_objects();//enable object mouse interaction
void disable_objects();//disable object mouse interaction
void mute_objects();
void unmute_objects();
void show_checkboxes();//show all checkboxes
void hide_checkboxes();//hide all checkboxes
void enable_checkboxes();
void disable_checkboxes();
void enable_checkboxes();//enable checkbox mouse interaction
void disable_checkboxes();//disable checkbox mouse interaction
void mute_checkboxes();
void unmute_checkboxes();
void show_buttons();//show all buttons
void hide_buttons();//hide all buttons
void enable_buttons();
void disable_buttons();
void enable_buttons();//enable button mouse interaction
void disable_buttons();//disable button mouse interaction
void mute_buttons();
void unmute_buttons();
void show_menus();//show all menus
void hide_menus();//hide all menus
void enable_menus();//enable all menus
void disable_menus();//disable all menus
void mute_menus();//mute all menus
void unmute_menus();//unmute all menus
void show_textures();
void hide_textures();
void show_all();//show all objects and ui elements
void hide_all();//hide all objects and ui elements
void enable_all();//enable all ui elements
Expand Down
10 changes: 9 additions & 1 deletion src/basic_object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

//initialize static variables
int basic_object::total_objects=0;
point2i basic_object::default_position = point2i(0,0);
point2i basic_object::default_position = point2i(window::center.x,window::center.y);

int basic_object::get_number()
{
Expand Down Expand Up @@ -78,6 +78,11 @@ float basic_object::get_radius()
return utilities::distance(xmin,ymin,xmax,ymax)/2;;
}

std::string basic_object::get_texture()
{
return texture;
}

void basic_object::set_position(int x, int y)
{
position.set((float)x,(float)y);
Expand Down Expand Up @@ -243,6 +248,7 @@ basic_object::basic_object()
textured=false;
selected=false;
muted=false;
set_texture("confuzedskull.bmp");
show();
}

Expand All @@ -263,6 +269,7 @@ basic_object::basic_object(int x, int y, int w, int h)
textured=false;
selected=false;
muted=false;
set_texture("confuzedskull.bmp");
show();
}

Expand All @@ -283,6 +290,7 @@ basic_object::basic_object(int x, int y, int w, int h, color c)
textured=false;
selected=false;
muted=false;
set_texture("confuzedskull.bmp");
show();
}

Expand Down
15 changes: 9 additions & 6 deletions src/checkbox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

#include "checkbox.h"
#include "cursor.h"
#include "audio.h"
#ifdef __APPLE__
#include <OpenGL/gl.h>
#include <OpenGL/glu.h>
Expand All @@ -30,6 +31,9 @@
#endif
#include <iostream>

std::string checkbox::default_click_sound = "click.wav";
std::string checkbox::default_hover_sound = "swipe.wav";

void checkbox::set_label(std::string l)
{
text.clear();
Expand Down Expand Up @@ -59,14 +63,11 @@ void checkbox::mouse_function()
if(visible && enabled)
{
if(filled)
{
if(hovered_over() && !fill_color.changed)
fill_color.brighten();
if(!hovered_over())
fill_color.undo();
}
hover_function();
if(left_clicked())
{
if(!muted)
audio::play(click_sound);
if(*option==1)
checked=0;
else
Expand Down Expand Up @@ -111,5 +112,7 @@ checkbox::checkbox()
checked=1;
checkmark_margin=2;
checkmark_color=BLACK;
set_click_sound(default_click_sound);
set_hover_sound(default_hover_sound);
std::clog<<"object#"<<number<<"(checkbox)"<<" created. "<<sizeof(*this)<<" bytes"<<std::endl;
}
2 changes: 1 addition & 1 deletion src/draggable_object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
#include <GL/glut.h>
#endif

point2i draggable_object::default_position = point2i(window::width*0.9,window::height*0.7);
point2i draggable_object::default_position = point2i(64,window::height*0.7);
int draggable_object::default_width = 64;
int draggable_object::default_height = 64;
std::string draggable_object::default_texture = "confuzedskull.bmp";
Expand Down
1 change: 1 addition & 0 deletions src/dropdown_menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ void dropdown_menu::update()
i->visible=true;
else
i->visible=false;
i->muted=muted;
i->update();
}
mouse_function();
Expand Down
Loading

0 comments on commit 6cf6649

Please sign in to comment.