Skip to content
This repository has been archived by the owner on Feb 19, 2018. It is now read-only.

Commit

Permalink
Merge pull request #150 from demiurgosoft/development
Browse files Browse the repository at this point in the history
DCmC 1.7.5
  • Loading branch information
Andrés committed Mar 17, 2015
2 parents 710cfd6 + c5de8be commit c705093
Show file tree
Hide file tree
Showing 38 changed files with 593 additions and 130 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Don´t Crush my Castle
=====================
_Version 0.7.3 (alpha)_
_Version 0.7.5 (alpha)_

Highly customizable tower defense style game

Expand Down Expand Up @@ -43,6 +43,8 @@ TinyXML2 by Lee Thomason - https://github.com/leethomason/tinyxml2
example_clock.png (used for testing) is under CCLicense by [Jorge Durán Llanos] (https://github.com/Caesar95)
<a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/"><img alt="Licencia de Creative Commons" style="border-width:0" src="https://i.creativecommons.org/l/by-nc-sa/4.0/88x31.png" /></a>

cyberpunk_skin is under CCLicense by [terceranexus6](https://github.com/terceranexus6)

ground_tileset.png is under CCLicense by [George_](http://opengameart.org/content/old-tiles)

all enemy_0 files are part of the "Medieval fantasy character sprites" art by [Johannes Sjölund] (http://opengameart.org/content/character-animations-clothes-armor-weapons-skeleton-enemy-combat-dummy) under CCLicense
Expand Down
9 changes: 4 additions & 5 deletions include/enemy/enemy_attributes.h
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
//TITLE: ENEMY_ATTRIBUTES_H
//PROJECT: DON´T CRUSH MY CASTLE
//AUTHOR: Andrés Ortiz
//VERSION: 0.7.4
//VERSION: 0.7.5
//DESCRIPTION: defines each kind of enemy
#ifndef ENEMY_ATTRIBUTES
#define ENEMY_ATTRIBUTES

#include "game_object_attributes.h"
#include "al_anim.h"
#include <map>

const string enemy_xml_value="Enemy";
enum enemy_animation {idle_anim,up_anim,down_anim,left_anim,right_anim,dead_anim}; //defines each animation for an enemy
//defines the basic characteristics of an enemy kind
struct enemy_attributes : game_object_attributes {
struct enemy_attributes {
map<enemy_animation,al_anim> animation; //stores all animations of an enemy
string name; //name of the enemy
double speed; //basic speed (pixels per seconds)
Expand All @@ -22,12 +21,12 @@ struct enemy_attributes : game_object_attributes {
unsigned int reward; //reward when killed
//Methods
enemy_attributes();
enemy_attributes(XMLElement *enemy_root);
enemy_attributes(XMLElement *enemy_root,const ALLEGRO_TIMER *timer);
enemy_attributes(const string &name,unsigned int life,unsigned int armor,double enemy_speed,unsigned int reward=0);
enemy_attributes(const string &name,unsigned int life,unsigned int armor,double enemy_speed,const map<enemy_animation,al_anim> &animation,unsigned int reward=0);
~enemy_attributes();
bool read_xml(const XMLElement *enemy_root,const ALLEGRO_TIMER *timer);

bool read_xml(const XMLElement *enemy_root);
// bool write_xml(XMLElement *enemy_root) const;
//insert animation (erasing previous animations and reseting all counters)
void insert_animation(enemy_animation type,const al_anim &anim);
Expand Down
1 change: 0 additions & 1 deletion include/map/tile.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

#include "al_utils.h"


class tile {
public:
enum tile_type {blocked,road,ground,open_ground,special,null_tile};
Expand Down
8 changes: 7 additions & 1 deletion include/map/tileset.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,12 @@

#include "tile.h"
#include <map>
#include "tinyxml2.h"
using namespace tinyxml2;

typedef int tile_id; //defines a id for a tile in the tileset
static const tile_id null_tile_id=-1;
const string tileset_xml_value="Tileset";
class tileset {
private:
string name;
Expand All @@ -30,15 +33,17 @@ class tileset {
//contructors with one tile
tileset(const string &name,const tile &t,unsigned int tile_size);
tileset(const tile &t,unsigned int tile_size);
tileset(const XMLElement *tileset_root);
//size of tileset tiles will be tile size
tileset(const tile &t);
~tileset();
//MODIFICATION
bool read_xml(const XMLElement *tileset_root);
//adds a tile,returning tile_id used
tile_id add_tile(tile::tile_type type,const ALLEGRO_BITMAP *bitmap);
tile_id add_tile(const tile &t);
//slices given bitmap and adds tiles to the tileset, return vector of ids used
vector<tile_id> load_from_bitmap(const ALLEGRO_BITMAP *bitmap,const vector<tile::tile_type> &types,unsigned int tile_size,int ntiles);
vector<tile_id> load_from_bitmap(const ALLEGRO_BITMAP *bitmap,const vector<tile::tile_type> &types,unsigned int tile_size,int ntiles=-1);
//removes tile with given id
void remove_tile(tile_id id);
//change name
Expand Down Expand Up @@ -75,5 +80,6 @@ class tileset {
private:
//return next free id after or equal to actual lower_id
tile_id get_next_free_id() const;
vector<tile::tile_type> get_xml_types(const XMLElement *types_element);
};
#endif
12 changes: 5 additions & 7 deletions include/tower/tower_atk_attributes.h
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
//TITLE: TOWER_ATK_ATTRIBUTES_H
//PROJECT: DON´T CRUSH MY CASTLE
//AUTHOR: Andrés Ortiz
//VERSION: 0.7.4
//VERSION: 0.7.5
//DESCRIPTION: defines the kind of attack of buildings
#ifndef TOWER_ATK_ATTRIBUTES
#define TOWER_ATK_ATTRIBUTES

#include "al_anim.h"
#include "game_object_attributes.h"
enum atk_type {shoot_atk,explosion_atk,continuous_atk};

const string tower_atk_xml_value="Tower_Atk";
//defines the atributes of an attack
struct atk_attributes : game_object_attributes {
struct atk_attributes {
ALLEGRO_BITMAP *bitmap; //attack bitmap
al_anim collision_anim; //collision animation (explosion) or continuous
unsigned int damage; //damage of the attack
Expand All @@ -22,12 +21,11 @@ struct atk_attributes : game_object_attributes {
//string name ¿?
//METHODS
atk_attributes();
atk_attributes(const XMLElement *attributes_root);
atk_attributes(const XMLElement *attributes_root,const ALLEGRO_TIMER *timer);
atk_attributes(ALLEGRO_BITMAP *bitmap,al_anim collision_anim,unsigned int damage,unsigned int range,unsigned int delay,double speed,atk_type type=shoot_atk);
~atk_attributes();

bool read_xml(const XMLElement *attributes_root);
bool write_xml(XMLElement *attributes_root) const;
bool read_xml(const XMLElement *atk_root,const ALLEGRO_TIMER *timer);
//clear data (dont destroy animations)
void clear();
//destroy all bitmaps and clear data
Expand Down
14 changes: 7 additions & 7 deletions include/tower/tower_attributes.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,22 @@
#define TOWER_ATTRIBUTES_H

#include "tower_atk.h"

const string tower_xml_value="Tower";
//defines the attributes of the tower
struct tower_attributes : game_object_attributes {
struct tower_attributes {
string name;
atk_attributes atk; //attack attributes
ALLEGRO_BITMAP *bitmap; //main bitmap of the towers (static)
// ALLEGRO_BITMAP *secondary_bitmap; //secondary bitmap (rotate)
unsigned int cost;
string name;
//ALLEGRO_BITMAP *secondary_bitmap; //secondary bitmap (rotate)
//METHODS
tower_attributes();
tower_attributes(const XMLElement *attributes_root);
tower_attributes(const XMLElement *tower_root,const ALLEGRO_TIMER *timer);
tower_attributes(const string &name,ALLEGRO_BITMAP *bitmap,const atk_attributes &atk,unsigned int cost);
~tower_attributes();

bool read_xml(const XMLElement *attributes_root);
bool write_xml(XMLElement *attributes_root) const;
bool read_xml(const XMLElement *tower_root,const ALLEGRO_TIMER *timer);
// bool write_xml(XMLElement *attributes_root) const;

//return bitmap width (in pixels)
unsigned int get_width() const;
Expand Down
5 changes: 3 additions & 2 deletions include/utilities/al_anim.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include "al_utils.h"
#include "tinyxml2.h"
using namespace tinyxml2;
const string anim_xml_value="Al Animation";
const string anim_xml_value="Al_Animation";
class al_anim {
private:
vector<ALLEGRO_BITMAP *> bitmap_set;
Expand All @@ -32,8 +32,9 @@ class al_anim {
al_anim(const ALLEGRO_BITMAP *bitmap_sheet,unsigned int width,unsigned int height,double duration,const ALLEGRO_TIMER *timer);
//destructor
~al_anim();
//read data from xml file
bool read_xml(const XMLElement *animation_root,const ALLEGRO_TIMER *timer);
//MODIFICATION
bool read_xml(const XMLElement *animation_root);
//checks animation and activates it
void activate();
//checks and activates animation from the beginning (like stop+activate)
Expand Down
3 changes: 1 addition & 2 deletions include/utilities/game_object.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

#include <iostream>
#include <utility>
#include "game_object_attributes.h"
using namespace std;

class game_object {
Expand Down Expand Up @@ -44,4 +43,4 @@ class game_object {
//check game object, return true if everyting is fine
bool check() const;
};
#endif
#endif
21 changes: 0 additions & 21 deletions include/utilities/game_object_attributes.h

This file was deleted.

6 changes: 3 additions & 3 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

#FLAGS
CXX = g++
CPPFLAGS= -Wall -O1 -std=c++11 #-g
CPPFLAGS= -Wall -O1 -std=c++11#-g
ALLEGROFLAGS=-lallegro -lallegro_image -lallegro_main -lallegro_font -lallegro_ttf
#ALLEGROFLAGS2=-lallegro -lallegro_primitives -lallegro_font -lallegro_ttf -lallegro_image -lallegro_main -lallegro_acodec -lallegro_audio -lallegro_color -lallegro_dialog -lallegro_memfile -lallegro_physfs

Expand All @@ -29,7 +29,7 @@ MAINDIR=$(SDIR)/main
_INC=$(UTILSDIR) $(MAPDIR) $(ENEMYDIR) $(TOWERDIR) $(CONTROLLERDIR)
I_INC=$(patsubst %,-I %,$(_INC))

_AL_UTILS=al_anim.cpp al_utils.cpp debug_log.cpp input_handler.cpp game_object_attributes.cpp game_object.cpp text_handler.cpp tinyxml2.cpp
_AL_UTILS=al_anim.cpp al_utils.cpp debug_log.cpp input_handler.cpp game_object.cpp text_handler.cpp tinyxml2.cpp
AL_UTILS_O=$(patsubst %,$(ODIR)/%,$(_AL_UTILS:.cpp=.o))
_MAP=tile.cpp tileset.cpp tilemap.cpp
MAP_O=$(patsubst %,$(ODIR)/%,$(_MAP:.cpp=.o))
Expand All @@ -41,7 +41,7 @@ _CONTROLLER=game_objects.cpp player_controller.cpp game_master.cpp player.cpp
CONTROLLER_O=$(patsubst %,$(ODIR)/%,$(_CONTROLLER:.cpp=.o))

TEST_O=$(AL_UTILS_O) $(MAP_O) $(ENEMY_O) $(TOWER_O) $(CONTROLLER_O)
_TEST_H=test_utils.h test_anim.h test_map.h test_tower.h test_enemy.h test_controller.h
_TEST_H=test_utils.h test_anim.h test_map.h test_tower.h test_enemy.h test_controller.h test_xml.h
TEST_H=$(patsubst %,$(TESTDIR)/%,$(_TEST_H))

MAIN_O=$(AL_UTILS_O) $(MAP_O) $(ENEMY_O) $(TOWER_O) $(CONTROLLER_O) $(ODIR)/DCmC.o
Expand Down
Binary file modified resources/spr/cannonball.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/spr/ciberpunk_skin/android/dead.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/spr/ciberpunk_skin/android/down.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/spr/ciberpunk_skin/android/idle.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/spr/ciberpunk_skin/android/left.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/spr/ciberpunk_skin/android/right.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/spr/ciberpunk_skin/android/up.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/spr/ciberpunk_skin/turret/deathray.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/spr/ciberpunk_skin/turret/turret.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions resources/xml/animation_test.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<Al_Animation Version="0.7.4" loop="false">
<Width>64</Width>
<Height>64</Height>
<Duration>2</Duration>
<Bitmap_Sheet>resources/spr/enemy_0/dead.png</Bitmap_Sheet>
</Al_Animation>
14 changes: 14 additions & 0 deletions resources/xml/atk_test.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<Tower_Atk Version="0.7.4">
<Damage>60</Damage>
<Range>90</Range>
<Delay>2</Delay>
<Speed>5</Speed>
<Type>Shoot</Type>
<Sprite>resources/spr/cannonball.png</Sprite>
<Al_Animation Version="0.7.4" loop="false">
<Width>64</Width>
<Height>64</Height>
<Duration>0.5</Duration>
<Bitmap_Sheet>resources/spr/explosion.png</Bitmap_Sheet>
</Al_Animation>
</Tower_Atk>
43 changes: 43 additions & 0 deletions resources/xml/default/enemy.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<Enemy Version="0.7.4">
<Name>Enemy_0</Name>
<Life>100</Life>
<Armor>1</Armor>
<Speed>50</Speed>
<Reward>20</Reward>
<Al_Animation Version="0.7.4" loop="false" type="dead">
<Width>64</Width>
<Height>64</Height>
<Duration>2</Duration>
<Bitmap_Sheet>resources/spr/enemy_0/dead.png</Bitmap_Sheet>
</Al_Animation>
<Al_Animation Version="0.7.4" loop="true" type="down">
<Width>64</Width>
<Height>64</Height>
<Duration>3</Duration>
<Bitmap_Sheet>resources/spr/enemy_0/down.png</Bitmap_Sheet>
</Al_Animation>
<Al_Animation Version="0.7.4" loop="true" type="up">
<Width>64</Width>
<Height>64</Height>
<Duration>3</Duration>
<Bitmap_Sheet>resources/spr/enemy_0/up.png</Bitmap_Sheet>
</Al_Animation>
<Al_Animation Version="0.7.4" loop="true" type="idle">
<Width>64</Width>
<Height>64</Height>
<Duration>3</Duration>
<Bitmap_Sheet>resources/spr/enemy_0/idle.png</Bitmap_Sheet>
</Al_Animation>
<Al_Animation Version="0.7.4" loop="true" type="left">
<Width>64</Width>
<Height>64</Height>
<Duration>3</Duration>
<Bitmap_Sheet>resources/spr/enemy_0/left.png</Bitmap_Sheet>
</Al_Animation>
<Al_Animation Version="0.7.4" loop="true" type="right">
<Width>64</Width>
<Height>64</Height>
<Duration>3</Duration>
<Bitmap_Sheet>resources/spr/enemy_0/right.png</Bitmap_Sheet>
</Al_Animation>
</Enemy>
10 changes: 10 additions & 0 deletions resources/xml/default/tileset.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<Tileset Version="0.7.5" Number="3" Resize="false">
<Name>Tileset 0</Name>
<Size>32</Size>
<Bitmap>resources/spr/ground_tileset_reduced.png</Bitmap>
<Tile_Types>
<Type>road</Type>
<Type>ground</Type>
<Type>blocked</Type>
</Tile_Types>
</Tileset>
19 changes: 19 additions & 0 deletions resources/xml/default/tower.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<Tower Version="0.7.5">
<Name>Tower 0</Name>
<Sprite>resources/spr/tower_cartoon.png</Sprite>
<Cost>50</Cost>
<Tower_Atk Version="0.7.4">
<Damage>60</Damage>
<Range>90</Range>
<Delay>2</Delay>
<Speed>5</Speed>
<Type>Shoot</Type>
<Sprite>resources/spr/cannonball.png</Sprite>
<Al_Animation Version="0.7.4" loop="false">
<Width>64</Width>
<Height>64</Height>
<Duration>0.5</Duration>
<Bitmap_Sheet>resources/spr/explosion.png</Bitmap_Sheet>
</Al_Animation>
</Tower_Atk>
</Tower>
43 changes: 43 additions & 0 deletions resources/xml/enemy_test.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<Enemy Version="0.7.4">
<Name>Enemy_0</Name>
<Life>100</Life>
<Armor>1</Armor>
<Speed>50</Speed>
<Reward>20</Reward>
<Al_Animation Version="0.7.4" loop="false" type="dead">
<Width>64</Width>
<Height>64</Height>
<Duration>2</Duration>
<Bitmap_Sheet>resources/spr/enemy_0/dead.png</Bitmap_Sheet>
</Al_Animation>
<Al_Animation Version="0.7.4" loop="false" type="down">
<Width>64</Width>
<Height>64</Height>
<Duration>3</Duration>
<Bitmap_Sheet>resources/spr/enemy_0/down.png</Bitmap_Sheet>
</Al_Animation>
<Al_Animation Version="0.7.4" loop="false" type="up">
<Width>64</Width>
<Height>64</Height>
<Duration>3</Duration>
<Bitmap_Sheet>resources/spr/enemy_0/up.png</Bitmap_Sheet>
</Al_Animation>
<Al_Animation Version="0.7.4" loop="false" type="idle">
<Width>64</Width>
<Height>64</Height>
<Duration>3</Duration>
<Bitmap_Sheet>resources/spr/enemy_0/idle.png</Bitmap_Sheet>
</Al_Animation>
<Al_Animation Version="0.7.4" loop="false" type="left">
<Width>64</Width>
<Height>64</Height>
<Duration>3</Duration>
<Bitmap_Sheet>resources/spr/enemy_0/left.png</Bitmap_Sheet>
</Al_Animation>
<Al_Animation Version="0.7.4" loop="false" type="right">
<Width>64</Width>
<Height>64</Height>
<Duration>3</Duration>
<Bitmap_Sheet>resources/spr/enemy_0/right.png</Bitmap_Sheet>
</Al_Animation>
</Enemy>
Loading

0 comments on commit c705093

Please sign in to comment.