Permalink
Browse files

wtfpl public license

  • Loading branch information...
1 parent 4c53809 commit cf03aca5f289c1a6195bff652299d205458dabd6 Dmytro Lytovchenko committed Oct 1, 2011
Showing with 1,129 additions and 1,011 deletions.
  1. +6 −0 CMakeLists.txt
  2. +16 −0 LICENSE.txt
  3. +28 −22 src/creature.cpp
  4. +16 −10 src/creature.h
  5. +80 −74 src/game.cpp
  6. +36 −30 src/game.h
  7. +208 −202 src/game_state.cpp
  8. +92 −86 src/game_state.h
  9. +6 −0 src/menuitem.cpp
  10. +6 −0 src/menuitem.h
  11. +243 −237 src/player.cpp
  12. +66 −60 src/player.h
  13. +6 −0 src/projectile.cpp
  14. +6 −0 src/projectile.h
  15. +35 −29 src/sprite_manager.cpp
  16. +13 −7 src/sprite_manager.h
  17. +149 −143 src/world.cpp
  18. +117 −111 src/world.h
View
@@ -3,6 +3,12 @@
# This is minimal game skeleton in HGE based on HGE_TUTORIAL 06
# to adapt this to your new game, search and replace HGESKEL with your project name
#
+# This program is free software. It comes without any warranty, to
+# the extent permitted by applicable law. You can redistribute it
+# and/or modify it under the terms of the Do What The Fuck You Want
+# To Public License, Version 2, as published by Sam Hocevar. See
+# http://sam.zoy.org/wtfpl/COPYING for more details.
+#
#-----------------------------------------------------------------------
project( HGESKEL )
cmake_minimum_required( VERSION 2.8 )
View
@@ -0,0 +1,16 @@
+http://sam.zoy.org/wtfpl/COPYING
+
+ DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
+ Version 2, December 2004
+
+ Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
+
+ Everyone is permitted to copy and distribute verbatim or modified
+ copies of this license document, and changing it is allowed as long
+ as the name is changed.
+
+ DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. You just DO WHAT THE FUCK YOU WANT TO.
+
View
@@ -1,3 +1,9 @@
+/* This program is free software. It comes without any warranty, to
+ * the extent permitted by applicable law. You can redistribute it
+ * and/or modify it under the terms of the Do What The Fuck You Want
+ * To Public License, Version 2, as published by Sam Hocevar. See
+ * http://sam.zoy.org/wtfpl/COPYING for more details.
+ */
// base Creature class
// represents a walking or stationary creature which is able to kill player
// on touch.
@@ -9,44 +15,44 @@
WorldObject::WorldObject( World * owner, float x, float y ): m_world(owner)
{
- m_box.Set( x, y, x + World::CELL_BOX_SIZE - 1.0f, y + World::CELL_BOX_SIZE - 1.0f );
+ m_box.Set( x, y, x + World::CELL_BOX_SIZE - 1.0f, y + World::CELL_BOX_SIZE - 1.0f );
}
void WorldObject::Render()
{
- hgeSprite * spr = GetSprite();
- if( ! spr ) return; // can't draw a NULL sprite
-
- hgeRect box( m_box.x1 - m_world->m_camera_pos.x,
- m_box.y1 - m_world->m_camera_pos.y,
- m_box.x2 - m_world->m_camera_pos.x,
- m_box.y2 - m_world->m_camera_pos.y );
-
- spr->Render4V( box.x1, box.y1,
- box.x2, box.y1,
- box.x2, box.y2,
- box.x1, box.y2 );
+ hgeSprite * spr = GetSprite();
+ if( ! spr ) return; // can't draw a NULL sprite
+
+ hgeRect box( m_box.x1 - m_world->m_camera_pos.x,
+ m_box.y1 - m_world->m_camera_pos.y,
+ m_box.x2 - m_world->m_camera_pos.x,
+ m_box.y2 - m_world->m_camera_pos.y );
+
+ spr->Render4V( box.x1, box.y1,
+ box.x2, box.y1,
+ box.x2, box.y2,
+ box.x1, box.y2 );
}
WorldObject_Money::WorldObject_Money( World * owner, float x, float y ) : WorldObject( owner, x, y )
{
- m_sprite[0] = owner->m_sprite_manager.GetSprite( "textures/coin1.png" );
- m_sprite[1] = owner->m_sprite_manager.GetSprite( "textures/coin2.png" );
+ m_sprite[0] = owner->m_sprite_manager.GetSprite( "textures/coin1.png" );
+ m_sprite[1] = owner->m_sprite_manager.GetSprite( "textures/coin2.png" );
}
WorldObject_Money::~WorldObject_Money()
{
- delete m_sprite[0];
- delete m_sprite[1];
+ delete m_sprite[0];
+ delete m_sprite[1];
}
hgeSprite * WorldObject_Money::GetSprite()
{
- uint32_t milliseconds = GetTickCount();
- // we want frames to change every 250 msec from 0 to 1
- // total of 2 frames, hence the modulo of 2
- uint32_t f = (milliseconds / 250) % 2;
+ uint32_t milliseconds = GetTickCount();
+ // we want frames to change every 250 msec from 0 to 1
+ // total of 2 frames, hence the modulo of 2
+ uint32_t f = (milliseconds / 250) % 2;
- return m_sprite[f];
+ return m_sprite[f];
}
View
@@ -1,3 +1,9 @@
+/* This program is free software. It comes without any warranty, to
+ * the extent permitted by applicable law. You can redistribute it
+ * and/or modify it under the terms of the Do What The Fuck You Want
+ * To Public License, Version 2, as published by Sam Hocevar. See
+ * http://sam.zoy.org/wtfpl/COPYING for more details.
+ */
// to prevent multiple compiling of this header
#pragma once
@@ -16,29 +22,29 @@ class World;
class WorldObject
{
protected:
- World * m_world;
+ World * m_world;
public:
- hgeRect m_box;
+ hgeRect m_box;
- WorldObject( World * owner, float x, float y );
- virtual ~WorldObject() {}
+ WorldObject( World * owner, float x, float y );
+ virtual ~WorldObject() {}
- virtual hgeSprite * GetSprite() { return NULL; }
- void Render();
+ virtual hgeSprite * GetSprite() { return NULL; }
+ void Render();
};
class WorldObject_Money: public virtual WorldObject
{
protected:
- hgeSprite * m_sprite[2];
+ hgeSprite * m_sprite[2];
public:
- WorldObject_Money(World * owner, float x, float y );
- virtual ~WorldObject_Money();
+ WorldObject_Money(World * owner, float x, float y );
+ virtual ~WorldObject_Money();
- virtual hgeSprite * GetSprite();
+ virtual hgeSprite * GetSprite();
};
View
@@ -1,3 +1,9 @@
+/* This program is free software. It comes without any warranty, to
+ * the extent permitted by applicable law. You can redistribute it
+ * and/or modify it under the terms of the Do What The Fuck You Want
+ * To Public License, Version 2, as published by Sam Hocevar. See
+ * http://sam.zoy.org/wtfpl/COPYING for more details.
+ */
/*
** Based on: hge_tut06 - Creating menus
** Haaf's Game Engine 1.8 -- Copyright (C) 2003-2007, Relish Games http://hge.relishgames.com
@@ -18,60 +24,60 @@ MyGame * MyGame::m_game = NULL;
MyGame::MyGame()
- : m_hge(NULL), m_font(NULL), m_mouse_cursor_sprite(NULL), m_state(NULL)
- , m_sound_enabled(true)
+ : m_hge(NULL), m_font(NULL), m_mouse_cursor_sprite(NULL), m_state(NULL)
+ , m_sound_enabled(true)
{
- // remember pointer to 'this' in globally visible variable so that everyone
- // else can reach it (not very good example of software design, but this simplifies a lot)
- m_game = this;
+ // remember pointer to 'this' in globally visible variable so that everyone
+ // else can reach it (not very good example of software design, but this simplifies a lot)
+ m_game = this;
- // do nothing else here, unless it can run before HGE is started
+ // do nothing else here, unless it can run before HGE is started
}
bool MyGame::FrameFunc()
{
- // passing control to the current game state, so that game reacts to events
- // differently in different states
- return m_game->m_state->Think( m_game );
- // do not add more code here, all the action happens in GameState's child classes
+ // passing control to the current game state, so that game reacts to events
+ // differently in different states
+ return m_game->m_state->Think( m_game );
+ // do not add more code here, all the action happens in GameState's child classes
}
bool MyGame::RenderFunc()
{
- // letting the current game state to take care of rendering (different render for
- // main menu, for game, and for game over screen)
- m_game->m_hge->Gfx_BeginScene();
-
- m_game->m_state->Render( m_game );
-
- // Draw framerate and time since previous frame
- char fps_text[64]; // some safer length so FPS text will fit
- _snprintf( fps_text, sizeof(fps_text)-1,
- "dt:%.3f\nFPS:%d",
- m_game->m_hge->Timer_GetDelta(), m_game->m_hge->Timer_GetFPS()
- );
-
- // print with black shadow
- m_game->m_font->SetColor(ARGB(255,0,0,0)); // black
- m_game->m_font->printf( 7, 7, HGETEXT_LEFT, fps_text );
- m_game->m_font->SetColor(ARGB(255,255,255,255)); // white
- m_game->m_font->printf( 5, 5, HGETEXT_LEFT, fps_text );
+ // letting the current game state to take care of rendering (different render for
+ // main menu, for game, and for game over screen)
+ m_game->m_hge->Gfx_BeginScene();
+
+ m_game->m_state->Render( m_game );
+
+ // Draw framerate and time since previous frame
+ char fps_text[64]; // some safer length so FPS text will fit
+ _snprintf( fps_text, sizeof(fps_text)-1,
+ "dt:%.3f\nFPS:%d",
+ m_game->m_hge->Timer_GetDelta(), m_game->m_hge->Timer_GetFPS()
+ );
+
+ // print with black shadow
+ m_game->m_font->SetColor(ARGB(255,0,0,0)); // black
+ m_game->m_font->printf( 7, 7, HGETEXT_LEFT, fps_text );
+ m_game->m_font->SetColor(ARGB(255,255,255,255)); // white
+ m_game->m_font->printf( 5, 5, HGETEXT_LEFT, fps_text );
- m_game->m_hge->Gfx_EndScene();
+ m_game->m_hge->Gfx_EndScene();
- // do not add more code here, all the action happens in GameState's child classes
- return false;
+ // do not add more code here, all the action happens in GameState's child classes
+ return false;
}
bool MyGame::Startup()
{
m_hge = hgeCreate(HGE_VERSION);
- m_hge->System_SetState(HGE_SHOWSPLASH, false);
- m_hge->System_SetState(HGE_FPS, 60);
+ m_hge->System_SetState(HGE_SHOWSPLASH, false);
+ m_hge->System_SetState(HGE_FPS, 60);
m_hge->System_SetState(HGE_LOGFILE, "hgeskel.log");
m_hge->System_SetState(HGE_FRAMEFUNC, FrameFunc);
@@ -110,85 +116,85 @@ bool MyGame::Startup()
m_background_quad.v[i].col=ARGB(0xFF, 0xFF, 0xFF, 0xFF);
}
- m_background_quad.v[0].x=0;
- m_background_quad.v[0].y=0;
+ m_background_quad.v[0].x=0;
+ m_background_quad.v[0].y=0;
- m_background_quad.v[1].x=800;
- m_background_quad.v[1].y=0;
+ m_background_quad.v[1].x=800;
+ m_background_quad.v[1].y=0;
- m_background_quad.v[2].x=800;
- m_background_quad.v[2].y=600;
+ m_background_quad.v[2].x=800;
+ m_background_quad.v[2].y=600;
- m_background_quad.v[3].x=0;
- m_background_quad.v[3].y=600;
+ m_background_quad.v[3].x=0;
+ m_background_quad.v[3].y=600;
- // Load the font, create the cursor sprite
- m_font = new hgeFont("font1.fnt");
- m_mouse_cursor_sprite = new hgeSprite(m_mouse_cursor_tex,0,0,32,32);
+ // Load the font, create the cursor sprite
+ m_font = new hgeFont("font1.fnt");
+ m_mouse_cursor_sprite = new hgeSprite(m_mouse_cursor_tex,0,0,32,32);
- m_state_options = new GameState_Options( this );
- m_state_mainmenu = new GameState_MainMenu( this );
- m_state_instructions = new GameState_Instructions( this );
- m_state_credits = new GameState_Credits( this );
- m_state_play = new GameState_Play();
+ m_state_options = new GameState_Options( this );
+ m_state_mainmenu = new GameState_MainMenu( this );
+ m_state_instructions = new GameState_Instructions( this );
+ m_state_credits = new GameState_Credits( this );
+ m_state_play = new GameState_Play();
- ShowMainMenuScreen();
+ ShowMainMenuScreen();
- return true; // all is fine
+ return true; // all is fine
}
void MyGame::Shutdown()
{
- delete m_state_options;
- delete m_state_mainmenu;
- delete m_state_instructions;
- delete m_state_credits;
- delete m_state_play;
-
- // Delete created objects and free loaded resources
- delete m_font;
- delete m_mouse_cursor_sprite;
-
- m_hge->Effect_Free(m_click_sound);
- m_hge->Texture_Free(m_mouse_cursor_tex);
- m_hge->Texture_Free(m_background_quad.tex);
-
- // Clean up and shutdown
- m_hge->System_Shutdown();
- m_hge->Release();
+ delete m_state_options;
+ delete m_state_mainmenu;
+ delete m_state_instructions;
+ delete m_state_credits;
+ delete m_state_play;
+
+ // Delete created objects and free loaded resources
+ delete m_font;
+ delete m_mouse_cursor_sprite;
+
+ m_hge->Effect_Free(m_click_sound);
+ m_hge->Texture_Free(m_mouse_cursor_tex);
+ m_hge->Texture_Free(m_background_quad.tex);
+
+ // Clean up and shutdown
+ m_hge->System_Shutdown();
+ m_hge->Release();
}
void MyGame::ShowMainMenuScreen()
{
- m_state = m_state_mainmenu;
+ m_state = m_state_mainmenu;
}
void MyGame::ShowOptionsScreen()
{
- m_state = m_state_options;
+ m_state = m_state_options;
}
void MyGame::ShowInstructionsScreen()
{
- m_state = m_state_instructions;
+ m_state = m_state_instructions;
}
void MyGame::ShowCreditsScreen()
{
- m_state = m_state_credits;
+ m_state = m_state_credits;
}
void MyGame::ShowPlayScreen()
{
- m_state = m_state_play;
- m_state_play->OnEnterState( this );
+ m_state = m_state_play;
+ m_state_play->OnEnterState( this );
}
Oops, something went wrong.

0 comments on commit cf03aca

Please sign in to comment.