├── AEImageEditor ├── AsciiEngineArtEditor.exe └── README.txt ├── AsciiEngine ├── Action.h ├── ActionList.c ├── ActionList.h ├── ActionListComponent.h ├── Animation.c ├── Animation.h ├── ArtAssets │ ├── BlankBackground.AEArt │ ├── BlockThing.AEArt │ ├── BlueSquare.AEArt │ ├── CloudBG.AEArt │ ├── ItemParticle.AEArt │ ├── Lexis.AEArt │ ├── Man.AEArt │ ├── ManJump.AEArt │ ├── ManJumpFlipX.AEArt │ ├── ManRun1.AEArt │ ├── ManRun1FlipX.AEArt │ ├── ManRun2.AEArt │ ├── ManRun2FlipX.AEArt │ ├── ManRun3.AEArt │ ├── ManRun3FlipX.AEArt │ ├── ManRun4.AEArt │ ├── ManRun4FlipX.AEArt │ ├── ManRun5.AEArt │ ├── ManRun5FlipX.AEArt │ ├── ManRun6.AEArt │ ├── ManRun6FlipX.AEArt │ ├── ManSwing1.AEArt │ ├── ManSwing1FlipX.AEArt │ ├── ManSwing2.AEArt │ ├── ManSwing2FlipX.AEArt │ ├── ManSwing3.AEArt │ ├── ManSwing3FlipX.AEArt │ ├── ManSwing4.AEArt │ ├── ManSwing4FlipX.AEArt │ ├── ManSwing5.AEArt │ ├── ManSwing5FlipX.AEArt │ ├── ManSwing6.AEArt │ ├── ManSwing6FlipX.AEArt │ ├── ManSwing7.AEArt │ ├── ManSwing7FlipX.AEArt │ ├── MapEditorMockup.AEArt │ ├── SimpleEnemy.AEArt │ ├── SmallInventoryBack.AEArt │ ├── TestDamage.AEArt │ ├── Tile.AEArt │ ├── WalkingArtCollection.AEArt │ ├── WeaponMan.AEArt │ ├── WeaponManFlipX.AEArt │ └── WhiteSquare.AEArt ├── AsciiEngine.sln ├── AsciiGame.vcxproj ├── AsciiGame.vcxproj.filters ├── AsciiGame.vcxproj.user ├── BrainComponent.h ├── Button.c ├── Button.h ├── Camera.c ├── Camera.h ├── Cloud.c ├── Cloud.h ├── CollisionComponent.h ├── Component.c ├── Component.h ├── ConsoleFuncs.c ├── ConsoleFuncs.h ├── DamageDealer.c ├── DamageDealer.h ├── DamageText.c ├── DamageText.h ├── Entity.c ├── Entity.h ├── EntityCreator.h ├── EntityCreatorTable.c ├── EntityCreatorTable.h ├── EntityFactory.c ├── EntityFactory.h ├── EntityManager.c ├── EntityManager.h ├── FrameRateController.c ├── FrameRateController.h ├── GameStateList.h ├── GameStateManager.c ├── GameStateManager.h ├── GlobalDefines.h ├── Graphics.c ├── Graphics.h ├── GraphicsComponent.h ├── HashTable.h ├── Hero.c ├── Hero.h ├── Hitpoints.c ├── Hitpoints.h ├── HitpointsComponent.h ├── ImageTable.c ├── ImageTable.h ├── Input.c ├── Input.h ├── InventoryComponent.h ├── Item.c ├── Item.h ├── ItemList.h ├── ItemParticle.c ├── ItemParticle.h ├── JumperLittle.c ├── JumperLittle.h ├── LinkedList.h ├── Loci.c ├── Loci.h ├── Main.c ├── MapAssets │ ├── MapEditorSave.txt │ ├── TEST_MAP.txt │ ├── TestLevel.txt │ ├── test.txt │ └── test2.txt ├── MapEditor.c ├── MapEditor.h ├── Math2D.c ├── Math2D.h ├── Message.h ├── OpenFile.c ├── OpenFile.h ├── Physics.c ├── Physics.h ├── PhysicsComponent.h ├── Player.c ├── Player.h ├── PlayerComponent.h ├── Point.c ├── Point.h ├── Position.c ├── Position.h ├── PositionComponent.h ├── Properties.h ├── Random.c ├── Random.h ├── Registration.c ├── Registration.h ├── Release │ ├── AsciiEngine.exe │ └── README.txt ├── Serialize.c ├── Serialize.h ├── Shapes.h ├── SimpleEnemy.c ├── SimpleEnemy.h ├── SmallInventory.c ├── SmallInventory.h ├── Sprite.c ├── Sprite.h ├── Square.c ├── Square.h ├── StaticBackground.c ├── StaticBackground.h ├── StringHash.c ├── StringHash.h ├── TestLevel.c ├── TestLevel.h ├── TestLevel2.c ├── TestLevel2.h ├── Tile.c ├── Tile.h ├── TileMap.c ├── TileMap.h ├── Vector2D.c └── Vector2D.h ├── CHANGELOG.txt ├── LICENSE.txt └── README.txt /AEImageEditor/AsciiEngineArtEditor.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RandyGaul/AsciiEngine/ffd4766e0f81c5b2efa347484585d09a6e4d2b26/AEImageEditor/AsciiEngineArtEditor.exe -------------------------------------------------------------------------------- /AEImageEditor/README.txt: -------------------------------------------------------------------------------- 1 | Ascii Engine Image Editor! 2 | 3 | This program can create images in ascii art quickly and easily. Art files created with this image editor are in the format .AEArt and can be loaded by AsciiEngine with the LoadAllArtAssets function (which loads all .AEArt files within a given directory). In order to draw an image within AsciiEngine loaded by LoadAllArtAssets simply call WriteImageToScreen and supply the file name of the image! 4 | 5 | HOW TO USE: 6 | You must select a forground color, background color, and character to begin drawing. Simply left or right click on the draw area to start. 7 | 8 | HOW TO COPY/PASTE: 9 | 1. Click on the button that says "Copy" at the bottom left. 10 | 2. Draw a square around whatever you want to copy in the draw area. 11 | 3. Once you draw your square, release your mouse button. This copies your selection to a temporary buffer. You are now automatically in "Paste" mode, as denoted by the little cursor in front of "Paste" at the bottom right. 12 | 4. Simply click on the draw area to paste your copied selection. 13 | 5. Click on "Draw" to draw with your cursor once again, or "Copy" to start a new copy selection. 14 | 15 | HOW TO SAVE AN IMAGE: 16 | Click on save. 17 | 18 | HOW TO OPEN AN IMAGE: 19 | Click on open. 20 | 21 | Other features: 22 | -You can hit ctrl + left click in the draw area to copy a specific tile to your cursor settings. 23 | -The "invisible" character, or transparency, as far as AsciiEngine is concerned, is character 255. To use this character click on the bottom right corner of the 16 x 16 array of selectio characters. It is a small black square. Paste this and it will be transparent in your image where you paint this character. -------------------------------------------------------------------------------- /AsciiEngine/Action.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////// 2 | // Copyright (c) 2012 ICRL 3 | // See the file LICENSE.txt for copying permission. 4 | // 5 | // Original Author: Randy Gaul 6 | // Date: 7/16/2012 7 | // Contact: r.gaul@digipen.edu 8 | //////////////////////////////////////////////////// 9 | 10 | #ifndef ACTIONH 11 | #define ACTIONH 12 | 13 | #include "GlobalDefines.h" 14 | 15 | typedef enum _ACTION_TYPE 16 | { 17 | AT_BLOCKING, 18 | AT_NOT_BLOCKING, 19 | AT_DRAW, 20 | AT_DESTROY, 21 | } AT; 22 | 23 | typedef struct _ACTION 24 | { 25 | AT type; 26 | AT isBlocking; 27 | void *PARAM; 28 | struct _ACTION *next; 29 | struct _ACTION *prev; 30 | } ACTION; 31 | 32 | #endif ACTIONH -------------------------------------------------------------------------------- /AsciiEngine/ActionList.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////// 2 | // Copyright (c) 2012 ICRL 3 | // See the file LICENSE.txt for copying permission. 4 | // 5 | // Original Author: Randy Gaul 6 | // Date: 7/21/2012 7 | // Contact: r.gaul@digipen.edu 8 | //////////////////////////////////////////////////// 9 | 10 | #pragma once 11 | 12 | #include "ActionListComponent.h" 13 | 14 | #define BLOCKING 0x00000001 15 | 16 | typedef enum ACTION_LIST_ACTION_TYPE 17 | { 18 | ALT_PAUSE, 19 | ALT_DESTROY, 20 | ALT_SET_PROPERTIES, 21 | ALT_CREATE_ENTITY, 22 | ALT_SET_VEL, 23 | } ALT; 24 | 25 | typedef struct ACTION_LIST_DATA 26 | { 27 | float dt; // Starting time 28 | float timerEnd; // End time 29 | int flag; // Multi-purpose flags 30 | int var1; // General data 31 | int var2; // General data 32 | int var3; // General data 33 | ALT ID; // Type of action 34 | } ALD; 35 | 36 | struct _ACTION_LIST_COMPONENT; 37 | 38 | typedef struct _AL_NODE 39 | { 40 | ALT ID; // Type of action 41 | float dt; // Used to store accumulated time 42 | float timerEnd; // Used to compare with dt 43 | int flag; // Bitfield for flags : SEE TOP OF FILE FOR DEFINES 44 | int var1; // General purpose data 45 | int var2; // General purpose data 46 | int var3; // General purpose data 47 | struct _ACTION_LIST *ownerComp; // Pointer to the owner component 48 | void (*Update)( struct _AL_NODE *self, float * ); // Update function for this action 49 | struct _AL_NODE *next; // Pointer to next in list 50 | struct _AL_NODE *prev; // Pointer to the previous in list 51 | } AL_NODE; 52 | 53 | typedef struct _ACTION_LIST 54 | { 55 | ACTIONLIST_COMPONENT base; 56 | AL_NODE *actionList; 57 | } AL; 58 | 59 | // 60 | // ClassCOM_PROC 61 | // Purpose: Component procedure for this component type. Dispatches messages 62 | // recieved in the appropriate manner. 63 | // 64 | void ActionListCOM_PROC( AL *self, EM msg, int var1, int var2 ); 65 | 66 | // 67 | // ClassCreate 68 | // Purpose: Acts as a constructor for this class. Initializes the 69 | // data and dynamically allocates any extra space needed, and 70 | // initializes the allocated space with data. 71 | // 72 | void ActionListCreate( AL *self ); 73 | 74 | // 75 | // ActionListRemoveAction 76 | // Purpose: Removes a specific action from an actionList. 77 | // 78 | void ActionListRemoveAction( AL_NODE *self ); 79 | 80 | // 81 | // ActionListDestroy 82 | // Purpose: Frees an action list's actions. 83 | // 84 | void ActionListDestroy( AL *self ); 85 | 86 | // 87 | // ClassInit 88 | // Purpose: One-time initialization of the class. Use this function to load resources from disk, 89 | // set up static class variables, or anything else. 90 | // 91 | void ActionListInit( const char *className ); 92 | 93 | 94 | // 95 | // ActionListUpdate 96 | // Purpose: Updates the action list. 97 | // 98 | void ActionListUpdate( AL *self, float *dt ); 99 | 100 | // 101 | // ActionListAddAction 102 | // Purpose: Adds a specific action and allows customized flag to be set, to an actionList 103 | // on a game object. 104 | // 105 | void ActionListAddAction( AL *self, ALD *data ); 106 | 107 | // 108 | // ActionListPause 109 | // Purpose: Creates a blocking pause for an amount of seconds. 110 | // 111 | void ActionListPause( AL_NODE *self, float *dt ); 112 | 113 | // 114 | // ActionListSetProperties 115 | // Purpose: Sets the properties of an entity to the flags data member with |=. 116 | // 117 | void ActionListSetProperties( AL_NODE *self, float *dt ); 118 | 119 | // 120 | // ActionListDestroySelf 121 | // Purpose: Sends an EM_DESTROY message to the owner entity. 122 | // 123 | void ActionListDestroySelf( AL_NODE *self, float *dt ); 124 | 125 | // 126 | // ActionListCreateEntity 127 | // Purpose: Creates an entity. 128 | // 129 | void ActionListCreateEntity( AL_NODE *self, float *dt ); 130 | 131 | // 132 | // ActionListSetVel 133 | // Purpose: Sets the velocity of an object to var1 134 | // 135 | void ActionListSetVel( AL_NODE *self, float *dt ); 136 | -------------------------------------------------------------------------------- /AsciiEngine/ActionListComponent.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////// 2 | // Copyright (c) 2012 ICRL 3 | // See the file LICENSE.txt for copying permission. 4 | // 5 | // Original Author: Randy Gaul 6 | // Date: 7/21/2012 7 | // Contact: r.gaul@digipen.edu 8 | //////////////////////////////////////////////////// 9 | 10 | #pragma once 11 | 12 | #include "Message.h" 13 | 14 | // Forward decl 15 | struct _ENTITY; 16 | 17 | // 18 | // Common interface for all graphics components. 19 | // 20 | typedef struct _ACIONTLIST_COMPONENT 21 | { 22 | const char *CLASS_NAME; 23 | void (*COM_PROC)( struct _ACIONTLIST_COMPONENT *self, EM msg, int var1, int var2 ); 24 | struct _ENTITY *owner; 25 | } ACTIONLIST_COMPONENT; -------------------------------------------------------------------------------- /AsciiEngine/Animation.c: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////// 2 | // Copyright (c) 2012 ICRL 3 | // See the file LICENSE.txt for copying permission. 4 | // 5 | // Original Author: Randy Gaul 6 | // Date: 7/19/2012 7 | // Contact: r.gaul@digipen.edu 8 | //////////////////////////////////////////////////// 9 | 10 | #include "Animation.h" 11 | #include "EntityManager.h" 12 | #include "Camera.h" 13 | 14 | // Static class variables and data 15 | static const char *CLASS_NAME = NULL; 16 | 17 | // 18 | // ClassCOM_PROC 19 | // Purpose: Component procedure for this component type. Dispatches messages 20 | // recieved in the appropriate manner. 21 | // 22 | void AnimationCOM_PROC( ANI *self, EM msg, int var1, int var2 ) 23 | { 24 | // GENERAL 25 | switch(msg) 26 | { 27 | case EM_CLSINIT: 28 | AnimationInit( (const char *)var1 ); 29 | break; 30 | case EM_CREATE: 31 | AnimationCreate( self, (ANIMATION *)var1 ); 32 | break; 33 | case EM_DRAW: 34 | AnimationDraw( self ); 35 | break; 36 | case EM_UPDATE: 37 | AnimationUpdate( self, (float *)var1 ); 38 | break; 39 | 40 | // DATA ACCESS 41 | case EM_GETPLAYC: 42 | AnimationGetPlayCount( self, (int *)var1 ); 43 | break; 44 | case EM_SETPLAYC: 45 | AnimationSetPlayCount( self, (int *)var1 ); 46 | break; 47 | case EM_GETFRAME: 48 | AnimationGetCurrentFrame( self, (int *)var1 ); 49 | break; 50 | case EM_SETFRAME: 51 | AnimationSetCurrentFrame( self, (int *)var1 ); 52 | break; 53 | case EM_GETFRAMD: 54 | AnimationGetFrameDelay( self, (float *)var1 ); 55 | break; 56 | case EM_SETFRAMD: 57 | AnimationSetFrameDelay( self, (float *)var1 ); 58 | break; 59 | case EM_GETISPAS: 60 | AnimationGetIsPaused( self, (BOOL *)var1 ); 61 | break; 62 | case EM_SETISPAS: 63 | AnimationSetIsPaused( self, (BOOL *)var1 ); 64 | break; 65 | } 66 | } 67 | 68 | // 69 | // ClassCreate 70 | // Purpose: Acts as a constructor for this class. Initializes the 71 | // data and dynamically allocates any extra space needed, and 72 | // initializes the allocated space with data. 73 | // 74 | void AnimationCreate( ANI *self, ANIMATION *animation ) 75 | { 76 | self->animation = animation; 77 | } 78 | 79 | // 80 | // ClassInit 81 | // Purpose: One-time initialization of the class. Use this function to load resources from disk, 82 | // set up static class variables, or anything else. 83 | // 84 | void AnimationInit( const char *className ) 85 | { 86 | CLASS_NAME = (const char *)malloc( strlen( className ) + 1 ); 87 | strcpy_s( (char *)CLASS_NAME, strlen( className ) + 1 , className ); 88 | } 89 | 90 | // 91 | // ComponentDraw 92 | // Purpose: Simply renders the animation. 93 | // 94 | void AnimationDraw( ANI *self ) 95 | { 96 | float x, y; 97 | VECTOR2D WH; 98 | SendEntityMessage( self->base.owner, EM_GETPOS, (int)&x, (int)&y ); 99 | SendEntityMessage( self->base.owner, EM_GETWH, (int)&WH.x_, (int)&WH.y_ ); 100 | WriteImageToScreen( self->animation->frames[self->animation->currentFrame]->ID, 101 | FloatToInt( x - CAMOFFX - WH.x_ / 2.f + DimensionOffset( WH.x_ ) ), 102 | FloatToInt( y - CAMOFFY - WH.y_ / 2.f + 1.f ) ); 103 | } 104 | 105 | // 106 | // AnimationUpdate 107 | // Purpose: Updates the animation's internal timer, allowing to flip through the frames. 108 | // 109 | void AnimationUpdate( ANI *self, float *dt ) 110 | { 111 | UpdateAnimation( self->animation, *dt ); 112 | } 113 | 114 | // 115 | // AnimationGetPlayCount 116 | // Purpose: Gets the playcount of the animation and copies into int *var1 117 | // 118 | void AnimationGetPlayCount( ANI *self, int *var1 ) 119 | { 120 | *var1 = self->animation->playCount; 121 | } 122 | 123 | // 124 | // AnimationSetPlayCount 125 | // Purpose: Sets the playcount from the data within int *var1 126 | // 127 | void AnimationSetPlayCount( ANI *self, int *var1 ) 128 | { 129 | self->animation->playCount = *var1; 130 | } 131 | 132 | // 133 | // AnimationGetCurrentFrame 134 | // Purpose: Gets the currentFrame of the animation and copies into int *var1 135 | // 136 | void AnimationGetCurrentFrame( ANI *self, int *var1 ) 137 | { 138 | *var1 = self->animation->currentFrame; 139 | } 140 | 141 | // 142 | // AnimationSetCurrentFrame 143 | // Purpose: Sets the currentFrame from the data within int *var1 144 | // 145 | void AnimationSetCurrentFrame( ANI *self, int *var1 ) 146 | { 147 | self->animation->currentFrame = *var1; 148 | } 149 | 150 | // 151 | // AnimationGetFrameDelay 152 | // Purpose: Gets the frameDelay from the animation and copies into float *var1 153 | // 154 | void AnimationGetFrameDelay( ANI *self, float *var1 ) 155 | { 156 | *var1 = self->animation->frameDelay; 157 | } 158 | 159 | // 160 | // AnimationSetFrameDelay 161 | // Purpose: Copis the frameDelay in the animation to value of float *var1 162 | // 163 | void AnimationSetFrameDelay( ANI *self, float *var1 ) 164 | { 165 | self->animation->frameDelay = *var1; 166 | } 167 | 168 | // 169 | // AnimationGetGetIsPaused 170 | // Purpose: Gets the isPaused from the animation and copies into BOOL *var1 171 | // 172 | void AnimationGetIsPaused( ANI *self, BOOL *var1 ) 173 | { 174 | *var1 = self->animation->isPaused; 175 | } 176 | 177 | // 178 | // AnimationSetGetIsPaused 179 | // Purpose: Copies the isPaused in the animation to value of BOOL *var1 180 | // 181 | void AnimationSetIsPaused( ANI *self, BOOL *var1 ) 182 | { 183 | self->animation->isPaused = *var1; 184 | } 185 | -------------------------------------------------------------------------------- /AsciiEngine/Animation.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////// 2 | // Copyright (c) 2012 ICRL 3 | // See the file LICENSE.txt for copying permission. 4 | // 5 | // Original Author: Randy Gaul 6 | // Date: 7/19/2012 7 | // Contact: r.gaul@digipen.edu 8 | //////////////////////////////////////////////////// 9 | 10 | #pragma once 11 | 12 | #include "Graphics.h" 13 | #include "GraphicsComponent.h" 14 | 15 | // 16 | // ANIMATION class 17 | // This class is derived from the GRAPHICS_COMPONENT base, and represents 18 | // a two dimensional sprite image. 19 | // 20 | typedef struct _ANIMATION_COMPONENT 21 | { 22 | GRAPHICS_COMPONENT base; 23 | ANIMATION *animation; 24 | } ANI; 25 | 26 | // 27 | // ClassCOM_PROC 28 | // Purpose: Component procedure for this component type. Dispatches messages 29 | // recieved in the appropriate manner. 30 | // 31 | void AnimationCOM_PROC( ANI *self, EM msg, int var1, int var2 ); 32 | 33 | // 34 | // ClassCreate 35 | // Purpose: Acts as a constructor for this class. Initializes the 36 | // data and dynamically allocates any extra space needed, and 37 | // initializes the allocated space with data. 38 | // 39 | void AnimationCreate( ANI *self, ANIMATION *animation ); 40 | 41 | // 42 | // ClassInit 43 | // Purpose: One-time initialization of the class. Use this function to load resources from disk, 44 | // set up static class variables, or anything else. 45 | // 46 | void AnimationInit( const char *className ); 47 | 48 | // 49 | // ComponentDraw 50 | // Purpose: Simply renders the animation. 51 | // 52 | void AnimationDraw( ANI *self ); 53 | 54 | // 55 | // AnimationUpdate 56 | // Purpose: Updates the animation's internal timer, allowing to flip through the frames. 57 | // 58 | void AnimationUpdate( ANI *self, float *dt ); 59 | 60 | // 61 | // AnimationSetPlayCount 62 | // Purpose: Sets the playcount of the animation and copies into int *var1 63 | // 64 | void AnimationSetPlayCount( ANI *self, int *var1 ); 65 | 66 | // 67 | // AnimationGetPlayCount 68 | // Purpose: Gets the playcount of the animation and copies into int *var1 69 | // 70 | void AnimationGetPlayCount( ANI *self, int *var1 ); 71 | 72 | // 73 | // AnimationGetCurrentFrame 74 | // Purpose: Gets the currentFrame of the animation and copies into int *var1 75 | // 76 | void AnimationGetCurrentFrame( ANI *self, int *var1 ); 77 | 78 | // 79 | // AnimationSetCurrentFrame 80 | // Purpose: Sets the currentFrame from the data within int *var1 81 | // 82 | void AnimationSetCurrentFrame( ANI *self, int *var1 ); 83 | 84 | // 85 | // AnimationGetFrameDelay 86 | // Purpose: Gets the currentFrame of the animation and copies into float *var1 87 | // 88 | void AnimationGetFrameDelay( ANI *self, float *var1 ); 89 | 90 | // 91 | // AnimationSetFrameDelay 92 | // Purpose: Sets the currentFrame from the data within float *var1 93 | // 94 | void AnimationSetFrameDelay( ANI *self, float *var1 ); 95 | 96 | // 97 | // AnimationGetGetIsPaused 98 | // Purpose: Gets the isPaused from the animation and copies into BOOL *var1 99 | // 100 | void AnimationGetIsPaused( ANI *self, BOOL *var1 ); 101 | 102 | // 103 | // AnimationSetGetIsPaused 104 | // Purpose: Copies the isPaused in the animation to value of BOOL *var1 105 | // 106 | void AnimationSetIsPaused( ANI *self, BOOL *var1 ); -------------------------------------------------------------------------------- /AsciiEngine/ArtAssets/BlockThing.AEArt: -------------------------------------------------------------------------------- 1 | 5 2 | 5 3 | 255 255 255 255 17 4 | 255 255 255 255 17 5 | 255 255 255 255 17 6 | 255 255 255 255 17 7 | 30 30 30 30 255 8 | 9 | 0 0 0 0 7 10 | 0 0 0 0 7 11 | 0 0 0 0 7 12 | 0 0 0 0 7 13 | 7 7 7 7 0 14 | -------------------------------------------------------------------------------- /AsciiEngine/ArtAssets/BlueSquare.AEArt: -------------------------------------------------------------------------------- 1 | 1 2 | 1 3 | 14 4 | 5 | 9 6 | -------------------------------------------------------------------------------- /AsciiEngine/ArtAssets/ItemParticle.AEArt: -------------------------------------------------------------------------------- 1 | 1 2 | 1 3 | 42 4 | 5 | 15 6 | -------------------------------------------------------------------------------- /AsciiEngine/ArtAssets/Man.AEArt: -------------------------------------------------------------------------------- 1 | 4 2 | 9 3 | 255 219 219 0 4 | 255 219 219 0 5 | 255 219 255 0 6 | 219 219 219 219 7 | 219 219 219 219 8 | 255 219 47 0 9 | 255 47 92 0 10 | 255 219 222 92 11 | 0 219 222 0 12 | 13 | 0 8 8 0 14 | 0 8 8 0 15 | 0 5 0 0 16 | 15 8 8 15 17 | 15 8 5 15 18 | 0 15 95 0 19 | 0 95 95 0 20 | 0 7 7 15 21 | 0 7 7 0 22 | -------------------------------------------------------------------------------- /AsciiEngine/ArtAssets/ManJump.AEArt: -------------------------------------------------------------------------------- 1 | 8 2 | 9 3 | 255 255 255 255 219 219 255 255 4 | 255 255 255 255 219 219 255 255 5 | 92 255 255 255 219 255 255 219 6 | 255 92 47 219 219 219 219 255 7 | 255 47 219 255 219 219 255 255 8 | 255 255 255 255 219 219 219 255 9 | 255 255 255 255 219 255 219 255 10 | 255 255 255 219 255 255 255 255 11 | 255 255 255 255 255 255 255 255 12 | 13 | 0 0 0 0 7 7 0 0 14 | 0 0 0 0 7 7 0 0 15 | 15 0 0 0 5 0 0 15 16 | 0 15 15 15 7 7 15 0 17 | 0 15 15 0 5 5 0 0 18 | 0 0 0 0 5 7 7 0 19 | 0 0 0 0 136 0 7 0 20 | 0 0 0 136 0 0 0 0 21 | 0 0 0 0 0 0 0 0 22 | -------------------------------------------------------------------------------- /AsciiEngine/ArtAssets/ManJumpFlipX.AEArt: -------------------------------------------------------------------------------- 1 | 8 2 | 9 3 | 255 255 219 219 255 255 255 255 4 | 255 255 219 219 255 255 255 255 5 | 219 255 255 219 255 255 255 47 6 | 255 219 219 219 219 92 47 255 7 | 255 255 219 219 255 219 92 255 8 | 255 219 219 219 255 255 255 255 9 | 255 219 255 219 255 255 255 255 10 | 255 255 255 255 219 255 255 255 11 | 255 255 255 255 255 255 255 255 12 | 13 | 0 0 7 7 0 0 0 0 14 | 0 0 7 7 0 0 0 0 15 | 15 0 0 5 0 0 0 15 16 | 0 15 7 7 15 15 15 0 17 | 0 0 5 5 0 15 15 0 18 | 0 7 7 5 0 0 0 0 19 | 0 7 0 136 0 0 0 0 20 | 0 0 0 0 136 0 0 0 21 | 0 0 0 0 0 0 0 0 22 | -------------------------------------------------------------------------------- /AsciiEngine/ArtAssets/ManRun1.AEArt: -------------------------------------------------------------------------------- 1 | 6 2 | 9 3 | 255 255 255 255 255 255 4 | 255 255 219 219 255 255 5 | 255 255 219 219 255 255 6 | 255 255 219 255 255 255 7 | 255 219 219 219 255 255 8 | 219 47 219 219 219 255 9 | 47 92 219 219 255 255 10 | 219 219 92 219 255 255 11 | 255 255 255 219 255 255 12 | 13 | 0 0 0 0 0 0 14 | 0 0 7 7 0 0 15 | 0 0 7 7 0 0 16 | 0 0 5 0 0 0 17 | 0 15 7 7 0 0 18 | 15 15 8 5 15 0 19 | 15 15 5 5 0 0 20 | 8 8 15 7 0 0 21 | 0 0 0 7 0 0 22 | -------------------------------------------------------------------------------- /AsciiEngine/ArtAssets/ManRun1FlipX.AEArt: -------------------------------------------------------------------------------- 1 | 8 2 | 9 3 | 255 255 255 255 255 255 255 255 4 | 255 255 255 255 219 219 255 255 5 | 255 255 255 255 219 219 255 255 6 | 255 255 255 255 255 219 255 255 7 | 255 255 255 255 219 219 219 255 8 | 255 255 255 219 219 219 92 219 9 | 255 255 255 255 219 219 47 92 10 | 255 255 255 255 219 47 219 219 11 | 255 255 255 255 219 255 255 255 12 | 13 | 0 0 0 0 0 0 0 0 14 | 0 0 0 0 7 7 0 0 15 | 0 0 0 0 7 7 0 0 16 | 0 0 0 0 0 5 0 0 17 | 0 0 0 0 7 7 15 0 18 | 0 0 0 15 5 8 15 15 19 | 0 0 0 0 5 5 15 15 20 | 0 0 0 0 7 15 8 8 21 | 0 0 0 0 7 0 0 0 22 | -------------------------------------------------------------------------------- /AsciiEngine/ArtAssets/ManRun2.AEArt: -------------------------------------------------------------------------------- 1 | 6 2 | 9 3 | 255 255 255 255 255 255 4 | 255 255 219 219 255 255 5 | 255 255 219 219 255 255 6 | 255 255 219 255 255 255 7 | 255 255 219 219 255 255 8 | 255 255 219 219 255 255 9 | 255 255 219 219 47 255 10 | 255 219 219 47 92 255 11 | 255 255 255 219 255 92 12 | 13 | 0 0 0 0 0 0 14 | 0 0 7 7 0 0 15 | 0 0 7 7 0 0 16 | 0 0 5 0 0 0 17 | 0 0 15 7 0 0 18 | 0 0 15 5 0 0 19 | 0 0 5 15 15 0 20 | 0 8 8 127 15 0 21 | 0 0 0 7 0 15 22 | -------------------------------------------------------------------------------- /AsciiEngine/ArtAssets/ManRun2FlipX.AEArt: -------------------------------------------------------------------------------- 1 | 7 2 | 9 3 | 255 255 255 255 255 255 255 4 | 255 255 255 255 219 219 255 5 | 255 255 255 255 219 219 255 6 | 255 255 255 255 255 219 255 7 | 255 255 255 255 219 219 255 8 | 255 255 255 255 219 219 255 9 | 255 255 255 92 219 219 255 10 | 255 255 255 47 92 219 219 11 | 255 255 47 255 219 255 255 12 | 13 | 0 0 0 0 0 0 0 14 | 0 0 0 0 7 7 0 15 | 0 0 0 0 7 7 0 16 | 0 0 0 0 0 5 0 17 | 0 0 0 0 7 15 0 18 | 0 0 0 0 5 15 0 19 | 0 0 0 15 15 5 0 20 | 0 0 0 15 127 8 8 21 | 0 0 15 0 7 0 0 22 | -------------------------------------------------------------------------------- /AsciiEngine/ArtAssets/ManRun3.AEArt: -------------------------------------------------------------------------------- 1 | 7 2 | 9 3 | 255 255 255 255 255 255 255 4 | 255 255 219 219 255 255 255 5 | 255 255 219 219 255 255 255 6 | 255 255 219 255 255 255 47 7 | 255 219 219 219 92 47 255 8 | 219 255 219 219 219 92 255 9 | 255 255 219 219 255 255 255 10 | 255 255 219 255 219 255 255 11 | 255 219 255 255 219 255 255 12 | 13 | 0 0 0 0 0 0 0 14 | 0 0 7 7 0 0 0 15 | 0 0 7 7 0 0 0 16 | 0 0 5 0 0 0 15 17 | 0 15 7 15 15 15 0 18 | 15 0 5 8 15 15 0 19 | 0 0 5 5 0 0 0 20 | 0 0 7 0 8 0 0 21 | 0 7 0 0 8 0 0 22 | -------------------------------------------------------------------------------- /AsciiEngine/ArtAssets/ManRun3FlipX.AEArt: -------------------------------------------------------------------------------- 1 | 8 2 | 9 3 | 255 255 255 255 255 255 255 255 4 | 255 255 255 255 219 219 255 255 5 | 255 255 255 255 219 219 255 255 6 | 255 92 255 255 255 219 255 255 7 | 255 255 92 47 219 219 219 255 8 | 255 255 47 219 219 219 255 219 9 | 255 255 255 255 219 219 255 255 10 | 255 255 255 219 255 219 255 255 11 | 255 255 255 219 255 255 219 255 12 | 13 | 0 0 0 0 0 0 0 0 14 | 0 0 0 0 7 7 0 0 15 | 0 0 0 0 7 7 0 0 16 | 0 15 0 0 0 5 0 0 17 | 0 0 15 15 15 7 15 0 18 | 0 0 15 15 8 5 0 15 19 | 0 0 0 0 5 5 0 0 20 | 0 0 0 8 0 7 0 0 21 | 0 0 0 8 0 0 7 0 22 | -------------------------------------------------------------------------------- /AsciiEngine/ArtAssets/ManRun4.AEArt: -------------------------------------------------------------------------------- 1 | 8 2 | 9 3 | 255 255 255 255 255 255 255 255 4 | 255 255 219 219 255 255 255 255 5 | 255 255 219 219 255 255 255 255 6 | 255 255 219 255 255 255 47 255 7 | 255 219 219 219 92 47 255 255 8 | 255 219 219 219 219 92 255 255 9 | 255 255 219 219 255 255 255 255 10 | 255 219 219 219 255 255 255 255 11 | 255 255 255 219 255 255 255 255 12 | 13 | 0 0 0 0 0 0 0 0 14 | 0 0 7 7 0 0 0 0 15 | 0 0 7 7 0 0 0 0 16 | 0 0 5 0 0 0 15 0 17 | 0 15 7 15 15 15 0 0 18 | 0 15 5 8 15 15 0 0 19 | 0 0 5 5 0 0 0 0 20 | 0 7 7 8 0 0 0 0 21 | 0 0 0 8 0 0 0 0 22 | -------------------------------------------------------------------------------- /AsciiEngine/ArtAssets/ManRun4FlipX.AEArt: -------------------------------------------------------------------------------- 1 | 7 2 | 9 3 | 255 255 255 255 255 255 255 4 | 255 255 255 255 219 219 255 5 | 255 255 255 255 219 219 255 6 | 255 92 255 255 255 219 255 7 | 255 255 92 47 219 219 219 8 | 255 255 47 219 219 219 219 9 | 255 255 255 255 219 219 255 10 | 255 255 255 255 219 219 219 11 | 255 255 255 255 219 255 255 12 | 13 | 0 0 0 0 0 0 0 14 | 0 0 0 0 7 7 0 15 | 0 0 0 0 7 7 0 16 | 0 15 0 0 0 5 0 17 | 0 0 15 15 15 7 15 18 | 0 0 15 15 8 5 15 19 | 0 0 0 0 5 5 0 20 | 0 0 0 0 8 7 7 21 | 0 0 0 0 8 0 0 22 | -------------------------------------------------------------------------------- /AsciiEngine/ArtAssets/ManRun5.AEArt: -------------------------------------------------------------------------------- 1 | 6 2 | 9 3 | 255 255 255 255 255 255 4 | 255 255 219 219 255 255 5 | 255 255 219 219 255 255 6 | 255 255 219 255 255 255 7 | 255 255 219 219 255 255 8 | 255 255 219 219 255 255 9 | 255 255 219 219 47 255 10 | 255 255 219 47 92 255 11 | 255 255 219 219 255 92 12 | 13 | 0 0 0 0 0 0 14 | 0 0 7 7 0 0 15 | 0 0 7 7 0 0 16 | 0 0 5 0 0 0 17 | 0 0 15 7 0 0 18 | 0 0 15 5 0 0 19 | 0 0 5 15 15 0 20 | 0 0 7 143 15 0 21 | 0 8 8 7 0 15 22 | -------------------------------------------------------------------------------- /AsciiEngine/ArtAssets/ManRun5FlipX.AEArt: -------------------------------------------------------------------------------- 1 | 6 2 | 9 3 | 255 255 255 255 255 255 4 | 255 255 255 255 219 219 5 | 255 255 255 255 219 219 6 | 255 255 255 255 255 219 7 | 255 255 255 255 219 219 8 | 255 255 255 255 219 219 9 | 255 255 255 92 219 219 10 | 255 255 255 47 92 219 11 | 255 255 47 255 219 219 12 | 13 | 0 0 0 0 0 0 14 | 0 0 0 0 7 7 15 | 0 0 0 0 7 7 16 | 0 0 0 0 0 5 17 | 0 0 0 0 7 15 18 | 0 0 0 0 5 15 19 | 0 0 0 15 15 5 20 | 0 0 0 15 143 7 21 | 0 0 15 0 7 8 22 | -------------------------------------------------------------------------------- /AsciiEngine/ArtAssets/ManRun6.AEArt: -------------------------------------------------------------------------------- 1 | 5 2 | 9 3 | 255 255 255 255 255 4 | 255 255 219 219 255 5 | 255 255 219 219 255 6 | 255 255 219 255 255 7 | 255 219 219 219 255 8 | 255 219 47 219 219 9 | 255 47 92 219 255 10 | 255 219 219 92 219 11 | 255 255 255 255 219 12 | 13 | 0 0 0 0 0 14 | 0 0 7 7 0 15 | 0 0 7 7 0 16 | 0 0 5 0 0 17 | 0 15 7 7 0 18 | 0 15 143 5 15 19 | 0 15 95 5 0 20 | 0 8 8 15 7 21 | 0 0 0 0 7 22 | -------------------------------------------------------------------------------- /AsciiEngine/ArtAssets/ManRun6FlipX.AEArt: -------------------------------------------------------------------------------- 1 | 7 2 | 9 3 | 255 255 255 255 255 255 255 4 | 255 255 255 255 219 219 255 5 | 255 255 255 255 219 219 255 6 | 255 255 255 255 255 219 255 7 | 255 255 255 255 219 219 219 8 | 255 255 255 219 219 92 219 9 | 255 255 255 255 219 47 92 10 | 255 255 255 219 47 219 219 11 | 255 255 255 219 255 255 255 12 | 13 | 0 0 0 0 0 0 0 14 | 0 0 0 0 7 7 0 15 | 0 0 0 0 7 7 0 16 | 0 0 0 0 0 5 0 17 | 0 0 0 0 7 7 15 18 | 0 0 0 15 5 143 15 19 | 0 0 0 0 5 95 15 20 | 0 0 0 7 15 8 8 21 | 0 0 0 7 0 0 0 22 | -------------------------------------------------------------------------------- /AsciiEngine/ArtAssets/ManSwing1.AEArt: -------------------------------------------------------------------------------- 1 | 8 2 | 9 3 | 255 255 255 255 255 255 255 255 4 | 255 255 255 255 219 219 255 255 5 | 255 255 255 255 219 219 255 255 6 | 92 255 255 255 219 255 255 255 7 | 255 92 47 219 219 219 219 219 8 | 255 47 219 162 219 219 255 255 9 | 255 255 255 255 219 21 255 255 10 | 255 255 255 255 219 219 255 255 11 | 255 255 255 255 219 255 219 255 12 | 13 | 5 5 5 5 5 5 5 5 14 | 5 5 5 5 7 7 5 5 15 | 15 5 5 5 7 7 5 5 16 | 15 5 5 5 5 5 5 5 17 | 5 15 15 15 7 8 15 15 18 | 5 15 15 15 8 5 5 5 19 | 5 5 5 5 5 80 5 5 20 | 5 5 5 5 7 8 5 8 21 | 5 5 5 5 7 5 8 8 22 | -------------------------------------------------------------------------------- /AsciiEngine/ArtAssets/ManSwing1FlipX.AEArt: -------------------------------------------------------------------------------- 1 | 10 2 | 9 3 | 255 255 255 255 255 255 255 255 255 255 4 | 255 255 255 255 219 219 255 255 255 255 5 | 255 255 255 255 219 219 255 255 255 255 6 | 255 255 255 255 255 219 255 255 255 47 7 | 255 255 219 219 219 219 219 92 47 255 8 | 255 255 255 255 219 219 163 219 92 255 9 | 255 255 255 255 21 219 255 255 255 255 10 | 255 255 255 255 219 219 255 255 255 255 11 | 255 255 255 219 255 219 255 255 255 255 12 | 13 | 5 5 5 5 5 5 5 5 0 0 14 | 0 0 0 0 7 7 0 0 0 0 15 | 0 0 0 0 7 7 0 0 0 0 16 | 0 0 0 0 0 5 0 0 0 15 17 | 0 0 15 15 8 7 15 15 15 0 18 | 0 0 0 0 5 8 15 15 15 0 19 | 0 0 0 0 5 5 0 0 0 0 20 | 0 0 0 0 8 7 0 0 0 0 21 | 0 0 0 8 0 7 0 0 0 0 22 | -------------------------------------------------------------------------------- /AsciiEngine/ArtAssets/ManSwing2.AEArt: -------------------------------------------------------------------------------- 1 | 8 2 | 9 3 | 255 255 255 255 255 255 255 255 4 | 255 255 255 255 255 255 255 255 5 | 255 255 255 255 255 255 255 255 6 | 255 255 255 255 219 219 255 255 7 | 255 255 255 255 219 219 219 219 8 | 255 255 255 219 219 255 255 255 9 | 255 255 219 219 219 255 255 255 10 | 255 255 219 219 163 161 255 255 11 | 255 47 255 219 255 219 255 255 12 | 13 | 5 5 5 5 5 5 5 5 14 | 5 5 5 5 5 5 5 5 15 | 5 5 5 5 5 5 5 5 16 | 15 5 5 5 7 7 5 5 17 | 5 5 15 15 7 7 15 15 18 | 5 15 15 7 5 5 5 5 19 | 5 5 15 5 5 5 5 0 20 | 5 5 15 7 7 7 5 5 21 | 5 15 5 8 5 8 5 5 22 | -------------------------------------------------------------------------------- /AsciiEngine/ArtAssets/ManSwing2FlipX.AEArt: -------------------------------------------------------------------------------- 1 | 9 2 | 9 3 | 255 255 255 255 255 255 255 255 255 4 | 255 255 255 255 255 255 255 255 255 5 | 255 255 255 255 255 255 255 255 255 6 | 255 255 255 219 219 255 255 255 255 7 | 255 255 219 219 219 255 255 255 255 8 | 255 255 255 255 219 219 255 255 255 9 | 255 255 255 255 219 219 219 255 255 10 | 255 255 255 160 162 219 219 255 255 11 | 255 255 255 219 255 219 255 92 255 12 | 13 | 5 5 5 5 5 5 5 5 0 14 | 5 5 5 5 5 5 5 5 0 15 | 5 5 5 5 5 5 5 5 0 16 | 15 0 0 7 7 0 0 0 0 17 | 0 0 15 7 7 0 0 0 0 18 | 5 0 0 0 5 7 0 0 0 19 | 5 0 0 0 5 5 15 0 0 20 | 5 0 0 7 7 7 15 0 0 21 | 5 0 0 8 0 8 0 15 0 22 | -------------------------------------------------------------------------------- /AsciiEngine/ArtAssets/ManSwing3.AEArt: -------------------------------------------------------------------------------- 1 | 7 2 | 9 3 | 255 255 255 255 255 255 255 4 | 255 255 255 255 255 255 255 5 | 255 255 255 255 255 255 255 6 | 255 255 219 255 219 219 255 7 | 255 255 255 219 219 219 255 8 | 255 255 255 219 219 255 255 9 | 255 255 255 219 219 255 255 10 | 255 255 255 219 163 219 255 11 | 255 255 255 219 255 219 92 12 | 13 | 5 5 5 5 5 5 5 14 | 5 5 7 5 5 5 5 15 | 5 5 5 5 7 7 5 16 | 5 5 15 5 7 7 5 17 | 5 5 5 15 7 7 5 18 | 5 5 5 7 5 5 5 19 | 5 5 5 5 15 5 5 20 | 5 5 5 7 8 15 5 21 | 5 5 5 8 5 8 15 22 | -------------------------------------------------------------------------------- /AsciiEngine/ArtAssets/ManSwing3FlipX.AEArt: -------------------------------------------------------------------------------- 1 | 8 2 | 9 3 | 255 255 255 255 255 255 255 255 4 | 255 255 255 255 255 255 255 255 5 | 255 255 255 255 255 255 255 255 6 | 255 255 255 255 219 219 255 219 7 | 255 255 255 255 219 219 219 255 8 | 255 255 255 255 255 219 219 255 9 | 255 255 255 255 255 219 219 255 10 | 255 255 255 255 219 162 219 255 11 | 255 255 255 47 219 255 219 255 12 | 13 | 5 5 5 5 5 5 5 0 14 | 5 5 7 5 5 5 5 0 15 | 5 5 5 5 7 7 5 0 16 | 5 5 0 0 7 7 0 15 17 | 5 5 0 0 7 7 15 0 18 | 5 5 0 0 0 5 7 0 19 | 5 5 0 0 0 15 5 0 20 | 5 5 0 0 15 8 15 0 21 | 5 0 5 15 8 0 8 0 22 | -------------------------------------------------------------------------------- /AsciiEngine/ArtAssets/ManSwing4.AEArt: -------------------------------------------------------------------------------- 1 | 10 2 | 9 3 | 255 255 255 255 255 255 255 255 255 255 4 | 255 255 255 255 255 255 255 255 255 255 5 | 255 255 255 255 219 219 255 255 255 255 6 | 255 255 255 255 219 219 255 255 255 47 7 | 255 255 219 219 219 255 255 92 47 255 8 | 255 255 255 255 219 219 219 219 92 255 9 | 255 255 255 255 219 219 255 255 255 255 10 | 255 255 255 255 219 219 255 255 255 255 11 | 255 255 255 255 219 21 21 255 255 255 12 | 13 | 5 5 5 5 5 5 5 5 5 5 14 | 5 5 5 5 5 5 5 5 5 5 15 | 5 5 5 5 119 119 5 5 5 5 16 | 5 5 5 5 119 119 5 5 0 15 17 | 5 5 15 15 5 5 5 15 15 5 18 | 5 5 5 5 119 119 15 15 15 5 19 | 5 5 5 5 5 5 5 5 5 5 20 | 5 5 5 5 119 8 5 5 5 5 21 | 5 5 5 5 8 8 128 5 5 5 22 | -------------------------------------------------------------------------------- /AsciiEngine/ArtAssets/ManSwing4FlipX.AEArt: -------------------------------------------------------------------------------- 1 | 8 2 | 9 3 | 255 255 255 255 255 255 255 255 4 | 255 255 255 255 255 255 255 255 5 | 255 255 255 255 219 219 255 255 6 | 92 255 255 255 219 219 255 255 7 | 255 92 47 255 255 219 219 219 8 | 255 47 219 219 219 219 255 255 9 | 255 255 255 255 219 219 255 255 10 | 255 255 255 255 219 219 255 255 11 | 255 255 255 21 21 219 255 255 12 | 13 | 5 5 5 5 5 5 5 5 14 | 5 5 5 5 5 5 5 5 15 | 0 0 0 0 119 119 0 0 16 | 15 0 0 0 119 119 0 0 17 | 0 15 15 0 0 5 15 15 18 | 0 15 15 15 119 119 0 0 19 | 0 0 0 0 5 5 0 0 20 | 0 0 0 0 8 119 0 0 21 | 0 0 0 8 128 8 0 0 22 | -------------------------------------------------------------------------------- /AsciiEngine/ArtAssets/ManSwing5.AEArt: -------------------------------------------------------------------------------- 1 | 8 2 | 9 3 | 255 255 255 255 255 255 255 255 4 | 255 255 255 255 219 219 255 255 5 | 255 255 255 255 219 219 92 255 6 | 255 255 255 255 219 255 255 219 7 | 255 255 255 219 219 219 219 255 8 | 255 255 219 255 219 219 255 255 9 | 255 255 255 255 219 219 255 255 10 | 255 255 255 255 219 163 161 255 11 | 255 255 255 255 219 255 219 255 12 | 13 | 5 5 5 5 5 5 5 5 14 | 5 5 5 5 119 119 0 5 15 | 5 5 5 5 119 119 15 0 16 | 5 5 5 0 5 5 5 15 17 | 5 5 5 15 119 119 15 5 18 | 5 0 15 5 8 5 0 0 19 | 5 5 5 5 5 5 0 0 20 | 5 5 5 5 119 8 8 0 21 | 5 5 5 5 8 5 8 0 22 | -------------------------------------------------------------------------------- /AsciiEngine/ArtAssets/ManSwing5FlipX.AEArt: -------------------------------------------------------------------------------- 1 | 8 2 | 9 3 | 255 255 255 255 255 255 255 255 4 | 255 255 255 255 219 219 255 255 5 | 255 255 255 47 219 219 255 255 6 | 255 255 219 255 255 219 255 255 7 | 255 255 255 219 219 219 219 255 8 | 255 255 255 255 219 219 255 219 9 | 255 255 255 255 219 219 255 255 10 | 255 255 255 160 162 219 255 255 11 | 255 255 255 219 255 219 255 255 12 | 13 | 5 5 5 5 5 5 5 5 14 | 5 5 0 0 119 119 0 0 15 | 5 5 0 15 119 119 0 0 16 | 5 5 15 0 0 5 0 0 17 | 5 5 0 15 119 119 15 0 18 | 5 0 0 0 5 8 0 15 19 | 5 5 0 0 5 5 0 0 20 | 5 5 0 8 8 119 0 0 21 | 5 5 0 8 0 8 0 0 22 | -------------------------------------------------------------------------------- /AsciiEngine/ArtAssets/ManSwing6.AEArt: -------------------------------------------------------------------------------- 1 | 8 2 | 9 3 | 255 255 255 255 255 255 255 255 4 | 255 255 255 255 219 219 255 255 5 | 255 255 255 255 219 219 255 255 6 | 255 255 255 255 219 255 255 47 7 | 255 255 255 219 219 219 47 255 8 | 255 255 255 255 219 219 92 255 9 | 255 255 255 255 219 219 255 255 10 | 255 255 255 255 219 219 255 255 11 | 255 255 255 255 219 21 21 255 12 | 13 | 5 5 5 5 5 0 5 5 14 | 0 5 5 0 119 119 5 5 15 | 5 5 5 5 119 119 5 5 16 | 5 5 5 0 5 5 5 15 17 | 5 5 5 15 119 15 15 5 18 | 5 5 5 5 8 15 15 5 19 | 5 5 5 0 5 5 5 5 20 | 5 5 5 5 119 8 5 5 21 | 5 5 5 5 8 8 128 5 22 | -------------------------------------------------------------------------------- /AsciiEngine/ArtAssets/ManSwing6FlipX.AEArt: -------------------------------------------------------------------------------- 1 | 7 2 | 9 3 | 255 255 255 255 255 255 255 4 | 255 255 255 255 219 219 255 5 | 255 255 255 255 219 219 255 6 | 255 255 92 255 255 219 255 7 | 255 255 255 92 219 219 219 8 | 255 255 255 47 219 219 255 9 | 255 255 255 255 219 219 255 10 | 255 255 255 255 219 219 255 11 | 255 255 255 21 21 219 255 12 | 13 | 5 5 5 5 5 0 5 14 | 0 5 0 0 119 119 0 15 | 5 5 0 0 119 119 0 16 | 5 5 15 0 0 5 0 17 | 5 5 0 15 15 119 15 18 | 5 5 0 15 15 8 0 19 | 5 5 0 0 5 5 0 20 | 5 5 0 0 8 119 0 21 | 5 5 0 8 128 8 0 22 | -------------------------------------------------------------------------------- /AsciiEngine/ArtAssets/ManSwing7.AEArt: -------------------------------------------------------------------------------- 1 | 7 2 | 9 3 | 255 255 255 255 219 219 255 4 | 255 255 255 255 219 219 255 5 | 255 255 255 255 219 255 255 6 | 255 255 255 255 219 219 47 7 | 255 255 255 255 219 47 255 8 | 255 255 255 255 219 92 255 9 | 255 255 255 255 219 219 255 10 | 255 255 255 255 219 21 255 11 | 255 255 255 255 219 21 255 12 | 13 | 5 0 5 5 119 119 8 14 | 5 0 5 5 119 119 8 15 | 5 0 5 5 5 8 8 16 | 5 0 5 5 15 119 15 17 | 5 0 5 5 15 143 8 18 | 5 0 5 5 15 95 8 19 | 5 0 5 5 8 5 8 20 | 5 0 5 5 119 8 8 21 | 5 5 5 5 8 8 8 22 | -------------------------------------------------------------------------------- /AsciiEngine/ArtAssets/ManSwing7FlipX.AEArt: -------------------------------------------------------------------------------- 1 | 6 2 | 9 3 | 255 255 255 255 219 219 4 | 255 255 255 255 219 219 5 | 255 255 255 255 255 219 6 | 255 255 255 92 219 219 7 | 255 255 255 255 92 219 8 | 255 255 255 255 47 219 9 | 255 255 255 255 219 219 10 | 255 255 255 255 21 219 11 | 255 255 255 255 21 219 12 | 13 | 5 0 5 0 119 119 14 | 5 0 5 0 119 119 15 | 5 0 5 0 0 5 16 | 5 0 5 15 119 15 17 | 5 0 5 0 143 15 18 | 5 0 5 0 95 15 19 | 5 0 5 0 5 8 20 | 5 0 5 0 128 119 21 | 5 5 5 0 128 8 22 | -------------------------------------------------------------------------------- /AsciiEngine/ArtAssets/SimpleEnemy.AEArt: -------------------------------------------------------------------------------- 1 | 5 2 | 5 3 | 255 30 30 30 255 4 | 17 255 255 255 16 5 | 17 255 255 255 16 6 | 17 255 255 255 16 7 | 255 31 31 31 255 8 | 9 | 0 7 7 7 0 10 | 7 0 0 0 7 11 | 7 0 0 0 7 12 | 7 0 0 0 7 13 | 0 7 7 7 0 14 | -------------------------------------------------------------------------------- /AsciiEngine/ArtAssets/SmallInventoryBack.AEArt: -------------------------------------------------------------------------------- 1 | 21 2 | 7 3 | 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 4 | 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 5 | 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 6 | 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 7 | 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 8 | 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 9 | 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 10 | 11 | 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 12 | 5 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 5 13 | 5 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 5 14 | 5 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 5 15 | 5 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 5 16 | 5 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 5 17 | 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 18 | -------------------------------------------------------------------------------- /AsciiEngine/ArtAssets/TestDamage.AEArt: -------------------------------------------------------------------------------- 1 | 1 2 | 1 3 | 28 4 | 5 | 15 6 | -------------------------------------------------------------------------------- /AsciiEngine/ArtAssets/Tile.AEArt: -------------------------------------------------------------------------------- 1 | 1 2 | 1 3 | 14 4 | 5 | 15 6 | -------------------------------------------------------------------------------- /AsciiEngine/ArtAssets/WalkingArtCollection.AEArt: -------------------------------------------------------------------------------- 1 | 62 2 | 9 3 | 255 219 219 255 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 4 | 255 219 219 255 0 0 0 0 0 0 0 0 0 219 219 0 0 0 0 0 0 219 219 0 0 0 0 0 0 219 219 0 0 0 0 0 0 219 219 0 0 0 0 0 0 0 0 219 219 0 0 0 0 0 0 0 219 219 0 0 0 0 5 | 255 219 255 255 0 0 0 0 0 0 0 0 0 219 219 0 0 0 0 0 0 219 219 0 0 0 0 0 0 219 219 0 0 0 0 0 0 219 219 0 0 0 0 0 0 0 0 219 219 0 0 0 0 0 0 0 219 219 0 0 0 0 6 | 219 219 219 219 0 0 0 0 0 0 0 0 219 219 0 0 0 0 0 0 0 219 0 0 0 0 0 0 0 219 0 0 0 0 0 0 0 219 0 0 0 47 0 0 0 0 0 219 0 0 0 0 0 0 0 0 219 0 0 0 0 0 7 | 219 219 219 219 0 0 0 0 0 0 0 219 219 219 219 219 0 0 0 0 0 219 219 0 0 0 0 0 219 219 219 92 47 0 0 0 219 219 219 92 47 0 0 0 0 0 0 219 219 0 0 0 0 0 0 219 219 219 0 0 0 0 8 | 255 219 47 255 0 0 0 0 0 0 0 219 47 219 0 0 0 0 0 0 0 219 219 0 0 0 0 219 0 219 219 219 92 0 0 0 219 219 219 219 92 0 0 0 0 0 0 219 219 0 0 0 0 0 0 219 47 219 219 0 0 0 9 | 255 47 92 255 0 0 0 0 0 0 0 47 92 219 0 0 0 0 0 0 0 219 219 47 0 0 0 0 0 219 219 0 0 0 0 0 0 219 219 0 0 0 0 0 0 0 0 219 219 47 0 0 0 0 0 47 92 219 0 0 0 0 10 | 255 219 21 92 0 0 0 0 0 0 0 219 219 92 219 0 0 0 0 0 219 219 47 92 0 0 0 0 0 219 219 0 0 0 0 0 219 219 219 0 0 0 0 0 0 219 219 0 47 92 0 0 0 0 0 219 219 92 0 0 0 0 11 | 255 219 21 255 0 0 0 0 0 0 0 0 0 0 219 0 0 0 0 0 0 0 219 0 92 0 0 0 219 0 219 0 0 0 0 0 0 0 219 0 0 0 0 0 0 0 0 0 219 0 92 0 0 0 0 0 0 219 0 0 0 0 12 | 13 | 0 7 7 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 14 | 0 7 7 0 0 0 0 0 0 0 0 0 0 7 7 0 0 0 0 0 0 7 7 0 0 0 0 0 0 7 7 0 0 0 0 0 0 7 7 0 0 0 0 0 0 0 0 7 7 0 0 0 0 0 0 0 7 7 0 0 0 0 15 | 0 5 0 0 0 0 0 0 0 0 0 0 0 7 7 0 0 0 0 0 0 7 7 0 0 0 0 0 0 7 7 0 0 0 0 0 0 7 7 0 0 0 0 0 0 0 0 7 7 0 0 0 0 0 0 0 7 7 0 0 0 0 16 | 15 7 7 15 0 0 0 0 0 0 0 0 15 5 0 0 0 0 0 0 0 5 0 0 0 0 0 0 0 5 0 0 0 0 0 0 0 5 0 0 0 15 0 0 0 0 0 5 0 0 0 0 0 0 0 0 5 0 0 0 0 0 17 | 15 8 5 15 0 0 0 0 0 0 0 15 8 7 8 15 0 0 0 0 0 15 7 0 0 0 0 0 15 7 15 15 15 0 0 0 15 7 15 15 15 0 0 0 0 0 0 15 7 0 0 0 0 0 0 15 7 7 0 0 0 0 18 | 0 15 95 0 0 0 0 0 0 0 0 15 95 5 0 0 0 0 0 0 0 15 5 0 0 0 0 15 0 5 8 15 15 0 0 0 15 5 8 15 15 0 0 0 0 0 0 15 5 0 0 0 0 0 0 15 143 5 15 0 0 0 19 | 0 95 95 0 0 0 0 0 0 0 0 15 15 5 0 0 0 0 0 0 0 5 15 15 0 0 0 0 0 5 5 0 0 0 0 0 0 5 5 0 0 0 0 0 0 0 0 5 15 15 0 0 0 0 0 15 95 5 0 0 0 0 20 | 0 7 8 15 0 0 0 0 0 0 0 8 8 15 7 0 0 0 0 0 8 8 127 15 0 0 0 0 0 7 8 0 0 0 0 0 7 7 8 0 0 0 0 0 0 7 7 0 143 15 0 0 0 0 0 8 7 143 0 0 0 0 21 | 0 7 8 0 0 0 0 0 0 0 0 0 0 0 7 0 0 0 0 0 0 0 7 0 15 0 0 0 7 0 8 0 0 0 0 0 0 0 8 0 0 0 0 0 0 0 0 0 8 0 15 0 0 0 0 0 0 7 0 0 0 0 22 | -------------------------------------------------------------------------------- /AsciiEngine/ArtAssets/WeaponMan.AEArt: -------------------------------------------------------------------------------- 1 | 4 2 | 9 3 | 255 219 219 255 4 | 255 219 219 255 5 | 255 219 255 255 6 | 219 219 219 219 7 | 219 219 219 219 8 | 255 219 47 255 9 | 255 47 92 255 10 | 255 219 21 92 11 | 255 219 21 255 12 | 13 | 0 7 7 0 14 | 0 7 7 0 15 | 0 5 0 0 16 | 15 7 7 15 17 | 15 8 5 15 18 | 0 15 95 0 19 | 0 95 95 0 20 | 0 7 8 15 21 | 0 7 8 0 22 | -------------------------------------------------------------------------------- /AsciiEngine/ArtAssets/WeaponManFlipX.AEArt: -------------------------------------------------------------------------------- 1 | 4 2 | 9 3 | 255 219 219 255 4 | 255 219 219 255 5 | 255 255 219 255 6 | 219 219 219 219 7 | 219 219 219 219 8 | 255 92 219 255 9 | 255 47 92 255 10 | 47 21 219 255 11 | 255 21 219 255 12 | 13 | 0 7 7 0 14 | 0 7 7 0 15 | 0 0 5 0 16 | 15 7 7 15 17 | 15 5 8 15 18 | 0 95 15 0 19 | 0 95 95 0 20 | 15 128 7 0 21 | 0 128 7 0 22 | -------------------------------------------------------------------------------- /AsciiEngine/ArtAssets/WhiteSquare.AEArt: -------------------------------------------------------------------------------- 1 | 1 2 | 1 3 | 177 4 | 5 | 15 6 | -------------------------------------------------------------------------------- /AsciiEngine/AsciiEngine.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 11.00 3 | # Visual Studio 2010 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Untitle Game", "AsciiGame.vcxproj", "{D87A83AF-D641-4880-A687-6140A241AC3F}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|Win32 = Debug|Win32 9 | Release|Win32 = Release|Win32 10 | EndGlobalSection 11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 12 | {D87A83AF-D641-4880-A687-6140A241AC3F}.Debug|Win32.ActiveCfg = Debug|Win32 13 | {D87A83AF-D641-4880-A687-6140A241AC3F}.Debug|Win32.Build.0 = Debug|Win32 14 | {D87A83AF-D641-4880-A687-6140A241AC3F}.Release|Win32.ActiveCfg = Release|Win32 15 | {D87A83AF-D641-4880-A687-6140A241AC3F}.Release|Win32.Build.0 = Release|Win32 16 | EndGlobalSection 17 | GlobalSection(SolutionProperties) = preSolution 18 | HideSolutionNode = FALSE 19 | EndGlobalSection 20 | EndGlobal 21 | -------------------------------------------------------------------------------- /AsciiEngine/AsciiGame.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | -------------------------------------------------------------------------------- /AsciiEngine/BrainComponent.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////// 2 | // Copyright (c) 2012 ICRL 3 | // See the file LICENSE.txt for copying permission. 4 | // 5 | // Original Author: Randy Gaul 6 | // Date: 7/25/2012 7 | // Contact: r.gaul@digipen.edu 8 | //////////////////////////////////////////////////// 9 | 10 | #pragma once 11 | 12 | #include "Message.h" 13 | 14 | // Forward decl 15 | struct _ENTITY; 16 | 17 | // 18 | // Common interface for all hitpoints components. 19 | // 20 | typedef struct _BRIAN_COMPONENT 21 | { 22 | const char *CLASS_NAME; 23 | void (*COM_PROC)( struct _BRIAN_COMPONENT *self, EM msg, int var1, int var2 ); 24 | struct _ENTITY *owner; 25 | } BRAIN_COMPONENT; 26 | -------------------------------------------------------------------------------- /AsciiEngine/Button.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////// 2 | // Copyright (c) 2012 ICRL 3 | // See the file LICENSE.txt for copying permission. 4 | // 5 | // Original Author: Randy Gaul 6 | // Date: 8/9/2012 7 | // Contact: r.gaul@digipen.edu 8 | //////////////////////////////////////////////////// 9 | 10 | #pragma once 11 | 12 | #include "GlobalDefines.h" 13 | #include "LinkedList.h" 14 | #include "Shapes.h" 15 | 16 | // Pause time defines in seconds 17 | #define STANDARD_BUTTON_DEBOUNCE 1.0f 18 | #define BRUSH_BUTTON_DEBOUNCE 0.0001f 19 | 20 | typedef struct BUTTON_STRUCTURE 21 | { 22 | struct BUTTON_STRUCTURE *self; 23 | char *buttonName; 24 | int order; 25 | BOOL isActive; 26 | BOOL isBlocking; 27 | float dt; 28 | AE_RECT rect; 29 | void (*exec)( struct BUTTON_STRUCTURE * ); 30 | RETURN_TYPE (*update)( struct BUTTON_STRUCTURE *, float ); 31 | } BUTTON; 32 | 33 | typedef BUTTON *P_BUTTON; 34 | DECLARE_LIST( P_BUTTON ); 35 | 36 | extern LIST_TYPE( P_BUTTON ) *BUTTON_LIST; 37 | 38 | // 39 | // CreateButton 40 | // Purpose: Creates a button class with a specified exec and update functionality. 41 | // 42 | BUTTON *CreateButton( char *name, void (*exec)( BUTTON * ), RETURN_TYPE (*update)( BUTTON *, float ), AE_RECT rect, int order ); 43 | 44 | // 45 | // DeleteButton 46 | // Purpose: Deletes a button from existence. 47 | // 48 | void DeleteButton( BUTTON *button ); 49 | 50 | // 51 | // DeleteButtons 52 | // Purpose: Deletes all buttons using the CallbackUpdate function. 53 | // 54 | void DeleteButtons( void ); 55 | 56 | // 57 | // UpdateButton 58 | // Purpose: Updates all buttons using the CallbackUpdate function. 59 | // 60 | RETURN_TYPE UpdateButton( BUTTON *button, float dt ); 61 | 62 | // 63 | // UpdateButtons 64 | // Purpose: Updates all buttons using the CallbackUpdate function. 65 | // 66 | void UpdateButtons( float dt ); 67 | 68 | // 69 | // ButtonUpdateStandard 70 | // Purpose: Standard update function for a generic button. 71 | // 72 | RETURN_TYPE ButtonUpdateStandard( BUTTON *self, float dt ); 73 | 74 | // 75 | // ButtonUpdateBrush 76 | // Purpose: Standard update function for a generic button. 77 | // 78 | RETURN_TYPE ButtonUpdateBrush( BUTTON *self, float dt ); 79 | 80 | void ExecTest( BUTTON *self ); 81 | -------------------------------------------------------------------------------- /AsciiEngine/Camera.c: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////// 2 | // Copyright (c) 2012 ICRL 3 | // See the file LICENSE.txt for copying permission. 4 | // 5 | // Original Author: Randy Gaul 6 | // Date: 7/20/2012 7 | // Contact: r.gaul@digipen.edu 8 | //////////////////////////////////////////////////// 9 | 10 | #include 11 | #include "Camera.h" 12 | #include "Math2D.h" 13 | #include "Graphics.h" 14 | #include "TileMap.h" 15 | #include "Input.h" 16 | 17 | CAMERA GLOBAL_CAM = { 0 }; 18 | 19 | // 20 | // GlobalCamInit 21 | // Purpose: Initializes the camera's various data members. 22 | // Notes : The followMe param can be NULL if you don't wish the camera to 23 | // follow any object. 24 | // 25 | RETURN_TYPE GlobalCamInit( float xoffset, float yoffset, ENTITY *followMe ) 26 | { 27 | GLOBAL_CAM.center.x_ = xoffset; 28 | GLOBAL_CAM.center.y_ = yoffset; 29 | GLOBAL_CAM.followThis = followMe; 30 | return RETURN_SUCCESS; 31 | } 32 | 33 | // 34 | // GlobalCamUpdate 35 | // Purpose: Updates the camera, for use when following a game entity. 36 | // 37 | void GlobalCamUpdate( float dt ) 38 | { 39 | VECTOR2D pos = { 0 }; 40 | 41 | // If have entity to follow, go in opposite direction it goes, if it moves 42 | if(GLOBAL_CAM.followThis) 43 | { 44 | SendEntityMessage( GLOBAL_CAM.followThis, EM_GETPOS, (int)&pos.x_, (int)&pos.y_ ); 45 | 46 | GLOBAL_CAM.center.x_ = -FloatToInt( pos.x_ ) + (float)BUFFERWIDTH / 2.f; 47 | GLOBAL_CAM.center.y_ = -(float)FloatToIntRoundUp( pos.y_ ) + (float)BUFFERHEIGHT / 2.f; 48 | 49 | } 50 | } 51 | 52 | // 53 | // GlobalCamDisable 54 | // Purpose: Clears the data members for the next state, to be used during free. 55 | // 56 | void GlobalCamDisable( void ) 57 | { 58 | GLOBAL_CAM.center.x_ = 0; 59 | GLOBAL_CAM.center.y_ = 0; 60 | GLOBAL_CAM.followThis = NULL; 61 | } 62 | -------------------------------------------------------------------------------- /AsciiEngine/Camera.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////// 2 | // Copyright (c) 2012 ICRL 3 | // See the file LICENSE.txt for copying permission. 4 | // 5 | // Original Author: Randy Gaul 6 | // Date: 7/20/2012 7 | // Contact: r.gaul@digipen.edu 8 | //////////////////////////////////////////////////// 9 | 10 | #ifndef CAMERAH 11 | #define CAMERAH 12 | 13 | #include "GlobalDefines.h" 14 | #include "Shapes.h" 15 | #include "Entity.h" 16 | #include "EntityManager.h" 17 | 18 | #define CAM_SCROLL_BOUND 5.0f 19 | 20 | typedef struct _PLAYER_CAMERA 21 | { 22 | VECTOR2D center; 23 | ENTITY *followThis; 24 | } CAMERA; 25 | 26 | // 27 | // GlobalCamInit 28 | // Purpose: Initializes the camera's various data members. 29 | // Notes : The followMe param can be NULL if you don't wish the camera to 30 | // follow any object. 31 | // 32 | RETURN_TYPE GlobalCamInit( float xoffset, float yoffset, ENTITY *followMe ); 33 | 34 | // 35 | // GlobalCamUpdate 36 | // Purpose: Updates the camera, for use when following a game entity. 37 | // 38 | void GlobalCamUpdate( float dt ); 39 | 40 | // 41 | // GlobalCamDisable 42 | // Purpose: Clears the data members for the next state, to be used during free. 43 | // 44 | void GlobalCamDisable( void ); 45 | 46 | extern CAMERA GLOBAL_CAM; 47 | 48 | #endif CAMERAH -------------------------------------------------------------------------------- /AsciiEngine/Cloud.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////// 2 | // Copyright (c) 2012 ICRL 3 | // See the file LICENSE.txt for copying permission. 4 | // 5 | // Original Author: Randy Gaul 6 | // Date: 7/19/2012 7 | // Contact: r.gaul@digipen.edu 8 | //////////////////////////////////////////////////// 9 | 10 | #pragma once 11 | 12 | #include "Loci.h" 13 | #include "GraphicsComponent.h" 14 | 15 | // 16 | // CLOUD class 17 | // This class is derived from the GRAPHICS_COMPONENT base, and represents 18 | // a two dimensional sprite image. 19 | // 20 | typedef struct _CLOUD_COMPONENT 21 | { 22 | GRAPHICS_COMPONENT base; 23 | GET_TABLE_TYPE( P_LOCUS ) *loci; 24 | } CLOUD; 25 | 26 | // 27 | // ClassCOM_PROC 28 | // Purpose: Component procedure for this component type. Dispatches messages 29 | // recieved in the appropriate manner. 30 | // 31 | void CloudCOM_PROC( CLOUD *self, EM msg, int var1, int var2 ); 32 | 33 | // 34 | // ClassCreate 35 | // Purpose: Acts as a constructor for this class. Initializes the 36 | // data and dynamically allocates any extra space needed, and 37 | // initializes the allocated space with data. 38 | // 39 | void CloudCreate( CLOUD *self, int tableSize ); 40 | 41 | // 42 | // ClassInit 43 | // Purpose: One-time initialization of the class. Use this function to load resources from disk, 44 | // set up static class variables, or anything else. 45 | // 46 | void CloudInit( const char *className ); 47 | 48 | // 49 | // ComponentDraw 50 | // Purpose: Simply renders the animation. 51 | // 52 | void CloudDraw( CLOUD *self ); 53 | 54 | // 55 | // AnimationUpdate 56 | // Purpose: Updates the animation's internal timer, allowing to flip through the frames. 57 | // 58 | void CloudUpdate( CLOUD *self, float *dt ); 59 | 60 | // 61 | // CloudInsertPoint 62 | // Purpose: Inserts a point (LOCUS) into the cloud. 63 | // 64 | void CloudInsertLocus( CLOUD *self, LOCUS *locus ); 65 | 66 | // 67 | // CloudGetLocus 68 | // Purpose: Retrieves a pointer to a specific locus by const char *var1 69 | // stores pointer in LOCUS *var2 70 | // 71 | void CloudGetLocus( CLOUD *self, const char *name, LOCUS* locus ); 72 | 73 | // 74 | // CloudSetLocusImage 75 | // Purpose: Swaps the image * of locus const char *var1 with IMAGE *var2 76 | // 77 | void CloudSetLocusImage( CLOUD *self, const char *name, IMAGE *image ); 78 | 79 | // 80 | // CloudSetLocusAnimation 81 | // Purpose: Swaps the image * of locus const char *var1 with IMAGE *var2 82 | // 83 | void CloudSetLocusAnimation( CLOUD *self, const char *name, ANIMATION *animation ); 84 | 85 | // 86 | // CloudDeallocateLocusAnimation 87 | // Purpose: Deallocates the animation of a specific locus at const char *var1 88 | // 89 | void CloudDeallocateLocusAnimation( CLOUD *self, const char *name ); 90 | 91 | // 92 | // CloudLocusToggleActive 93 | // Purpose: Toggles activity of a locus const char *var1 94 | // 95 | void CloudLocusToggleActive( CLOUD *self, const char *name ); 96 | 97 | // 98 | // CloudLocusSetActive 99 | // Purpose: Toggles activity of a locus const char *var1 100 | // 101 | void CloudLocusSetActive( CLOUD *self, const char *name, BOOL *activity ); 102 | 103 | // 104 | // CloudLocusOn 105 | // Purpose: Toggles activity of a locus const char *var1 106 | // 107 | void CloudLocusOn( CLOUD *self, const char *name ); 108 | 109 | // 110 | // CloudLocusOff 111 | // Purpose: Toggles activity of a locus const char *var1 112 | // 113 | void CloudLocusOff( CLOUD *self, const char *name ); 114 | -------------------------------------------------------------------------------- /AsciiEngine/CollisionComponent.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////// 2 | // Copyright (c) 2012 ICRL 3 | // See the file LICENSE.txt for copying permission. 4 | // 5 | // Original Author: Randy Gaul 6 | // Date: 7/17/2012 7 | // Contact: r.gaul@digipen.edu 8 | //////////////////////////////////////////////////// 9 | 10 | #pragma once 11 | 12 | #include "Message.h" 13 | #include "Shapes.h" 14 | 15 | // Forward decl 16 | struct _ENTITY; 17 | 18 | // 19 | // Common interface for all collision components. 20 | // 21 | typedef struct _COLLISION_COMPONENT 22 | { 23 | const char *CLASS_NAME; 24 | void (*COM_PROC)( struct _COLLISION_COMPONENT *self, EM msg, int var1, int var2 ); 25 | struct _ENTITY *owner; 26 | } COLLISION_COMPONENT; 27 | 28 | typedef struct COLLISION_DATA 29 | { 30 | AE_RECT rect; 31 | int flag; 32 | float shortestDist; 33 | struct _ENTITY *closestEntity; 34 | struct _ENTITY *entity; 35 | } COL_DATA; 36 | 37 | #define DAMAGE_DEALER_COLLISION 0x00000001 38 | #define DONT_COLLIDE_WITH_OTHERS 0x00000002 39 | #define ITEM_COLLISION 0x00000004 40 | -------------------------------------------------------------------------------- /AsciiEngine/ConsoleFuncs.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////// 2 | // Copyright (c) 2012 ICRL 3 | // See the file LICENSE.txt for copying permission. 4 | // 5 | // Original Author: Randy Gaul 6 | // Date: 7/3/2012 7 | // Contact: r.gaul@digipen.edu 8 | //////////////////////////////////////////////////// 9 | 10 | // Documentation: http://cecilsunkure.blogspot.com/2011/12/windows-console-game-set-custom-color.html 11 | 12 | #define WIN32_LEAN_AND_MEAN 13 | 14 | #include 15 | #include 16 | 17 | extern BOOL WINDOW_FOCUS; /* BOOL for storing window focus */ 18 | extern HANDLE OUTPUT_HANDLE; /* write (output) handle */ 19 | extern HANDLE INPUT_HANDLE; /* read (input handle */ 20 | extern HWND WINDOW_HANDLE; /* Handle to window */ 21 | 22 | #define MAX_CONSOLE_TITLE 100 23 | 24 | extern WCHAR CONSOLE_TITLE[]; 25 | 26 | #define WM_SETCONSOLEINFO (WM_USER+201) 27 | #pragma pack(push, 1) 28 | typedef struct _CONSOLE_INFO 29 | { 30 | ULONG Length; 31 | COORD ScreenBufferSize; 32 | COORD WindowSize; 33 | ULONG WindowPosX; 34 | ULONG WindowPosY; 35 | COORD FontSize; 36 | ULONG FontFamily; 37 | ULONG FontWeight; 38 | WCHAR FaceName[32]; 39 | ULONG CursorSize; 40 | ULONG FullScreen; 41 | ULONG QuickEdit; 42 | ULONG AutoPosition; 43 | ULONG InsertMode; 44 | USHORT ScreenColors; 45 | USHORT PopupColors; 46 | ULONG HistoryNoDup; 47 | ULONG HistoryBufferSize; 48 | ULONG NumberOfHistoryBuffers; 49 | COLORREF ColorTable[16]; 50 | ULONG CodePage; 51 | HWND Hwnd; 52 | WCHAR ConsoleTitle[0x100]; 53 | } CONSOLE_INFO; 54 | #pragma pack(pop) 55 | 56 | typedef struct CONSOLE_FONT 57 | { 58 | DWORD index; 59 | COORD dimension; 60 | } CONSOLE_FONT; 61 | 62 | #if(_WIN32_WINNT < 0x0600) 63 | typedef struct _CONSOLE_FONT_INFOEX { 64 | ULONG cbSize; 65 | DWORD nFont; 66 | COORD dwFontSize; 67 | UINT FontFamily; 68 | UINT FontWeight; 69 | WCHAR FaceName[LF_FACESIZE]; 70 | } CONSOLE_FONT_INFOEX, *PCONSOLE_FONT_INFOEX; 71 | 72 | typedef struct _CONSOLE_SCREEN_BUFFER_INFOEX { 73 | ULONG cbSize; 74 | COORD dwSize; 75 | COORD dwCursorPosition; 76 | WORD wAttributes; 77 | SMALL_RECT srWindow; 78 | COORD dwMaximumWindowSize; 79 | WORD wPopupAttributes; 80 | BOOL bFullscreenSupported; 81 | COLORREF ColorTable[16]; 82 | } CONSOLE_SCREEN_BUFFER_INFOEX, *PCONSOLE_SCREEN_BUFFER_INFOEX; 83 | #endif // _WIN32_WINNT < 0x0600 84 | 85 | typedef BOOL (WINAPI *PGetCurrentConsoleFontEx)(HANDLE hConsoleOutput, BOOL bMaximumWindow, PCONSOLE_FONT_INFOEX lpConsoleCurrentFontEx); 86 | typedef BOOL (WINAPI *PSetCurrentConsoleFontEx)(HANDLE hConsoleOutput, BOOL bMaximumWindow, PCONSOLE_FONT_INFOEX lpConsoleCurrentFontEx); 87 | typedef BOOL (WINAPI *PGetConsoleScreenBufferInfoEx)(HANDLE hConsoleOutput, PCONSOLE_SCREEN_BUFFER_INFOEX lpConsoleScreenBufferInfoEx); 88 | typedef BOOL (WINAPI *PSetConsoleScreenBufferInfoEx)(HANDLE hConsoleOutput, PCONSOLE_SCREEN_BUFFER_INFOEX lpConsoleScreenBufferInfoEx); 89 | 90 | 91 | typedef BOOL (WINAPI *PSetConsoleFont)(HANDLE, DWORD); 92 | typedef BOOL (WINAPI *PGetConsoleFontInfo)(HANDLE, BOOL, DWORD, CONSOLE_FONT*); 93 | typedef int (WINAPI *PGetNumberOfConsoleFonts)(); 94 | 95 | BOOL SetConsoleInfo(HWND hwndConsole, CONSOLE_INFO *pci); 96 | VOID WINAPI SetConsolePalette(COLORREF palette[], int fontX, int fontY, wchar_t *fontName); 97 | static void GetConsoleSizeInfo(CONSOLE_INFO *pci, HANDLE hOutput); 98 | int windowsVersionTest(void); 99 | void initConsole(unsigned short *title, wchar_t *fontName, int fontx, int fonty); 100 | void RenderScreen( void ); 101 | -------------------------------------------------------------------------------- /AsciiEngine/DamageDealer.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////// 2 | // Copyright (c) 2012 ICRL 3 | // See the file LICENSE.txt for copying permission. 4 | // 5 | // Original Author: Randy Gaul 6 | // Date: 7/22/2012 7 | // Contact: r.gaul@digipen.edu 8 | //////////////////////////////////////////////////// 9 | 10 | #pragma once 11 | 12 | #include "EntityCreator.h" 13 | 14 | typedef struct DAMAGE_DEALER_DATA 15 | { 16 | VECTOR2D pos; 17 | VECTOR2D vel; 18 | VECTOR2D WH; 19 | int damage; 20 | int properties; 21 | float delay; // Delay in seconds till automatic destruction 22 | } DDD; 23 | 24 | // Definition of the creator of this entity 25 | extern ENTITY_CREATOR DAMAGE_DEALER_CREATOR; 26 | -------------------------------------------------------------------------------- /AsciiEngine/DamageText.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////// 2 | // Copyright (c) 2012 ICRL 3 | // See the file LICENSE.txt for copying permission. 4 | // 5 | // Original Author: Randy Gaul 6 | // Date: 7/24/2012 7 | // Contact: r.gaul@digipen.edu 8 | //////////////////////////////////////////////////// 9 | 10 | #pragma once 11 | 12 | #include "EntityCreator.h" 13 | 14 | // Definition of the creator of this entity 15 | extern ENTITY_CREATOR DAMAGE_TEXT_CREATOR; 16 | -------------------------------------------------------------------------------- /AsciiEngine/Entity.c: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////// 2 | // Copyright (c) 2012 ICRL 3 | // See the file LICENSE.txt for copying permission. 4 | // 5 | // Original Author: Randy Gaul 6 | // Date: 7/25/2012 7 | // Contact: r.gaul@digipen.edu 8 | //////////////////////////////////////////////////// 9 | 10 | #include "Entity.h" 11 | 12 | void EntityInactive( ENTITY *self ) 13 | { 14 | self->inactive = TRUE; 15 | } 16 | -------------------------------------------------------------------------------- /AsciiEngine/Entity.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////// 2 | // Copyright (c) 2012 ICRL 3 | // See the file LICENSE.txt for copying permission. 4 | // 5 | // Original Author: Randy Gaul 6 | // Date: 7/5/2012 7 | // Contact: r.gaul@digipen.edu 8 | //////////////////////////////////////////////////// 9 | 10 | #pragma once 11 | 12 | #include "GlobalDefines.h" 13 | #include "Graphics.h" 14 | #include "Message.h" 15 | #include "Action.h" 16 | #include "Component.h" 17 | 18 | // Forward declaration for proper compile 19 | struct _ENTITY_NODE; 20 | struct _ENTITY; 21 | 22 | // Base class for a generic game entity. 23 | typedef struct _ENTITY 24 | { 25 | const char *CLASS_NAME; 26 | void (*EM_PROC)( struct _ENTITY *self, EM msg, int var1, int var2 ); 27 | EN_COMPS comps; 28 | unsigned zOrder; 29 | int properties; // See Properties.h for various properties 30 | int data; // General purpose data holder 31 | BOOL inactive; // If TRUE entity is deleted and removed from list during update 32 | struct _ENTITY_NODE *node; // Pointer to this entity's node for easy deletion 33 | } ENTITY; 34 | 35 | // A simple doubly node for a linked list. 36 | // Linked list documentation: http://cecilsunkure.blogspot.com/2010/11/memory-allocation-and-linked-lists.html 37 | // Object oriented C: http://cecilsunkure.blogspot.com/2012/04/entity-oriented-c-class-like-structures.html 38 | typedef struct _ENTITY_NODE 39 | { 40 | ENTITY *data_; // Pointer to the actual game entity 41 | struct _ENTITY_NODE *next_; 42 | struct _ENTITY_NODE *prev_; 43 | } ENTITY_NODE; 44 | 45 | void EntityInactive( ENTITY *self ); 46 | -------------------------------------------------------------------------------- /AsciiEngine/EntityCreator.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////// 2 | // Copyright (c) 2012 ICRL 3 | // See the file LICENSE.txt for copying permission. 4 | // 5 | // Original Author: Randy Gaul 6 | // Date: 7/15/2012 7 | // Contact: r.gaul@digipen.edu 8 | //////////////////////////////////////////////////// 9 | 10 | #pragma once 11 | 12 | #include "Entity.h" 13 | 14 | typedef struct _ENTITY_CREATOR 15 | { 16 | const char *ID; // Type of entity to create 17 | ENTITY *(*Create)( int var1, int var2 ); // Pointer to the creation function for this entity 18 | } ENTITY_CREATOR; 19 | -------------------------------------------------------------------------------- /AsciiEngine/EntityCreatorTable.c: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////// 2 | // Copyright (c) 2012 ICRL 3 | // See the file LICENSE.txt for copying permission. 4 | // 5 | // Original Author: Randy Gaul 6 | // Date: 7/15/2012 7 | // Contact: r.gaul@digipen.edu 8 | //////////////////////////////////////////////////// 9 | 10 | // This file is used to maintain a hash table of ENTITY_CREATOR structs 11 | // Documentation: http://cecilsunkure.blogspot.com/2012/07/hash-tables.html 12 | 13 | #include "EntityCreatorTable.h" 14 | 15 | DEFINE_TABLE( P_ENTITY_CREATOR, NULL ); 16 | 17 | GET_TABLE_TYPE( P_ENTITY_CREATOR ) *ENTITY_CREATOR_TABLE = NULL; 18 | 19 | // 20 | // CreatorTableGetEntryKeys 21 | // Purpose: Returns an array of string pointers pointing to strings representing all 22 | // the various types of ID keys in the TABLE. The last key will be null to 23 | // detect when to end loop. No string is longer than maxStrLen (not counting null). 24 | // 25 | char **CreatorTableGetEntryKeys( unsigned maxStrLen ) 26 | { 27 | unsigned i = 0, count = 0; 28 | char **entries = NULL; 29 | 30 | for(; i < ENTITY_CREATOR_TABLE->TABLESIZE; ++i) 31 | { 32 | if(HT_HAS_ENTRY( P_ENTITY_CREATOR, ENTITY_CREATOR_TABLE->ARRAY, i )) 33 | { 34 | ++count; 35 | } 36 | } 37 | 38 | entries = (char **)malloc( sizeof( char *) * (count + 1) ); 39 | memset( entries, 0, sizeof( char *) * (count + 1) ); 40 | 41 | for(i = 0; i < ENTITY_CREATOR_TABLE->TABLESIZE; ++i) 42 | { 43 | if(HT_HAS_ENTRY( P_ENTITY_CREATOR, ENTITY_CREATOR_TABLE->ARRAY, i )) 44 | { 45 | unsigned len = strlen( ENTITY_CREATOR_TABLE->ARRAY[i].ID ) + 1; 46 | int size = (len < maxStrLen + 1) ? len : maxStrLen + 1; 47 | --count; 48 | entries[count] = (char *)malloc( size + 1 ); 49 | memcpy( entries[count], ENTITY_CREATOR_TABLE->ARRAY[i].ID, size ); 50 | entries[count][size] = 0; 51 | } 52 | } 53 | 54 | return entries; 55 | } 56 | -------------------------------------------------------------------------------- /AsciiEngine/EntityCreatorTable.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////// 2 | // Copyright (c) 2012 ICRL 3 | // See the file LICENSE.txt for copying permission. 4 | // 5 | // Original Author: Randy Gaul 6 | // Date: 7/15/2012 7 | // Contact: r.gaul@digipen.edu 8 | //////////////////////////////////////////////////// 9 | 10 | // This file is used to maintain a hash table of ENTITY_CREATOR structs 11 | // Documentation: http://cecilsunkure.blogspot.com/2012/07/hash-tables.html 12 | 13 | #pragma once 14 | 15 | #include "GlobalDefines.h" 16 | #include "EntityCreator.h" 17 | #include "HashTable.h" 18 | 19 | typedef ENTITY_CREATOR *P_ENTITY_CREATOR; 20 | 21 | DECLARE_TABLE( P_ENTITY_CREATOR, MAX_KEY_LEN ); 22 | 23 | extern GET_TABLE_TYPE( P_ENTITY_CREATOR ) *ENTITY_CREATOR_TABLE; 24 | 25 | // 26 | // CreatorTableGetEntryKeys 27 | // Purpose: Returns an array of string pointers pointing to strings representing all 28 | // the various types of ID keys in the TABLE. The last key will be null to 29 | // detect when to end loop. 30 | // 31 | char **CreatorTableGetEntryKeys( unsigned maxStrLen ); 32 | -------------------------------------------------------------------------------- /AsciiEngine/EntityFactory.c: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////// 2 | // Copyright (c) 2012 ICRL 3 | // See the file LICENSE.txt for copying permission. 4 | // 5 | // Original Author: Randy Gaul 6 | // Date: 7/5/2012 7 | // Contact: r.gaul@digipen.edu 8 | //////////////////////////////////////////////////// 9 | 10 | #include "GlobalDefines.h" 11 | #include "EntityFactory.h" 12 | #include "FrameRateController.h" 13 | #include "EntityCreatorTable.h" // Map Entity creators to string IDs 14 | #include "EntityManager.h" // EntityListPush 15 | 16 | // 17 | // The Entity factory allows easy handling of creation, 18 | // deletion, updating, initializing, and drawing of all 19 | // game entities. Simply include EntityFactory.h to start 20 | // creating your entities from a state file. 21 | // Additional documentation on how Entity oriented C 22 | // works: http://cecilsunkure.blogspot.com/2012/04/entity-oriented-c-class-like-structures.html 23 | // 24 | 25 | // 26 | // CreateEntity 27 | // Purpose: Creates a game entity from an ID. This is useful since 28 | // the factory abstracts the necessity of including many 29 | // various entity files in order to just create different 30 | // kinds of entities. The factory is also key in entity 31 | // serialization. 32 | // 33 | ENTITY *CreateEntity( const char *ID, int var1, int var2 ) 34 | { 35 | ENTITY *entity = NULL; 36 | NODE_TYPE( P_ENTITY ) *node = NULL; 37 | ENTITY_CREATOR *entityCreator = FIND_DATA( P_ENTITY_CREATOR, ENTITY_CREATOR_TABLE, ID ); 38 | 39 | if(!entityCreator) 40 | return NULL; // ID mismatch (shouldn't ever get here! D:) 41 | 42 | entity = entityCreator->Create( var1, var2 ); 43 | 44 | node = NODE_CREATE( P_ENTITY, entity, DeleteEntity, entity->zOrder ); 45 | LIST_INSERT( P_ENTITY, ENTITY_LIST, node ); 46 | 47 | return entity; 48 | } 49 | 50 | // 51 | // CreateEntities 52 | // Purpose: Calles CreateEntity a number of times specified by count. 53 | // 54 | RETURN_TYPE CreateEntities( const char *ID, int var1, int var2, int count ) 55 | { 56 | int i; 57 | 58 | for(i = 0; i < count; ++i) 59 | CreateEntity( ID, var1, var2 ); 60 | 61 | return RETURN_SUCCESS; 62 | } 63 | -------------------------------------------------------------------------------- /AsciiEngine/EntityFactory.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////// 2 | // Copyright (c) 2012 ICRL 3 | // See the file LICENSE.txt for copying permission. 4 | // 5 | // Original Author: Randy Gaul 6 | // Date: 7/5/2012 7 | // Contact: r.gaul@digipen.edu 8 | //////////////////////////////////////////////////// 9 | 10 | #pragma once 11 | 12 | // 13 | // The entity factory allows easy handling of creation, 14 | // deletion, updating, initializing, and drawing of all 15 | // game entitys. Simply include EntityFactory.h to start 16 | // creating your entitys from a state file. 17 | // Additional documentation on how entity oriented C 18 | // works: http://cecilsunkure.blogspot.com/2012/04/entity-oriented-c-class-like-structures.html 19 | // 20 | 21 | #include "Entity.h" 22 | #include "EntityCreator.h" 23 | 24 | // 25 | // CreateEntity 26 | // Purpose: Creates a game entity from an ID. This is useful since 27 | // the factory abstracts the necessity of including many 28 | // various entity files in order to just create different 29 | // kinds of entitys. The factory is also key in entity 30 | // serialization. 31 | // 32 | ENTITY *CreateEntity( const char *ID, int var1, int var2 ); 33 | 34 | // 35 | // CreateEntities 36 | // Purpose: Calles CreateEntity a number of times specified by count. 37 | // 38 | RETURN_TYPE CreateEntities( const char *ID, int var1, int var2, int count ); 39 | -------------------------------------------------------------------------------- /AsciiEngine/EntityManager.c: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////// 2 | // Copyright (c) 2012 ICRL 3 | // See the file LICENSE.txt for copying permission. 4 | // 5 | // Original Author: Randy Gaul 6 | // Date: 7/17/2012 7 | // Contact: r.gaul@digipen.edu 8 | //////////////////////////////////////////////////// 9 | 10 | #include "EntityManager.h" 11 | #include "FrameRateController.h" 12 | 13 | // Start of linked list of Entities. 14 | // Linked list documentation: http://cecilsunkure.blogspot.com/2010/11/memory-allocation-and-linked-lists.html 15 | DEFINE_LIST( P_ENTITY ); 16 | LIST_TYPE( P_ENTITY ) *ENTITY_LIST = NULL; 17 | 18 | // 19 | // SendEntityMessage 20 | // Purpose: Sends a message to an entity via pointer to the entity. 21 | // 22 | void SendEntityMessage( ENTITY *entity, EM msg, int var1, int var2 ) 23 | { 24 | entity->EM_PROC( entity, msg, var1, var2 ); 25 | } 26 | 27 | // 28 | // DeleteEntity 29 | // Purpose: Used in the NODE_CREATE macro in the DeleteData param. 30 | // 31 | void DeleteEntity( P_ENTITY entity ) 32 | { 33 | entity->EM_PROC( (ENTITY *)entity, EM_DESTROY, 0, 0 ); 34 | } 35 | 36 | // 37 | // CallbackSendEntityMessage 38 | // Purpose: Used to send all entities a message. 39 | // 40 | RETURN_TYPE CallbackSendEntityMessage( NODE_TYPE( P_ENTITY ) *node, void *param ) 41 | { 42 | typedef struct 43 | { 44 | EM msg; 45 | int var1; 46 | int var2; 47 | } paramType; 48 | 49 | paramType *parameter = (paramType *)param; 50 | 51 | // Skip inactive entities 52 | if(node->data->inactive) 53 | return RETURN_SUCCESS; 54 | 55 | SendEntityMessage( node->data, parameter->msg, parameter->var1, parameter->var2 ); 56 | return RETURN_SUCCESS; 57 | } 58 | 59 | // 60 | // SendEntitiesMessage 61 | // Purpose: Sends a message to all live entities. 62 | // 63 | void SendEntitiesMessage( EM msg, int var1, int var2 ) 64 | { 65 | typedef struct 66 | { 67 | EM msg; 68 | int var1; 69 | int var2; 70 | } paramType; 71 | 72 | paramType parameter = { 73 | msg, 74 | var1, 75 | var2 76 | }; 77 | 78 | LIST_CALLER( P_ENTITY, ENTITY_LIST, CallbackSendEntityMessage, ¶meter ); 79 | } 80 | 81 | // 82 | // UpdateEntities 83 | // Purpose: Cycles the entity list and calls their update functions. 84 | // 85 | RETURN_TYPE UpdateEntities( void ) 86 | { 87 | float dt = GetDT( ); 88 | SendEntitiesMessage( EM_UPDATE, (int)&dt, 0 ); 89 | return RETURN_SUCCESS; 90 | } 91 | 92 | // 93 | // DrawEntities 94 | // Purpose: Cycles the Entity list and calls their draw functions. 95 | // 96 | RETURN_TYPE DrawEntities( void ) 97 | { 98 | SendEntitiesMessage( EM_DRAW, 0, 0 ); 99 | return RETURN_SUCCESS; 100 | } 101 | 102 | // 103 | // CallbackDeleteNode 104 | // Purpose: Used to delete all nodes. 105 | // 106 | RETURN_TYPE CallbackDeleteNode( NODE_TYPE( P_ENTITY ) *node, void *param ) 107 | { 108 | SendEntityMessage( node->data, EM_DESTROY, 0, 0 ); 109 | free( node->data ); 110 | LIST_REMOVE( P_ENTITY, ENTITY_LIST, node ); 111 | return RETURN_SUCCESS; 112 | } 113 | 114 | // 115 | // DestroyEntities 116 | // Purpose: Cycles the entity list and calls their destroy functions. 117 | // 118 | RETURN_TYPE DestroyEntities( void ) 119 | { 120 | LIST_CALLER( P_ENTITY, ENTITY_LIST, CallbackDeleteNode, 0 ); 121 | return RETURN_SUCCESS; 122 | } 123 | 124 | // 125 | // CallbackSerializeEntity 126 | // Purpose: Used to serialize all nodes. 127 | // 128 | RETURN_TYPE CallbackSerializeEntity( NODE_TYPE( P_ENTITY ) *node, void *param ) 129 | { 130 | EntityToFile( node->data ); 131 | return RETURN_SUCCESS; 132 | } 133 | 134 | // 135 | // SerializeAllEntities 136 | // Purpose: Serializes all active entities into a text file. 137 | // 138 | void SerializeAllEntities( const char *fileName ) 139 | { 140 | SerializerSetFile( fileName ); 141 | 142 | SerializeMapDimensions( ); 143 | 144 | LIST_CALLER( P_ENTITY, ENTITY_LIST, CallbackSerializeEntity, 0 ); 145 | 146 | SerializerCloseFile( ); 147 | } 148 | -------------------------------------------------------------------------------- /AsciiEngine/EntityManager.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////// 2 | // Copyright (c) 2012 ICRL 3 | // See the file LICENSE.txt for copying permission. 4 | // 5 | // Original Author: Randy Gaul 6 | // Date: 7/17/2012 7 | // Contact: r.gaul@digipen.edu 8 | //////////////////////////////////////////////////// 9 | 10 | #pragma once 11 | 12 | #include "Entity.h" 13 | #include "Message.h" 14 | #include "Serialize.h" 15 | #include "LinkedList.h" 16 | 17 | typedef ENTITY *P_ENTITY; 18 | DECLARE_LIST( P_ENTITY ); 19 | 20 | extern LIST_TYPE( P_ENTITY ) *ENTITY_LIST; 21 | 22 | // 23 | // SendEntityMessage 24 | // Purpose: Sends a message to an entity via pointer to the entity. 25 | // 26 | void SendEntityMessage( ENTITY *entity, EM msg, int var1, int var2 ); 27 | 28 | // 29 | // DeleteEntity 30 | // Purpose: Used in the NODE_CREATE macro in the DeleteData param. 31 | // 32 | void DeleteEntity( P_ENTITY entity ); 33 | 34 | // 35 | // DestroyEntities 36 | // Purpose: Cycles the entity list and calls their destroy functions. 37 | // 38 | RETURN_TYPE DestroyEntities( void ); 39 | 40 | // 41 | // SendEntitiesMessage 42 | // Purpose: Sends a message to all live entities. 43 | // 44 | void SendEntitiesMessage( EM msg, int var1, int var2 ); 45 | 46 | // 47 | // AE_UpdateEntities 48 | // Purpose: Cycles the entity list and calls their update functions. 49 | // 50 | RETURN_TYPE UpdateEntities( void ); 51 | 52 | // 53 | // AE_DrawEntities 54 | // Purpose: Cycles the entity list and calls their draw functions. 55 | // 56 | RETURN_TYPE DrawEntities( void ); 57 | 58 | // 59 | // SerializeAllEntities 60 | // Purpose: Serializes all active entities into a text file. 61 | // 62 | void SerializeAllEntities( const char *fileName ); 63 | -------------------------------------------------------------------------------- /AsciiEngine/FrameRateController.c: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////// 2 | // Copyright (c) 2012 ICRL 3 | // See the file LICENSE.txt for copying permission. 4 | // 5 | // Original Author: Randy Gaul 6 | // Date: 7/3/2012 7 | // Contact: r.gaul@digipen.edu 8 | //////////////////////////////////////////////////// 9 | 10 | // Documentation: http://cecilsunkure.blogspot.com/2012/02/game-program-design-game-state-manager.html 11 | 12 | #include 13 | #pragma comment(lib, "winmm.lib") 14 | #include "GlobalDefines.h" // DT_MAX 15 | #include "FrameRateController.h" 16 | 17 | float previousTime; 18 | float timeAtFrameStart; 19 | float stateStartTime; 20 | LARGE_INTEGER FREQUENCY; 21 | float F_FREQUENCY = 1.0f / FPS_LIMIT; // Used to limit FPS 22 | int firstRun = 1; // to see if the application just started 23 | static float dt; 24 | 25 | // 26 | // SetDT 27 | // Purpose: Sets DT to a specific value 28 | // 29 | void SetDT( float deltaTime ) 30 | { 31 | dt = deltaTime; 32 | } 33 | void dtCap( float *dt ); 34 | 35 | // 36 | // GetDT 37 | // Purpose: Retrieves and caps the current DT 38 | // 39 | float GetDT( void ) 40 | { 41 | dtCap( &dt ); 42 | return dt; 43 | } 44 | 45 | // 46 | // GetTimeAtFrameStart 47 | // Purpose: Retrieves the current game time at frame start in high resolution seconds 48 | // 49 | float GetTimeAtFrameStart( void ) 50 | { 51 | return timeAtFrameStart; 52 | } 53 | 54 | // 55 | // GetCurrentGameTime 56 | // Purpose: Retrieves the current game time in high resolution seconds 57 | // 58 | float GetCurrentGameTime( void ) 59 | { 60 | LARGE_INTEGER currentTime; 61 | QueryPerformanceCounter( ¤tTime ); 62 | return (float)(currentTime.QuadPart) / (float)(FREQUENCY.QuadPart); 63 | } 64 | 65 | // 66 | // Name: SetStateStartTime 67 | // Purpose: Records the time at function call. 68 | // 69 | void SetStateStartTime( void ) 70 | { 71 | stateStartTime = GetCurrentGameTime( ); 72 | } 73 | 74 | // 75 | // Name: GetStateStartTime 76 | // Purpose: Returns the recorded state start time. 77 | // 78 | float GetStateStartTime( void ) 79 | { 80 | return stateStartTime; 81 | } 82 | 83 | // 84 | // Name: FrameStart 85 | // Purpose: Catch the time of when the frame first starts 86 | // 87 | void FrameStart( void ) 88 | { 89 | timeAtFrameStart = GetCurrentGameTime( ); 90 | } 91 | 92 | // 93 | // Name: dtCalculate 94 | // Purpose: Calculates the change in time since the last calculation of dt 95 | // 96 | float dtCalculate( ) 97 | { 98 | float currentTime = GetCurrentGameTime( ); // record current time 99 | float dt = currentTime - previousTime; // calculate dt 100 | previousTime = currentTime; // set previousTime for the next call 101 | 102 | if(firstRun) 103 | { 104 | dt = 0.f; 105 | firstRun = 0; 106 | } 107 | return dt; 108 | } 109 | 110 | // 111 | // Name: dtCap 112 | // Purpose: Caps dt to a specified amount. This ensures that a really 113 | // huge timestep won't occur of the computer lags, or the window 114 | // is paused. 115 | // 116 | void dtCap( float *dt ) 117 | { 118 | if(dt) 119 | { 120 | if(*dt > F_FREQUENCY) 121 | { 122 | *dt = F_FREQUENCY; 123 | } 124 | } 125 | } 126 | 127 | // 128 | // Name: FPSLimit 129 | // Purpose: Limit the FPS in terms of drawing to a specific speed 130 | // Parameters: FPS - Max amount of frames per second 131 | // 132 | BOOL FPSLimit( void ) 133 | { 134 | enum 135 | { 136 | DONTDRAW, 137 | DRAW 138 | }; 139 | 140 | if (GetCurrentGameTime( ) - timeAtFrameStart < F_FREQUENCY) // If we are not over our threshold 141 | { 142 | return DONTDRAW; 143 | } 144 | else 145 | { 146 | return DRAW; 147 | } 148 | } 149 | 150 | // 151 | // InitFrameRateController 152 | // Purpose: Initializes various values for the framerate controller 153 | // 154 | RETURN_TYPE InitFrameRateController( void ) 155 | { 156 | F_FREQUENCY = (float)((int)(F_FREQUENCY * 1000.0f)) / 1000.0f; 157 | return QueryPerformanceFrequency( &FREQUENCY ); 158 | } -------------------------------------------------------------------------------- /AsciiEngine/FrameRateController.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////// 2 | // Copyright (c) 2012 ICRL 3 | // See the file LICENSE.txt for copying permission. 4 | // 5 | // Original Author: Randy Gaul 6 | // Date: 7/3/2012 7 | // Contact: r.gaul@digipen.edu 8 | //////////////////////////////////////////////////// 9 | 10 | // Documentation: http://cecilsunkure.blogspot.com/2012/02/game-program-design-game-state-manager.html 11 | 12 | #ifndef FRAMERATECONTROLLERH 13 | #define FRAMERATECONTROLLERH 14 | 15 | #include "GlobalDefines.h" 16 | 17 | void FrameStart( void ); 18 | float dtCalculate( void ); 19 | BOOL FPSLimit( void ); 20 | void dtCap( float *dt ); 21 | void SetStateStartTime( void ); 22 | float GetStateStartTime( void ); 23 | void SetDT( float deltaTime ); 24 | float GetDT( void ); 25 | float GetTimeAtFrameStart( void ); 26 | float GetCurrentGameTime( void ); 27 | RETURN_TYPE InitFrameRateController( void ); 28 | 29 | #endif FRAMERATECONTROLLERH -------------------------------------------------------------------------------- /AsciiEngine/GameStateList.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////// 2 | // Copyright (c) 2012 ICRL 3 | // See the file LICENSE.txt for copying permission. 4 | // 5 | // Original Author: Randy Gaul 6 | // Date: 7/3/2012 7 | // Contact: r.gaul@digipen.edu 8 | //////////////////////////////////////////////////// 9 | 10 | // Documentation: http://cecilsunkure.blogspot.com/2012/02/game-program-design-game-state-manager.html 11 | 12 | #ifndef GAMESTATELISTH 13 | #define GAMESTATELISTH 14 | 15 | #include "GlobalDefines.h" 16 | #include "TestLevel.h" 17 | #include "TestLevel2.h" 18 | #include "MapEditor.h" 19 | 20 | enum GameState_ 21 | { 22 | Restart, 23 | Quit, 24 | TestLevel, 25 | TestLevel2, 26 | MapEditor, 27 | } GAME_STATE; 28 | 29 | #endif // GAMESTATELISTH -------------------------------------------------------------------------------- /AsciiEngine/GameStateManager.c: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////// 2 | // Copyright (c) 2012 ICRL 3 | // See the file LICENSE.txt for copying permission. 4 | // 5 | // Original Author: Randy Gaul 6 | // Date: 7/3/2012 7 | // Contact: r.gaul@digipen.edu 8 | //////////////////////////////////////////////////// 9 | 10 | // This file manages the states of the game 11 | // Documentation: http://cecilsunkure.blogspot.com/2012/02/game-program-design-game-state-manager.html 12 | 13 | #include "GameStateList.h" 14 | #include "GameStateManager.h" 15 | #include "GlobalDefines.h" 16 | 17 | // These three states are global variables for holding the values of states. 18 | stateIndicator nextState; 19 | stateIndicator previousState; 20 | stateIndicator currentState; 21 | 22 | // Globals for function pointers for any state. To point at functions in other files. 23 | RETURN_TYPE (*Load)( void ); 24 | RETURN_TYPE (*Initialize)( void ); 25 | RETURN_TYPE (*Update)( ); 26 | RETURN_TYPE (*Draw)( void ); 27 | RETURN_TYPE (*Free)( void ); 28 | RETURN_TYPE (*Unload)( void ); 29 | 30 | // Initialize the Game State Manager by pointing the three states at an initial state. 31 | int GSM_Initialize( stateIndicator initVal ) 32 | { 33 | nextState = initVal; 34 | previousState = initVal; 35 | currentState = initVal; 36 | 37 | return RETURN_SUCCESS; 38 | } 39 | 40 | // Update the Game State Manager by syncing the three state indicators to their 41 | // corresponding function pointers (all six of them). 42 | int GSM_Update( void ) 43 | { 44 | switch(currentState) 45 | { 46 | case TestLevel: 47 | Load = &TestLevelLoad; 48 | Initialize = &TestLevelInit; 49 | Update = &TestLevelUpdate; 50 | Draw = &TestLevelDraw; 51 | Free = &TestLevelFree; 52 | Unload = &TestLevelUnload; 53 | break; 54 | case TestLevel2: 55 | Load = &TestLevel2Load; 56 | Initialize = &TestLevel2Init; 57 | Update = &TestLevel2Update; 58 | Draw = &TestLevel2Draw; 59 | Free = &TestLevel2Free; 60 | Unload = &TestLevel2Unload; 61 | break; 62 | case MapEditor: 63 | Load = &MapEditorLoad; 64 | Initialize = &MapEditorInit; 65 | Update = &MapEditorUpdate; 66 | Draw = &MapEditorDraw; 67 | Free = &MapEditorFree; 68 | Unload = &MapEditorUnload; 69 | break; 70 | /* 71 | case Template: 72 | Load = &Load; 73 | Initialize = &Initialize; 74 | Update = &Update; 75 | Draw = &Draw; 76 | Free = &Free; 77 | Unload = &Unload; 78 | break;*/ 79 | case Restart: 80 | break; 81 | case Quit: 82 | break; 83 | } 84 | 85 | return RETURN_SUCCESS; 86 | } -------------------------------------------------------------------------------- /AsciiEngine/GameStateManager.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////// 2 | // Copyright (c) 2012 ICRL 3 | // See the file LICENSE.txt for copying permission. 4 | // 5 | // Original Author: Randy Gaul 6 | // Date: 7/3/2012 7 | // Contact: r.gaul@digipen.edu 8 | //////////////////////////////////////////////////// 9 | 10 | #ifndef GAMESTATEMANAGERH 11 | #define GAMESTATEMANAGERH 12 | 13 | #include "GameStateList.h" 14 | 15 | typedef unsigned int stateIndicator; 16 | 17 | extern stateIndicator currentState; 18 | extern stateIndicator previousState; 19 | extern stateIndicator nextState; 20 | 21 | extern RETURN_TYPE (*Load)( void ); 22 | extern RETURN_TYPE (*Initialize)( void ); 23 | extern RETURN_TYPE (*Update)( void ); 24 | extern RETURN_TYPE (*Draw)( void ); 25 | extern RETURN_TYPE (*Free)( void ); 26 | extern RETURN_TYPE (*Unload)( void ); 27 | 28 | int GSM_Initialize( stateIndicator initVal ); 29 | int GSM_Update( void ); 30 | 31 | #endif // GAMESTATEMANAGERH -------------------------------------------------------------------------------- /AsciiEngine/GlobalDefines.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////// 2 | // Copyright (c) 2012 ICRL 3 | // See the file LICENSE.txt for copying permission. 4 | // 5 | // Original Author: Randy Gaul 6 | // Date: 7/3/2012 7 | // Contact: r.gaul@digipen.edu 8 | //////////////////////////////////////////////////// 9 | 10 | #ifndef GLOBALDEFINESH 11 | #define GLOBALDEFINESH 12 | 13 | #include 14 | #include 15 | #include 16 | #include "Properties.h" 17 | 18 | #define CLIENT_WIDTH 75 19 | #define CLIENT_WIDTH_HALF 37.5f 20 | #define CLIENT_HEIGHT 50 21 | #define CLIENT_HEIGHT_HALF 25.0f 22 | 23 | #define FPS_LIMIT ((float)( 30 )) 24 | // Compile switch for displaying (or not) the FPS onto the screen 25 | #define DISPLAY_FPS 26 | 27 | #define TRUE 1 28 | #define FALSE 0 29 | 30 | #define TRANSPERANT 255 31 | 32 | #define GRAVITY 80.f 33 | #define PLAYER_JUMP_HEIGHT -33.0f 34 | #define LEFT_RIGHT_SPEED 15.f 35 | 36 | // CAMERA STUFF 37 | #define ENABLE_CAM 1 38 | #define DISABLE_CAM 0 39 | #define CAMOFFX ((self->base.enableCam) ? 0 : GLOBAL_CAM.center.x_) 40 | #define CAMOFFY ((self->base.enableCam) ? 0 : GLOBAL_CAM.center.y_ + 1) 41 | 42 | // VISUALS 43 | #define DAMAGE_TEXT_FLOAT_VEL -5.f 44 | #define DAMAGE_TEXT_FLOAT_TIME 2.f 45 | #define ITEM_PARTICLE_SPAWN_COUNT 6 46 | #define ITEM_PARTICLE_VELOCITY_RANGE 10 47 | #define ITEM_PARTICLE_DELAY (float)RandomInt( 1, 4 ) / 8.f 48 | 49 | // UI stuff 50 | #define INVENTORY_BUTTON_DEBOUNCE_TIME .1f 51 | 52 | // Takes a pointer and returns a pointer offset in bytes 53 | #define PtrAdd( ptr, offset ) \ 54 | (((char *)ptr) + offset) 55 | 56 | #define DT_MAX 60.0f 57 | 58 | typedef enum 59 | { 60 | RETURN_SUCCESS, 61 | RETURN_FAILURE 62 | } RETURN_TYPE; 63 | 64 | /* ASCII key definitions */ 65 | #define ASCII_a (unsigned char)97 66 | #define ASCII_b (unsigned char)98 67 | #define ASCII_c (unsigned char)99 68 | #define ASCII_d (unsigned char)100 69 | #define ASCII_e (unsigned char)101 70 | #define ASCII_f (unsigned char)102 71 | #define ASCII_g (unsigned char)103 72 | #define ASCII_h (unsigned char)104 73 | #define ASCII_i (unsigned char)105 74 | #define ASCII_j (unsigned char)106 75 | #define ASCII_k (unsigned char)107 76 | #define ASCII_l (unsigned char)108 77 | #define ASCII_m (unsigned char)109 78 | #define ASCII_n (unsigned char)110 79 | #define ASCII_o (unsigned char)111 80 | #define ASCII_p (unsigned char)112 81 | #define ASCII_q (unsigned char)113 82 | #define ASCII_r (unsigned char)114 83 | #define ASCII_s (unsigned char)115 84 | #define ASCII_t (unsigned char)116 85 | #define ASCII_u (unsigned char)117 86 | #define ASCII_v (unsigned char)118 87 | #define ASCII_w (unsigned char)119 88 | #define ASCII_x (unsigned char)120 89 | #define ASCII_y (unsigned char)121 90 | #define ASCII_z (unsigned char)122 91 | #define ASCII_RETURN (unsigned char)13 92 | #define ASCII_BACKSPACE (unsigned char)8 93 | #define ASCII_SPACE (unsigned char)32 94 | 95 | #define ASCII_A (unsigned char)65 96 | #define ASCII_B (unsigned char)66 97 | #define ASCII_C (unsigned char)67 98 | #define ASCII_D (unsigned char)68 99 | #define ASCII_E (unsigned char)69 100 | #define ASCII_F (unsigned char)70 101 | #define ASCII_G (unsigned char)71 102 | #define ASCII_H (unsigned char)72 103 | #define ASCII_I (unsigned char)73 104 | #define ASCII_J (unsigned char)74 105 | #define ASCII_K (unsigned char)75 106 | #define ASCII_L (unsigned char)76 107 | #define ASCII_M (unsigned char)77 108 | #define ASCII_N (unsigned char)78 109 | #define ASCII_O (unsigned char)79 110 | #define ASCII_P (unsigned char)80 111 | #define ASCII_Q (unsigned char)81 112 | #define ASCII_R (unsigned char)82 113 | #define ASCII_S (unsigned char)83 114 | #define ASCII_T (unsigned char)84 115 | #define ASCII_U (unsigned char)85 116 | #define ASCII_V (unsigned char)86 117 | #define ASCII_W (unsigned char)87 118 | #define ASCII_X (unsigned char)88 119 | #define ASCII_Y (unsigned char)89 120 | #define ASCII_Z (unsigned char)90 121 | 122 | /* Virtual key definitions (type int) */ 123 | // http://msdn.microsoft.com/en-us/library/windows/desktop/dd375731(v=vs.85).aspx 124 | typedef enum _VIRTUAL_KEY 125 | { 126 | VK_0 = 0x30, 127 | VK_1, 128 | VK_2, 129 | VK_3, 130 | VK_4, 131 | VK_5, 132 | VK_6, 133 | VK_7, 134 | VK_8, 135 | VK_9, 136 | VK_A = 0x41, 137 | VK_B, 138 | VK_C, 139 | VK_D, 140 | VK_E, 141 | VK_F, 142 | VK_G, 143 | VK_H, 144 | VK_I, 145 | VK_J, 146 | VK_K, 147 | VK_L, 148 | VK_M, 149 | VK_N, 150 | VK_O, 151 | VK_P, 152 | VK_Q, 153 | VK_R, 154 | VK_S, 155 | VK_T, 156 | VK_U, 157 | VK_V, 158 | VK_W, 159 | VK_X, 160 | VK_Y, 161 | VK_Z, 162 | VK_ENTER = 0x0D, 163 | } VIRTUAL_KEY; 164 | 165 | #endif GLOBALDEFINESH -------------------------------------------------------------------------------- /AsciiEngine/Graphics.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////// 2 | // Copyright (c) 2012 ICRL 3 | // See the file LICENSE.txt for copying permission. 4 | // 5 | // Original Author: Randy Gaul 6 | // Date: 7/3/2012 7 | // Contact: r.gaul@digipen.edu 8 | //////////////////////////////////////////////////// 9 | 10 | // Documentation: http://cecilsunkure.blogspot.com/2011/12/windows-console-game-painters-algorithm.html 11 | // http://cecilsunkure.blogspot.com/2012/02/windows-console-game-variable-sized.html 12 | 13 | #ifndef GRAPHICSH 14 | #define GRAPHICSH 15 | 16 | #include 17 | #include 18 | #include "GlobalDefines.h" 19 | #include "Math2D.h" 20 | 21 | #define CHAR unsigned char 22 | #define COL unsigned char 23 | 24 | #define FOREGROUND_COLOR_1 0x0001 25 | #define FOREGROUND_COLOR_2 0x0002 26 | #define FOREGROUND_COLOR_3 0x0004 27 | #define FOREGROUND_INTENSITY 0x0008 28 | #define BACKGROUND_COLOR_1 0x0010 29 | #define BACKGROUND_COLOR_2 0x0020 30 | #define BACKGROUND_COLOR_3 0x0040 31 | #define BACKGROUND_INTENSITY 0x0080 32 | 33 | #define CharAt( image, x, y ) \ 34 | (CHAR *)(PtrAdd( image->chars, ((y) * image->width + (x)) * sizeof( CHAR ) )) 35 | 36 | #define ColorAt( image, x, y ) \ 37 | (COL *)(PtrAdd( image->colors, ((y) * image->width + (x)) * sizeof( COL ) )) 38 | 39 | extern CHAR_INFO *DOUBLE_BUFFER; 40 | extern int BUFFERHEIGHT; 41 | extern int BUFFERWIDTH; 42 | 43 | typedef struct _IMAGE 44 | { 45 | char *ID; // Image name string, must be unique identifier 46 | int width; 47 | int height; 48 | unsigned char *chars; 49 | unsigned char *colors; 50 | } IMAGE; 51 | 52 | typedef struct _ANIMATION 53 | { 54 | int numFrames; // Number of frames 55 | int currentFrame; // The current frame to display 56 | unsigned playCount; // Number of times the animation has played 57 | float frameDelay; // Time in seconds to delay between each frame 58 | float dt; // Used to store a time value 59 | BOOL isPaused; // Boolean for play/pause 60 | IMAGE **frames; // Conainer for frames 61 | } ANIMATION; 62 | 63 | typedef enum 64 | { 65 | ENTRY_IMAGE, 66 | ENTRY_ANIMATION, 67 | } ENTRY_TYPE; 68 | 69 | void ClearBuffer( void ); 70 | IMAGE *AllocateImage( const char *string, int width, int height ); 71 | 72 | // 73 | // AllocateAnimation 74 | // Purpose: Allocates and initializes a new ANIMATION struct 75 | // Notes : The last parameter must be NULL. Example: 76 | // AllocateAnimation( frameDelay, "FirstFrame", "SecondFrame", NULL ); 77 | // frameDelay is a float representing SECONDS 78 | // 79 | ANIMATION *AllocateAnimation( float frameDelay, const char *firstFrame, ... ); 80 | // 81 | // UpdateAnimation 82 | // Purpose: Updates an animation 83 | // 84 | int UpdateAnimation( ANIMATION *animation, float dt ); 85 | 86 | RETURN_TYPE DeallocateImage( IMAGE *image ); 87 | RETURN_TYPE DeallocateAnimation( ANIMATION *animation ); 88 | void ImageSet( IMAGE *image, CHAR *charData, COL *colorData ); 89 | void ZeroImage( IMAGE *image ); 90 | void InitGraphics( int width, int height ); 91 | RETURN_TYPE DeallocateImage( IMAGE *image ); 92 | RETURN_TYPE RenderPImageToScreen( IMAGE *image, int xoffset, int yoffset ); 93 | RETURN_TYPE RenderPImageToScreenNoCam( IMAGE *image, int xoffset, int yoffset ); 94 | RETURN_TYPE WriteImageToScreen( const char *imageID, int xoffset, int yoffset ); 95 | RETURN_TYPE WriteImageToScreenNoCam( const char *imageID, int xoffset, int yoffset ); 96 | RETURN_TYPE WriteCharToImage( IMAGE *image, CHAR character, COL color, int x, int y ); 97 | void WriteStringToScreen( char string[], int x, int y ); 98 | void WriteStringToScreenNoCam( char string[], int x, int y ); 99 | RETURN_TYPE WriteImageToImage( const char *drawOnMe, const char *drawWithMe, int xOffset, int yOffset );// Writes an image onto the DOUBLE_BUFFER 100 | // Does NOT render the DOUBLE_BUFFER to the screen 101 | // Only draws from the coordinates of topLeft and topRight on the source image 102 | RETURN_TYPE WritePortionOfImageToScreen( const char *imageID, AE_COORD topLeft, AE_COORD bottomRight, int xoffset, int yoffset ); 103 | 104 | // Integer to string 105 | void inttostr(int number, char string[]); 106 | // 107 | // DimensionOffset 108 | // Purpose: Returns EPSILON or 1.f depending on odd/even 109 | // 110 | float DimensionOffset( float dimension ); 111 | 112 | #endif GRAPHICSH -------------------------------------------------------------------------------- /AsciiEngine/GraphicsComponent.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////// 2 | // Copyright (c) 2012 ICRL 3 | // See the file LICENSE.txt for copying permission. 4 | // 5 | // Original Author: Randy Gaul 6 | // Date: 7/16/2012 7 | // Contact: r.gaul@digipen.edu 8 | //////////////////////////////////////////////////// 9 | 10 | #pragma once 11 | 12 | #include "Message.h" 13 | 14 | // Forward decl 15 | struct _ENTITY; 16 | 17 | // 18 | // Common interface for all graphics components. 19 | // 20 | typedef struct _GRAPHICS_COMPONENT 21 | { 22 | const char *CLASS_NAME; 23 | void (*COM_PROC)( struct _GRAPHICS_COMPONENT *self, EM msg, int var1, int var2 ); 24 | BOOL enableCam; 25 | struct _ENTITY *owner; 26 | } GRAPHICS_COMPONENT; 27 | -------------------------------------------------------------------------------- /AsciiEngine/Hero.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////// 2 | // Copyright (c) 2012 ICRL 3 | // See the file LICENSE.txt for copying permission. 4 | // 5 | // Original Author: Randy Gaul 6 | // Date: 7/5/2012 7 | // Contact: r.gaul@digipen.edu 8 | //////////////////////////////////////////////////// 9 | 10 | #ifndef HEROH 11 | #define HEROH 12 | 13 | #include "EntityCreator.h" 14 | 15 | // Definition of the creator of this entity 16 | extern ENTITY_CREATOR HERO_CREATOR; 17 | 18 | #endif HEROH 19 | -------------------------------------------------------------------------------- /AsciiEngine/Hitpoints.c: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////// 2 | // Copyright (c) 2012 ICRL 3 | // See the file LICENSE.txt for copying permission. 4 | // 5 | // Original Author: Randy Gaul 6 | // Date: 7/22/2012 7 | // Contact: r.gaul@digipen.edu 8 | //////////////////////////////////////////////////// 9 | 10 | #include "Hitpoints.h" 11 | #include "EntityManager.h" 12 | #include "EntityFactory.h" 13 | 14 | // Static class variables and data 15 | static const char *CLASS_NAME = NULL; 16 | 17 | // 18 | // ClassCOM_PROC 19 | // Purpose: Component procedure for this component type. Dispatches messages 20 | // recieved in the appropriate manner. 21 | // 22 | void HitPointsCOM_PROC( HP *self, EM msg, int var1, int var2 ) 23 | { 24 | // GENERAL 25 | switch(msg) 26 | { 27 | case EM_CLSINIT: 28 | HitPointsInit( (const char *)var1 ); 29 | break; 30 | case EM_CREATE: 31 | HitPointsCreate( self, var1 ); 32 | break; 33 | case EM_UPDATE: 34 | HitPointsUpdate( self, (float *)var1 ); 35 | break; 36 | 37 | // DATA ACCESS 38 | case EM_GETHP: 39 | HitPointsGet( self, (int *)var1 ); 40 | break; 41 | case EM_SETHP: 42 | HitPointsSet( self, var1 ); 43 | break; 44 | case EM_DAMAGEHP: 45 | HitPointsDamage( self, var1 ); 46 | break; 47 | case EM_HEALHP: 48 | HitPointsHeal( self, var1 ); 49 | break; 50 | } 51 | } 52 | 53 | // 54 | // ClassCreate 55 | // Purpose: Acts as a constructor for this class. Initializes the 56 | // data and dynamically allocates any extra space needed, and 57 | // initializes the allocated space with data. 58 | // 59 | void HitPointsCreate( HP *self, int hp ) 60 | { 61 | self->hp = (hp >= 0) ? hp : 1; 62 | // FIXME : ability to set maxhp through param2 63 | self->maxHP = 20; 64 | } 65 | 66 | // 67 | // ClassInit 68 | // Purpose: One-time initialization of the class. Use this function to load resources from disk, 69 | // set up static class variables, or anything else. 70 | // 71 | void HitPointsInit( const char *className ) 72 | { 73 | CLASS_NAME = (const char *)malloc( strlen( className ) + 1 ); 74 | strcpy_s( (char *)CLASS_NAME, strlen( className ) + 1 , className ); 75 | } 76 | 77 | // 78 | // ClassUpdate 79 | // Purpose: Uses float *dt to update various aspects of the component. 80 | // 81 | void HitPointsUpdate( HP *self, float *dt ) 82 | { 83 | if(self->hp == 0) 84 | SendEntityMessage( self->base.owner, EM_INACTIVE, 0, 0 ); 85 | } 86 | 87 | // 88 | // HitPointsGet 89 | // Purpose: Retrieves int HP and copies into int *var1 90 | // 91 | void HitPointsGet( HP *self, int *hp ) 92 | { 93 | *hp = self->hp; 94 | } 95 | 96 | // 97 | // HitPointsSet 98 | // Purpose: Retrieves int HP and copies into int *var1 99 | // 100 | void HitPointsSet( HP *self, int hp ) 101 | { 102 | self->hp = (hp < self->maxHP) ? hp : self->maxHP; 103 | } 104 | 105 | // 106 | // HitPointsDamage 107 | // Purpose: Subtracts an int var1 from the hp data member, but does not go lower than zero 108 | // 109 | void HitPointsDamage( HP *self, int damage ) 110 | { 111 | if(self->hp - damage > 0) 112 | self->hp -= damage; 113 | else 114 | self->hp = 0; 115 | 116 | CreateEntity( "DAMAGE_TEXT", (int)self->base.owner, damage ); 117 | } 118 | 119 | // 120 | // HitPointsHeal 121 | // Purpose: Adds an int var1 from the hp data member, but does not go above than self->maxHP 122 | // 123 | void HitPointsHeal( HP *self, int heal ) 124 | { 125 | if((self->hp + heal) < self->maxHP) 126 | self->hp += heal; 127 | else 128 | self->hp = self->maxHP; 129 | } 130 | -------------------------------------------------------------------------------- /AsciiEngine/Hitpoints.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////// 2 | // Copyright (c) 2012 ICRL 3 | // See the file LICENSE.txt for copying permission. 4 | // 5 | // Original Author: Randy Gaul 6 | // Date: 7/22/2012 7 | // Contact: r.gaul@digipen.edu 8 | //////////////////////////////////////////////////// 9 | 10 | #pragma once 11 | 12 | #include "HitpointsComponent.h" 13 | 14 | #define PLAYER_MAX_HP 20 15 | 16 | // 17 | // HP class 18 | // This class is derived from the HITPOINTS_COMPONENT base, and represents 19 | // normal HP. 20 | // 21 | typedef struct _NORMAL_HITPOINTS_COMPONENT 22 | { 23 | HITPOINTS_COMPONENT base; 24 | int hp; 25 | int maxHP; 26 | } HP; 27 | 28 | // 29 | // ClassCOM_PROC 30 | // Purpose: Component procedure for this component type. Dispatches messages 31 | // recieved in the appropriate manner. 32 | // 33 | void HitPointsCOM_PROC( HP *self, EM msg, int var1, int var2 ); 34 | 35 | // 36 | // ClassCreate 37 | // Purpose: Acts as a constructor for this class. Initializes the 38 | // data and dynamically allocates any extra space needed, and 39 | // initializes the allocated space with data. 40 | // 41 | void HitPointsCreate( HP *self, int hp ); 42 | 43 | // 44 | // ClassInit 45 | // Purpose: One-time initialization of the class. Use this function to load resources from disk, 46 | // set up static class variables, or anything else. 47 | // 48 | void HitPointsInit( const char *className ); 49 | 50 | // 51 | // AnimationUpdate 52 | // Purpose: 53 | // 54 | void HitPointsUpdate( HP *self, float *dt ); 55 | 56 | // 57 | // HitPointsGet 58 | // Purpose: Retrieves int HP and copies into int *var1 59 | // 60 | void HitPointsGet( HP *self, int *hp ); 61 | 62 | // 63 | // HitPointsSet 64 | // Purpose: Retrieves int HP and copies into int *var1 65 | // 66 | void HitPointsSet( HP *self, int hp ); 67 | 68 | // 69 | // HitPointsDamage 70 | // Purpose: Subtracts an int var1 from the hp data member, but does not go lower than zero 71 | // 72 | void HitPointsDamage( HP *self, int damage ); 73 | 74 | // 75 | // HitPointsHeal 76 | // Purpose: adds an int var1 from the hp data member, but does not go above than self->maxHP 77 | // 78 | void HitPointsHeal( HP *self, int heal ); 79 | -------------------------------------------------------------------------------- /AsciiEngine/HitpointsComponent.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////// 2 | // Copyright (c) 2012 ICRL 3 | // See the file LICENSE.txt for copying permission. 4 | // 5 | // Original Author: Randy Gaul 6 | // Date: 7/22/2012 7 | // Contact: r.gaul@digipen.edu 8 | //////////////////////////////////////////////////// 9 | 10 | #pragma once 11 | 12 | #include "Message.h" 13 | 14 | // Forward decl 15 | struct _ENTITY; 16 | 17 | // 18 | // Common interface for all hitpoints components. 19 | // 20 | typedef struct _HITPOINTS_COMPONENT 21 | { 22 | const char *CLASS_NAME; 23 | void (*COM_PROC)( struct _HITPOINTS_COMPONENT *self, EM msg, int var1, int var2 ); 24 | struct _ENTITY *owner; 25 | } HITPOINTS_COMPONENT; 26 | -------------------------------------------------------------------------------- /AsciiEngine/ImageTable.c: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////// 2 | // Copyright (c) 2012 ICRL 3 | // See the file LICENSE.txt for copying permission. 4 | // 5 | // Original Author: Randy Gaul 6 | // Date: 7/15/2012 7 | // Contact: r.gaul@digipen.edu 8 | //////////////////////////////////////////////////// 9 | 10 | 11 | // This file is used to maintain a hash table of IMAGE structs 12 | // Documentation: http://cecilsunkure.blogspot.com/2012/07/hash-tables.html 13 | 14 | #include "ImageTable.h" 15 | 16 | GET_TABLE_TYPE( P_IMAGE ) *IMAGE_TABLE = NULL; 17 | 18 | DEFINE_TABLE( P_IMAGE, DeallocateImage ); 19 | -------------------------------------------------------------------------------- /AsciiEngine/ImageTable.h: -------------------------------------------------------------------------------- 1 | #ifndef IMAGETABLEH 2 | #define IMAGETABLEH 3 | 4 | // This file is used to maintain a hash table of IMAGE structs 5 | // Documentation: http://cecilsunkure.blogspot.com/2012/07/hash-tables.html 6 | 7 | #include "HashTable.h" 8 | #include "Graphics.h" 9 | 10 | typedef IMAGE *P_IMAGE; 11 | 12 | DECLARE_TABLE( P_IMAGE, MAX_KEY_LEN ); 13 | 14 | extern GET_TABLE_TYPE( P_IMAGE ) *IMAGE_TABLE; 15 | 16 | 17 | #endif IMAGETABLEH -------------------------------------------------------------------------------- /AsciiEngine/Input.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////// 2 | // Copyright (c) 2012 ICRL 3 | // See the file LICENSE.txt for copying permission. 4 | // 5 | // Original Author: Randy Gaul 6 | // Date: 7/3/2012 7 | // Contact: r.gaul@digipen.edu 8 | //////////////////////////////////////////////////// 9 | 10 | // Documentation: http://cecilsunkure.blogspot.com/2011/11/windows-console-game-event-handling.html 11 | 12 | #ifndef INPUTH 13 | #define INPUTH 14 | 15 | typedef int VIRTUAL_KEY; 16 | 17 | // 18 | // Structure containing all the keys, refer to these in the program to see if something is 19 | // pressed or not. 20 | // 21 | typedef struct 22 | { 23 | BOOL Key_A; 24 | BOOL Key_B; 25 | BOOL Key_C; 26 | BOOL Key_D; 27 | BOOL Key_E; 28 | BOOL Key_F; 29 | BOOL Key_G; 30 | BOOL Key_H; 31 | BOOL Key_I; 32 | BOOL Key_J; 33 | BOOL Key_K; 34 | BOOL Key_L; 35 | BOOL Key_M; 36 | BOOL Key_N; 37 | BOOL Key_O; 38 | BOOL Key_P; 39 | BOOL Key_Q; 40 | BOOL Key_R; 41 | BOOL Key_S; 42 | BOOL Key_T; 43 | BOOL Key_U; 44 | BOOL Key_V; 45 | BOOL Key_W; 46 | BOOL Key_X; 47 | BOOL Key_Y; 48 | BOOL Key_Z; 49 | BOOL Key_1; 50 | BOOL Key_2; 51 | BOOL Key_3; 52 | BOOL Key_4; 53 | BOOL Key_5; 54 | BOOL Key_6; 55 | BOOL Key_7; 56 | BOOL Key_8; 57 | BOOL Key_9; 58 | BOOL Key_0; 59 | BOOL Key_Space; 60 | BOOL Key_Ctrl; 61 | BOOL Key_Shift; 62 | BOOL Arrow_Up; 63 | BOOL Arrow_Left; 64 | BOOL Arrow_Down; 65 | BOOL Arrow_Right; 66 | BOOL Control; 67 | BOOL Backspace; 68 | BOOL Shift; 69 | BOOL Enter; 70 | BOOL L_Button; // Mouse 71 | BOOL R_Button; // Mouse 72 | int xPos; // Mouse (within window) 73 | int yPos; // Mouse (within window) 74 | int xPosAtLastLeftClick; // x position of cursor relative to draw area during last left or right click 75 | int yPosAtLastLeftClick; // y position of cursor relative to draw area during last left or right click 76 | int xPosAtLastRightClick; // x position of cursor relative to draw area during last left or right click 77 | int yPosAtLastRightClick; // y position of cursor relative to draw area during last left or right click 78 | } GlobalInputs; 79 | 80 | extern GlobalInputs GLOBAL_INPUTS; 81 | 82 | // 83 | // UpdateInput 84 | // Purpose: Reads the console's input buffer and updates all keys within 85 | // the GlobalInputs struct 86 | // 87 | void UpdateInput( void ); 88 | 89 | // 90 | // IsKeyPressed 91 | // Purpose: Checks to see if a specific key is pressed or not; returns BOOL 92 | // 93 | BOOL IsKeyPressed( VIRTUAL_KEY key ); 94 | 95 | void ClearLastMouseClick( void ); 96 | 97 | #endif INPUTH -------------------------------------------------------------------------------- /AsciiEngine/InventoryComponent.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////// 2 | // Copyright (c) 2012 ICRL 3 | // See the file LICENSE.txt for copying permission. 4 | // 5 | // Original Author: Randy Gaul 6 | // Date: 7/24/2012 7 | // Contact: r.gaul@digipen.edu 8 | //////////////////////////////////////////////////// 9 | 10 | #pragma once 11 | 12 | #include "Message.h" 13 | 14 | // Forward decl 15 | struct _ENTITY; 16 | 17 | // 18 | // Common interface for all hitpoints components. 19 | // 20 | typedef struct _INVENTORY_COMPONENT 21 | { 22 | const char *CLASS_NAME; 23 | void (*COM_PROC)( struct _INVENTORY_COMPONENT *self, EM msg, int var1, int var2 ); 24 | struct _ENTITY *owner; 25 | } INVENTORY_COMPONENT; 26 | -------------------------------------------------------------------------------- /AsciiEngine/Item.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////// 2 | // Copyright (c) 2012 ICRL 3 | // See the file LICENSE.txt for copying permission. 4 | // 5 | // Original Author: Randy Gaul 6 | // Date: 7/24/2012 7 | // Contact: r.gaul@digipen.edu 8 | //////////////////////////////////////////////////// 9 | 10 | #pragma once 11 | 12 | #include "EntityCreator.h" 13 | #include "ItemList.h" 14 | 15 | // Definition of the creator of this entity 16 | extern ENTITY_CREATOR ITEM_CREATOR; 17 | 18 | // 19 | // ItemIDToImage 20 | // Purpose: Maps item id's to image pointers. 21 | // 22 | IMAGE *ItemIDToImage( ITEM_ID id ); 23 | 24 | // 25 | // ItemIDToImage 26 | // Purpose: Maps item id's to string identifiers. 27 | // 28 | const char *ItemIDToString( ITEM_ID id ); 29 | -------------------------------------------------------------------------------- /AsciiEngine/ItemList.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////// 2 | // Copyright (c) 2012 ICRL 3 | // See the file LICENSE.txt for copying permission. 4 | // 5 | // Original Author: Randy Gaul 6 | // Date: 7/24/2012 7 | // Contact: r.gaul@digipen.edu 8 | //////////////////////////////////////////////////// 9 | 10 | #pragma once 11 | 12 | typedef enum ITEM_TYPES 13 | { 14 | NONE, 15 | TestItem1, 16 | TestItem2, 17 | } ITEM_ID; 18 | -------------------------------------------------------------------------------- /AsciiEngine/ItemParticle.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////// 2 | // Copyright (c) 2012 ICRL 3 | // See the file LICENSE.txt for copying permission. 4 | // 5 | // Original Author: Randy Gaul 6 | // Date: 7/24/2012 7 | // Contact: r.gaul@digipen.edu 8 | //////////////////////////////////////////////////// 9 | 10 | #pragma once 11 | 12 | #include "EntityCreator.h" 13 | 14 | // Definition of the creator of this entity 15 | extern ENTITY_CREATOR ITEM_PARTICLE_CREATOR; 16 | -------------------------------------------------------------------------------- /AsciiEngine/JumperLittle.c: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////// 2 | // Copyright (c) 2012 ICRL 3 | // See the file LICENSE.txt for copying permission. 4 | // 5 | // Original Author: Randy Gaul 6 | // Date: 7/25/2012 7 | // Contact: r.gaul@digipen.edu 8 | //////////////////////////////////////////////////// 9 | 10 | #include "JumperLittle.h" 11 | #include "Component.h" 12 | #include "EntityManager.h" 13 | #include "EntityFactory.h" 14 | #include "Random.h" 15 | 16 | // Static class variables and data 17 | static const char *CLASS_NAME = NULL; 18 | 19 | // 20 | // ClassCOM_PROC 21 | // Purpose: Component procedure for this component type. Dispatches messages 22 | // recieved in the appropriate manner. 23 | // 24 | void JumperLittleCOM_PROC( BJL *self, EM msg, int var1, int var2 ) 25 | { 26 | // GENERAL 27 | switch(msg) 28 | { 29 | case EM_CLSINIT: 30 | JumperLittleInit( (const char *)var1 ); 31 | break; 32 | case EM_CREATE: 33 | JumperLittleCreate( self ); 34 | break; 35 | case EM_UPDATE: 36 | JumperLittleUpdate( self, (float *)var1 ); 37 | break; 38 | } 39 | } 40 | 41 | // 42 | // ClassCreate 43 | // Purpose: Acts as a constructor for this class. Initializes the 44 | // data and dynamically allocates any extra space needed, and 45 | // initializes the allocated space with data. 46 | // 47 | void JumperLittleCreate( BJL *self ) 48 | { 49 | self->dt = 0; 50 | self->timeToWait = (float)RandomInt( 2, 5 ); 51 | } 52 | 53 | // 54 | // ClassInit 55 | // Purpose: One-time initialization of the class. Use this function to load resources from disk, 56 | // set up static class variables, or anything else. 57 | // 58 | void JumperLittleInit( const char *className ) 59 | { 60 | CLASS_NAME = (const char *)malloc( strlen( className ) + 1 ); 61 | strcpy_s( (char *)CLASS_NAME, strlen( className ) + 1 , className ); 62 | } 63 | 64 | // 65 | // JumperLittleUpdate 66 | // Purpose: Creates various actions for the actionList of this object. 67 | // 68 | void JumperLittleUpdate( BJL *self, float *dt ) 69 | { 70 | self->dt += *dt; 71 | 72 | if(self->dt > self->timeToWait) 73 | { 74 | VECTOR2D vel = { (float)RandomInt( -10, 10 ), -(float)RandomInt( 20, 40 ) }; 75 | ALD ALdata = { 0 }; 76 | self->dt = 0; 77 | ALdata.flag |= BLOCKING; 78 | ALdata.ID = ALT_SET_VEL; 79 | ALdata.var1 = (int)vel.x_; 80 | ALdata.var2 = (int)vel.y_; 81 | SendEntityMessage( self->base.owner, EM_ALADDACT, (int)&ALdata, 0 ); 82 | } 83 | } 84 | 85 | -------------------------------------------------------------------------------- /AsciiEngine/JumperLittle.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////// 2 | // Copyright (c) 2012 ICRL 3 | // See the file LICENSE.txt for copying permission. 4 | // 5 | // Original Author: Randy Gaul 6 | // Date: 7/25/2012 7 | // Contact: r.gaul@digipen.edu 8 | //////////////////////////////////////////////////// 9 | 10 | #pragma once 11 | 12 | #include "Message.h" 13 | #include "BrainComponent.h" 14 | 15 | typedef struct _BRAIN_JUMPER_LITTLE_COMPONENT 16 | { 17 | BRAIN_COMPONENT base; 18 | float dt; 19 | float timeToWait; 20 | } BJL; 21 | 22 | // 23 | // ClassCOM_PROC 24 | // Purpose: Component procedure for this component type. Dispatches messages 25 | // recieved in the appropriate manner. 26 | // 27 | void JumperLittleCOM_PROC( BJL *self, EM msg, int var1, int var2 ); 28 | 29 | // 30 | // ClassCreate 31 | // Purpose: Acts as a constructor for this class. Initializes the 32 | // data and dynamically allocates any extra space needed, and 33 | // initializes the allocated space with data. 34 | // 35 | void JumperLittleCreate( BJL *self ); 36 | 37 | // 38 | // ClassInit 39 | // Purpose: One-time initialization of the class. Use this function to load resources from disk, 40 | // set up static class variables, or anything else. 41 | // 42 | void JumperLittleInit( const char *className ); 43 | 44 | // 45 | // JumperLittleUpdate 46 | // Purpose: Creates various actions for the actionList of this object. 47 | // 48 | void JumperLittleUpdate( BJL *self, float *dt ); 49 | -------------------------------------------------------------------------------- /AsciiEngine/Loci.c: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////// 2 | // Copyright (c) 2012 ICRL 3 | // See the file LICENSE.txt for copying permission. 4 | // 5 | // Original Author: Randy Gaul 6 | // Date: 7/16/2012 7 | // Contact: r.gaul@digipen.edu 8 | //////////////////////////////////////////////////// 9 | 10 | #include 11 | #include "Loci.h" 12 | #include "ImageTable.h" 13 | 14 | unsigned HIGHEST_ZORDER = 10; 15 | 16 | DEFINE_TABLE( P_LOCUS, DeallocateLocus ); 17 | 18 | // 19 | // AllocateImageLocus 20 | // Purpose: Allocates a locus with an image inside. 21 | // 22 | LOCUS *AllocateImageLocus( const char *name, float x, float y, IMAGE *image, unsigned zOrder ) 23 | { 24 | LOCUS *locus = (LOCUS *)malloc( sizeof( LOCUS ) + strlen( name ) + 1 ); 25 | locus->ID = PtrAdd( locus, sizeof( LOCUS ) ); 26 | strcpy_s( (char *)locus->ID, strlen( name ) + 1, (char *)name ); 27 | locus->coord.x_ = x; 28 | locus->coord.y_ = y; 29 | locus->image = image; 30 | locus->isActive = TRUE; 31 | locus->animation = NULL; 32 | locus->zOrder = zOrder; 33 | 34 | // Keep track of highest zOrder for use in Cloud.c in drawing 35 | if(HIGHEST_ZORDER < zOrder) 36 | { 37 | HIGHEST_ZORDER = zOrder; 38 | } 39 | 40 | return locus; 41 | } 42 | 43 | // 44 | // AllocateAnimationLocus 45 | // Purpose: Allocates a locus with an animation inside. 46 | // 47 | LOCUS *AllocateAnimationLocus( const char *name, float x, float y, unsigned zOrder, float frameDelay, const char *firstFrame, ... ) 48 | { 49 | va_list args; 50 | ANIMATION *animation = NULL; 51 | const char *next = firstFrame; 52 | int frameIterator = 0, numFrames = 0; 53 | LOCUS *locus = (LOCUS *)malloc( sizeof( LOCUS ) + strlen( name ) + 1 ); 54 | locus->ID = PtrAdd( locus, sizeof( LOCUS ) ); 55 | va_start( args, firstFrame ); 56 | 57 | // Count number of arguments 58 | va_start( args, firstFrame ); 59 | while(next != 0) 60 | { 61 | ++numFrames; 62 | next = va_arg( args, const char * ); 63 | } 64 | va_end( args ); 65 | 66 | // Allocate image + size of animation frame array 67 | animation = (ANIMATION *)malloc( sizeof( ANIMATION ) + sizeof( IMAGE ) * numFrames ); 68 | 69 | // Initialize frames pointer to directly after the ID string 70 | animation->frames = (IMAGE **)PtrAdd( animation, sizeof( ANIMATION ) ); 71 | 72 | animation->isPaused = FALSE; 73 | animation->numFrames = numFrames; 74 | animation->playCount = 0; 75 | animation->frameDelay = frameDelay; 76 | animation->dt = 0.f; 77 | animation->currentFrame = 0; 78 | 79 | // Restart the argument loop 80 | next = firstFrame; 81 | va_start( args, firstFrame ); 82 | 83 | // Loop through arguments and assign images to the frame array 84 | while(frameIterator < numFrames) 85 | { 86 | animation->frames[frameIterator] = FIND_DATA( P_IMAGE, IMAGE_TABLE, next ); 87 | ++frameIterator; 88 | next = va_arg( args, const char * ); 89 | } 90 | 91 | va_end( args ); 92 | 93 | strcpy_s( (char *)locus->ID, strlen( name ) + 1, (char *)name ); 94 | locus->coord.x_ = x; 95 | locus->coord.y_ = y; 96 | locus->animation = animation; 97 | locus->isActive = TRUE; 98 | locus->image = NULL; 99 | locus->zOrder = zOrder; 100 | 101 | // Keep track of highest zOrder for use in Cloud.c in drawing 102 | if(HIGHEST_ZORDER < zOrder) 103 | { 104 | HIGHEST_ZORDER = zOrder; 105 | } 106 | 107 | return locus; 108 | } 109 | 110 | // 111 | // DeallocateLocus 112 | // Purpose: Deallocates a locus. 113 | // 114 | RETURN_TYPE DeallocateLocus( LOCUS *locus ) 115 | { 116 | if(locus->image) 117 | { 118 | free( locus ); 119 | } 120 | else if(locus->animation) 121 | { 122 | free( locus->animation ); 123 | free( locus ); 124 | } 125 | 126 | return RETURN_SUCCESS; 127 | } 128 | -------------------------------------------------------------------------------- /AsciiEngine/Loci.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////// 2 | // Copyright (c) 2012 ICRL 3 | // See the file LICENSE.txt for copying permission. 4 | // 5 | // Original Author: Randy Gaul 6 | // Date: 7/16/2012 7 | // Contact: r.gaul@digipen.edu 8 | //////////////////////////////////////////////////// 9 | 10 | // A loci is a collection of points that perform a specific task. 11 | // A locus is a single point within a loci. In this engine loci are 12 | // used as collections of mid-points of various images to draw in order 13 | // to represent entitys with multiple images. Each locus is mapped 14 | // within a loci by a unique to the loci string key. 15 | 16 | #ifndef LOCIH 17 | #define LOCIH 18 | 19 | #include 20 | #include "GlobalDefines.h" 21 | #include "StringHash.h" 22 | #include "Graphics.h" 23 | #include "Vector2D.h" 24 | #include "HashTable.h" 25 | 26 | extern unsigned HIGHEST_ZORDER; 27 | 28 | typedef struct _LOCUS 29 | { 30 | unsigned zOrder; 31 | const char *ID; 32 | VECTOR2D coord; 33 | BOOL isActive; 34 | IMAGE *image; 35 | ANIMATION *animation; 36 | } LOCUS; 37 | 38 | typedef LOCUS *P_LOCUS; 39 | 40 | DECLARE_TABLE( P_LOCUS, MAX_KEY_LEN ); 41 | 42 | // 43 | // AllocateImageLocus 44 | // Purpose: Allocates a locus with an image inside. 45 | // 46 | LOCUS *AllocateImageLocus( const char *name, float x, float y, IMAGE *image, unsigned zOrder ); 47 | 48 | // 49 | // AllocateAnimationLocus 50 | // Purpose: Allocates a locus with an animation inside. 51 | // 52 | LOCUS *AllocateAnimationLocus( const char *name, float x, float y, unsigned zOrder, float frameDelay, const char *firstFrame, ... ); 53 | 54 | // 55 | // DeallocateLocus 56 | // Purpose: Deallocates a locus. 57 | // 58 | RETURN_TYPE DeallocateLocus( LOCUS *locus ); 59 | 60 | 61 | #endif LOCIH -------------------------------------------------------------------------------- /AsciiEngine/Main.c: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////// 2 | // Copyright (c) 2012 ICRL 3 | // See the file LICENSE.txt for copying permission. 4 | // 5 | // Original Author: Randy Gaul 6 | // Date: 7/3/2012 7 | // Contact: r.gaul@digipen.edu 8 | //////////////////////////////////////////////////// 9 | 10 | #include "GlobalDefines.h" 11 | #include "ConsoleFuncs.h" 12 | #include "Graphics.h" 13 | #include "GameStateManager.h" 14 | #include "FrameRateController.h" 15 | #include "Input.h" 16 | #include "Random.h" 17 | #include "Registration.h" // Register entity classes and entity components 18 | 19 | int main(void) 20 | { 21 | // Initializes the graphics settings. 22 | InitGraphics( CLIENT_WIDTH, CLIENT_HEIGHT ); 23 | 24 | // Initializes the console. 25 | // The first string is the name of your window. The second string is the 26 | // name of the font you want to use. Blank uses the default raster font, 27 | // though you can try strings "Lucida Console" or "Consolas" as they are 28 | // optional fonts in Windows 7 and Vista. A custom font can be created and 29 | // implemented if you're so inclined. 30 | initConsole(TEXT("Ascii Engine v1.02"), TEXT("Sunkure Font"), 8, 8 ); 31 | 32 | // Seed PRNG 33 | // http://cecilsunkure.blogspot.com/2010/11/prngs-psuedo-random-number-generator.html 34 | InitRandSeed( ); 35 | 36 | // Set the starting state 37 | // http://cecilsunkure.blogspot.com/2012/02/game-program-design-game-state-manager.html 38 | GSM_Initialize( TestLevel ); 39 | 40 | InitFrameRateController( ); 41 | 42 | // Registration of creators to the creator table 43 | // http://cecilsunkure.blogspot.com/2012/08/game-object-factory-distributed-factory.html 44 | RegisterEntityClasses( ); 45 | RegisterEntityComponents( ); 46 | 47 | while (currentState != Quit) 48 | { 49 | if (currentState == Quit) 50 | { 51 | break; 52 | } 53 | 54 | if (currentState == Restart) 55 | { 56 | currentState = previousState; 57 | nextState = previousState; 58 | } 59 | else 60 | { 61 | GSM_Update( ); 62 | Load( ); 63 | } 64 | 65 | Initialize( ); 66 | SetStateStartTime( ); 67 | 68 | while (currentState == nextState) 69 | { 70 | FrameStart( ); // get time frame started 71 | 72 | UpdateInput( ); // Capture input 73 | 74 | for (;;) 75 | { 76 | assert(_CrtCheckMemory()); 77 | SetDT( dtCalculate( ) ); // Set's dt for the function GetDT 78 | Update( ); // calculate change in time since last call, for update 79 | if (FPSLimit( )) 80 | { 81 | Draw( ); 82 | break; 83 | } 84 | } 85 | } 86 | 87 | Free( ); 88 | 89 | if (nextState == Restart) 90 | { 91 | previousState = currentState; 92 | currentState = nextState; 93 | } 94 | else 95 | { 96 | Unload( ); 97 | previousState = currentState; 98 | currentState = nextState; 99 | } 100 | } 101 | 102 | return RETURN_SUCCESS; 103 | } 104 | -------------------------------------------------------------------------------- /AsciiEngine/MapEditor.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////// 2 | // Copyright (c) 2012 ICRL 3 | // See the file LICENSE.txt for copying permission. 4 | // 5 | // Original Author: Randy Gaul 6 | // Date: 7/10/2012 7 | // Contact: r.gaul@digipen.edu 8 | //////////////////////////////////////////////////// 9 | 10 | #pragma once 11 | 12 | #include "GlobalDefines.h" 13 | 14 | #define VIEWPORT_SCROLL_SPEED 15.0f 15 | #define VIEWPORT_OFFSET_X -7.5f 16 | #define VIEWPORT_OFFSET_Y 6.f 17 | 18 | #define VIEWPORT_HEIGHT 32.0f 19 | #define VIEWPORT_WIDTH 57.0f 20 | 21 | RETURN_TYPE MapEditorLoad( void ); 22 | RETURN_TYPE MapEditorInit( void ); 23 | RETURN_TYPE MapEditorUpdate( void ); 24 | RETURN_TYPE MapEditorDraw( void ); 25 | RETURN_TYPE MapEditorFree( void ); 26 | RETURN_TYPE MapEditorUnload( void ); 27 | -------------------------------------------------------------------------------- /AsciiEngine/Math2D.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////// 2 | // Copyright (c) 2012 ICRL 3 | // See the file LICENSE.txt for copying permission. 4 | // 5 | // Original Author: Randy Gaul 6 | // Date: 7/5/2012 7 | // Contact: r.gaul@digipen.edu 8 | //////////////////////////////////////////////////// 9 | 10 | #ifndef MATH2DH 11 | #define MATH2DH 12 | 13 | // This is used to reverse clamp floating values to zero for 14 | // effective floating point usage 15 | #define EPSILON 0.0001f 16 | 17 | #include "Vector2D.h" 18 | #include "Shapes.h" 19 | #include "GlobalDefines.h" 20 | 21 | // 22 | // StaticCircleToStaticRectangle 23 | // Purpose: Detects collision between a static circle and static 24 | // rectangle 25 | // 26 | BOOL StaticCircleToStaticRectangle( const AE_CIRCLE *circle, const AE_RECT *rect ); 27 | 28 | // 29 | // StaticPointToStaticCircle 30 | // Purpose: Detects collision between a static point and static 31 | // circle 32 | // 33 | BOOL StaticPointToStaticCircle( const VECTOR2D *point, const AE_CIRCLE *circle ); 34 | 35 | // 36 | // StaticPointToStaticRect 37 | // Purpose: Detects collision between a static point and static 38 | // rectangle 39 | // 40 | BOOL StaticPointToStaticRect( const VECTOR2D *point, const AE_RECT *rect ); 41 | 42 | // 43 | // StaticCircleToStaticCircle 44 | // Purpose: Detects collision between a static circleA and static 45 | // circleB 46 | // 47 | BOOL StaticCircleToStaticCircle( const AE_CIRCLE *circleA, const AE_CIRCLE *circleB ); 48 | 49 | // 50 | // StaticRectToStaticRect 51 | // Purpose: Detects collision between a static rectangleA and static 52 | // rectangleB 53 | // 54 | BOOL StaticRectToStaticRect( const AE_RECT *rectA, const AE_RECT *rectB ); 55 | 56 | // 57 | // FloatToInt 58 | // Purpose: Truncates all of the floating point value 59 | // 60 | int FloatToInt( float val ); 61 | 62 | // 63 | // FloatToIntRoundUp 64 | // Purpose: Returns an integer representation of a 65 | // float rounded to the nearest integer, upwards 66 | // 67 | int FloatToIntRoundUp( float val ); 68 | 69 | // 70 | // SnapToCell 71 | // Purpose: Snaps a floating point value to the nearest cell 72 | // 73 | void SnapToCell( float *coordinate ); 74 | 75 | // 76 | // BoundCheck 77 | // Purpose: Checks to make sure a coordinate is within a specific bound 78 | // 79 | BOOL BoundCheck( AE_COORD coord, int boundTop, int boundLeft, int boundBottom, int boundRight ); 80 | 81 | // 82 | // BoundCheck 83 | // Purpose: Checks to make sure a coordinate is within a specific bound 84 | // 85 | BOOL BoundCheck2( AE_COORD coord, AE_COORD topLeft, AE_COORD bottomRight ); 86 | 87 | // 88 | // SnapVectorToRect 89 | // Purpose: Snaps a point within a rectangle boundary. 90 | // 91 | void SnapVectorToRect( VECTOR2D *vec, AE_RECT *rect ); 92 | 93 | #endif MATH2DH 94 | -------------------------------------------------------------------------------- /AsciiEngine/OpenFile.c: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////// 2 | // Copyright (c) 2012 ICRL 3 | // See the file LICENSE.txt for copying permission. 4 | // 5 | // Original Author: Randy Gaul 6 | // Date: 7/9/2012 7 | // Contact: r.gaul@digipen.edu 8 | //////////////////////////////////////////////////// 9 | 10 | #include 11 | #include 12 | #include "OpenFile.h" 13 | #include "Graphics.h" 14 | 15 | BOOL SaveAEArtFile( const char *path, OPENFILENAMEA *ofn ) 16 | { 17 | memset( ofn, 0, sizeof(*ofn)); 18 | ofn->lStructSize = sizeof( OPENFILENAME ); 19 | ofn->hwndOwner = NULL; 20 | ofn->hInstance = NULL; 21 | ofn->lpstrFilter = (LPCSTR)"AsciiEngine Art Files\0*.AEArt\0\0"; 22 | (const char *)ofn->lpstrFile = path; 23 | ofn->lpstrFile[0] = '\0'; 24 | ofn->nMaxFile = MAX_PATH; 25 | ofn->lpstrTitle = (LPCSTR)"Select A Location To Save To"; 26 | ofn->Flags = OFN_NONETWORKBUTTON | 27 | OFN_PATHMUSTEXIST | 28 | OFN_HIDEREADONLY; 29 | if (GetSaveFileNameA( ofn )) 30 | return( TRUE ); 31 | return FALSE; 32 | } 33 | 34 | BOOL OpenAEArtFile( const char *path, OPENFILENAMEA *ofn ) 35 | { 36 | memset( ofn, 0, sizeof(*ofn)); 37 | ofn->lStructSize = sizeof( OPENFILENAME ); 38 | ofn->hwndOwner = NULL; 39 | ofn->hInstance = NULL; 40 | ofn->lpstrFilter = (LPCSTR)"AsciiEngine Art Files\0*.AEArt\0\0"; 41 | (const char *)ofn->lpstrFile = path; 42 | ofn->lpstrFile[0] = '\0'; 43 | ofn->nMaxFile = MAX_PATH; 44 | ofn->lpstrTitle = (LPCSTR)"Select A File To Open"; 45 | ofn->Flags = OFN_NONETWORKBUTTON | 46 | OFN_FILEMUSTEXIST | 47 | OFN_PATHMUSTEXIST | 48 | OFN_HIDEREADONLY; 49 | if (GetOpenFileNameA( ofn )) 50 | return( TRUE ); 51 | return FALSE; 52 | } 53 | 54 | // 55 | // LoadAllArtAssets 56 | // Purpose: Loads all art assets of .AEArt format from the Assets folder. 57 | // 58 | RETURN_TYPE LoadAllArtAssets( const char *directory ) 59 | { 60 | // Use a few functions from MSDN to cycle through the files of a folder 61 | WIN32_FIND_DATAA fileData = { 0 }; 62 | HANDLE handle; 63 | char *searchString = "*.AEArt"; 64 | 65 | // Allocate space to concatenate the folder and the fileName together 66 | int size = strlen( directory ) + strlen( searchString ) + 2; 67 | char *entireSearchString = (char *)malloc( size ); 68 | 69 | // Copy the folder and fileName into the pathName array 70 | strcpy_s( entireSearchString, size, directory ); 71 | strcat_s( entireSearchString, size, searchString ); 72 | 73 | handle = FindFirstFileA( entireSearchString, &fileData ); 74 | 75 | do 76 | { 77 | // For each file found, load it 78 | LoadAEArtFile( directory, fileData.cFileName ); 79 | } 80 | while(FindNextFileA( handle, &fileData ) != 0); 81 | 82 | return RETURN_SUCCESS; 83 | } 84 | 85 | // 86 | // LoadAEArtFile 87 | // Purpose: Loads a .AEArt file and places it into the table of image files 88 | // 89 | IMAGE *LoadAEArtFile( const char *folder, const char *fileName ) 90 | { 91 | FILE *fp; 92 | IMAGE *image = NULL; 93 | 94 | // Allocate space to concatenate the folder and the fileName together 95 | int size = strlen( folder ) + strlen( fileName ) + 2; 96 | char *pathName = (char *)malloc( size ); 97 | 98 | // Copy the folder and fileName into the pathName array 99 | strcpy_s( pathName, size, folder ); 100 | strcat_s( pathName, size, fileName ); 101 | 102 | fopen_s( &fp, pathName, "r" ); 103 | 104 | if(fp) // read image contents in file 105 | { 106 | int x, y; 107 | CHAR *thisChar; 108 | COL *thisColor; 109 | AE_COORD bottomRight = { 0 }; 110 | 111 | fscanf_s( fp, "%d", &bottomRight.x_ ); 112 | fscanf_s( fp, "%d", &bottomRight.y_ ); 113 | 114 | image = AllocateImage( fileName, bottomRight.x_, bottomRight.y_ ); 115 | 116 | for(y = 0; y < bottomRight.y_; ++y) 117 | { 118 | for(x = 0; x < bottomRight.x_; ++x) 119 | { 120 | int copy = 0; 121 | thisChar = CharAt( image, x, y ); 122 | fscanf_s( fp, "%d", © ); 123 | *thisChar = (char)copy; 124 | } 125 | } 126 | 127 | for(y = 0; y < bottomRight.y_; ++y) 128 | { 129 | for(x = 0; x < bottomRight.x_; ++x) 130 | { 131 | int copy = 0; 132 | thisColor = ColorAt( image, x, y ); 133 | fscanf_s( fp, "%d", © ); 134 | *thisColor = (char)copy; 135 | } 136 | } 137 | fclose( fp ); 138 | } 139 | return image; 140 | } 141 | -------------------------------------------------------------------------------- /AsciiEngine/OpenFile.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////// 2 | // Copyright (c) 2012 ICRL 3 | // See the file LICENSE.txt for copying permission. 4 | // 5 | // Original Author: Randy Gaul 6 | // Date: 7/9/2012 7 | // Contact: r.gaul@digipen.edu 8 | //////////////////////////////////////////////////// 9 | 10 | #ifndef OPENFILEH 11 | #define OPENFILEH 12 | 13 | #include "GlobalDefines.h" 14 | #include "Graphics.h" 15 | 16 | BOOL OpenAEArtFile( const char *path, OPENFILENAMEA *ofn ); 17 | BOOL SaveAEArtFile( const char *path, OPENFILENAMEA *ofn ); 18 | 19 | // 20 | // LoadAllArtAssets 21 | // Purpose: Loads all art assets of .AEArt format from the Assets folder. 22 | // 23 | RETURN_TYPE LoadAllArtAssets( const char *directory ); 24 | 25 | // 26 | // LoadAEArtFile 27 | // Purpose: Loads a .AEArt file and places it into the table of image files 28 | // 29 | IMAGE *LoadAEArtFile( const char *folder, const char *fileName ); 30 | 31 | #endif OPENFILEH -------------------------------------------------------------------------------- /AsciiEngine/Physics.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////// 2 | // Copyright (c) 2012 ICRL 3 | // See the file LICENSE.txt for copying permission. 4 | // 5 | // Original Author: Randy Gaul 6 | // Date: 7/17/2012 7 | // Contact: r.gaul@digipen.edu 8 | //////////////////////////////////////////////////// 9 | 10 | #pragma once 11 | 12 | #include "PhysicsComponent.h" 13 | #include "Entity.h" 14 | #include "Vector2D.h" 15 | 16 | // 17 | // PHYSICS class 18 | // This class is derived from the GRAPHICS_COMPONENT base, and represents 19 | // a two dimensional sprite image. 20 | // 21 | typedef struct _PHYS_COMPONENT 22 | { 23 | PHYSICS_COMPONENT base; 24 | VECTOR2D vel; 25 | VECTOR2D accel; 26 | } PHYS; 27 | 28 | // 29 | // ClassCOM_PROC 30 | // Purpose: Component procedure for this component type. Dispatches messages 31 | // recieved in the appropriate manner. 32 | // 33 | void PhysCOM_PROC( PHYS *self, EM msg, int var1, int var2 ); 34 | 35 | // 36 | // ClassCreate 37 | // Purpose: Acts as a constructor for this class. Initializes the 38 | // data and dynamically allocates any extra space needed, and 39 | // initializes the allocated space with data. 40 | // 41 | void PhysCreate( PHYS *self, VECTOR2D *vel, VECTOR2D *accel ); 42 | 43 | // 44 | // ClassUpdate 45 | // Purpose: Acts as a constructor for this class. Initializes the 46 | // data and dynamically allocates any extra space needed, and 47 | // initializes the allocated space with data. 48 | // 49 | void PhysUpdate( PHYS *self, float *dt ); 50 | 51 | // 52 | // ClassInit 53 | // Purpose: One-time initialization of the class. Use this function to load resources from disk, 54 | // set up static class variables, or anything else. 55 | // 56 | void PhysInit( const char *className ); 57 | 58 | // 59 | // ClassSetVel 60 | // Purpose: Sets the velocity of the class. Takes two floats. 61 | // 62 | void PhysSetVel( PHYS *self, float *var1, float *var2 ); 63 | 64 | // 65 | // ClassStepXPos 66 | // Purpose: Copies the stepped value of vel into float *var1, var2 is (float *)dt provided for step 67 | // Does not actually modify anything, only retrieves values stepped by dt 68 | // 69 | void PhysStepXPos( PHYS *self, float *var1, float *dt ); 70 | 71 | 72 | // 73 | // ClassStepYPos 74 | // Purpose: Copies the stepped value of vel into float *var1, var2 is (float *)dt provided for step 75 | // Does not actually modify anything, only retrieves values stepped by dt 76 | // 77 | void PhysStepYPos( PHYS *self, float *var1, float *dt ); 78 | 79 | // 80 | // ClassSetAccel 81 | // Purpose: Sets the velocity of the class. Takes two floats. 82 | // 83 | void PhysSetAccel( PHYS *self, float *var1, float *var2 ); 84 | 85 | // 86 | // ClassGetVel 87 | // Purpose: Copiess values of x and y position into var1 and var2 88 | // respectively. 89 | // 90 | void PhysGetVel( PHYS *self, float *var1, float *var2 ); 91 | 92 | // 93 | // ClassGetAccel 94 | // Purpose: Copiess values of x and y position into var1 and var2 95 | // respectively. 96 | // 97 | void PhysGetAccel( PHYS *self, float *var1, float *var2 ); 98 | 99 | // 100 | // ClassApplyGravity 101 | // Purpose: Applies gravity to the vel y component. 102 | // 103 | void PhysApplyGravity( PHYS *self, float *dt ); 104 | -------------------------------------------------------------------------------- /AsciiEngine/PhysicsComponent.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////// 2 | // Copyright (c) 2012 ICRL 3 | // See the file LICENSE.txt for copying permission. 4 | // 5 | // Original Author: Randy Gaul 6 | // Date: 7/17/2012 7 | // Contact: r.gaul@digipen.edu 8 | //////////////////////////////////////////////////// 9 | 10 | #pragma once 11 | 12 | #include "Message.h" 13 | 14 | // Forward decl 15 | struct _ENTITY; 16 | 17 | // 18 | // Common interface for all physics components. 19 | // 20 | typedef struct _PHYSICS_COMPONENT 21 | { 22 | const char *CLASS_NAME; 23 | void (*COM_PROC)( struct _PHYSICS_COMPONENT *self, EM msg, int var1, int var2 ); 24 | struct _ENTITY *owner; 25 | } PHYSICS_COMPONENT; 26 | -------------------------------------------------------------------------------- /AsciiEngine/Player.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////// 2 | // Copyright (c) 2012 ICRL 3 | // See the file LICENSE.txt for copying permission. 4 | // 5 | // Original Author: Randy Gaul 6 | // Date: 7/18/2012 7 | // Contact: r.gaul@digipen.edu 8 | //////////////////////////////////////////////////// 9 | 10 | #pragma once 11 | 12 | #include "PlayerComponent.h" 13 | #include "Entity.h" 14 | 15 | #define PLAYER_ATTACK_SPEED_SECONDS .75f 16 | 17 | typedef enum _PLAYER_STATE 18 | { 19 | PLAYER_STATE_IDLE, 20 | PLAYER_STATE_MOVING, 21 | PLAYER_STATE_ATTACKING_1, 22 | PLAYER_STATE_HIT, 23 | } PLAYER_STATE; 24 | 25 | // 26 | // PLAYER class 27 | // This class is derived from the PLAYER_COMPONENT base, and enables player input 28 | // 29 | typedef struct _PLAC_COMPONENT 30 | { 31 | PLAYER_COMPONENT base; 32 | BOOL canJump; 33 | BOOL jumping; // TRUE YES : FALSE NO 34 | BOOL faceDir; // TRUE RIGHT : FALSE LEFT 35 | BOOL hitBottom; 36 | float dt; // General purpose timer 37 | float inventoryDT; // Timer for inventory button debounce 38 | PLAYER_STATE playerState; // Walking/Running/Jumping/Idle/Hit/Attacking 39 | VECTOR2D inputVector; 40 | } PLAC; 41 | 42 | // 43 | // ClassCOM_PROC 44 | // Purpose: Component procedure for this component type. Dispatches messages 45 | // recieved in the appropriate manner. 46 | // 47 | void PlaCCOM_PROC( PLAC *self, EM msg, int var1, int var2 ); 48 | 49 | // 50 | // ClassCreate 51 | // Purpose: Acts as a constructor for this class. Initializes the 52 | // data and dynamically allocates any extra space needed, and 53 | // initializes the allocated space with data. 54 | // 55 | void PlaCCreate( PLAC *self ); 56 | 57 | // 58 | // ClassUpdate 59 | // Purpose: Acts as a constructor for this class. Initializes the 60 | // data and dynamically allocates any extra space needed, and 61 | // initializes the allocated space with data. 62 | // 63 | void PlaCUpdate( PLAC *self, float *dt ); 64 | 65 | // 66 | // ClassInit 67 | // Purpose: One-time initialization of the class. Use this function to load resources from disk, 68 | // set up static class variables, or anything else. 69 | // 70 | void PlaCInit( const char *className ); 71 | 72 | // 73 | // SetCanJump 74 | // Purpose: Sets the canJump flag of the PlayerComponent to the provided param. 75 | // 76 | void PlaCSetCanJump( PLAC *self, BOOL *var1 ); 77 | 78 | // 79 | // GetCanJump 80 | // Purpose: Gets the canJump flag of the PlayerComponent to the provided param. 81 | // 82 | void PlaCGetCanJump( PLAC *self, BOOL *var1 ); 83 | 84 | // 85 | // PlaCGetInputVector 86 | // Purpose: Copies the input vector contents into VECTOR2D var1 87 | // 88 | void PlaCGetInputVector( PLAC *self, VECTOR2D *var1 ); 89 | 90 | // 91 | // PlaCSetInputVector 92 | // Purpose: Copies VECTOR2D var1 contents into the input vector 93 | // 94 | void PlaCSetInputVector( PLAC *self, VECTOR2D *var1 ); 95 | 96 | // 97 | // PlaCGetJumping 98 | // Purpose: Copies the jumping contents into BOOL *var1 99 | // 100 | void PlaCGetJumping( PLAC *self, BOOL *var1 ); 101 | 102 | // 103 | // PlaCSetJumping 104 | // Purpose: Places the value of var1 into jumping 105 | // 106 | void PlaCSetJumping( PLAC *self, BOOL var1 ); 107 | 108 | // 109 | // PlaCGetHitBottom 110 | // Purpose: 111 | // 112 | void PlaCGetHitBottom( PLAC *self, BOOL *var1 ); 113 | 114 | // 115 | // PlaCSetHitBottom 116 | // Purpose: 117 | // 118 | void PlaCSetHitBottom( PLAC *self, BOOL var1 ); 119 | -------------------------------------------------------------------------------- /AsciiEngine/PlayerComponent.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////// 2 | // Copyright (c) 2012 ICRL 3 | // See the file LICENSE.txt for copying permission. 4 | // 5 | // Original Author: Randy Gaul 6 | // Date: 7/18/2012 7 | // Contact: r.gaul@digipen.edu 8 | //////////////////////////////////////////////////// 9 | 10 | #pragma once 11 | 12 | #include "Message.h" 13 | 14 | // Forward decl 15 | struct _ENTITY; 16 | 17 | // 18 | // Common interface for all physics components. 19 | // 20 | typedef struct _PLAYER_COMPONENT 21 | { 22 | const char *CLASS_NAME; 23 | void (*COM_PROC)( struct _PLAYER_COMPONENT *self, EM msg, int var1, int var2 ); 24 | struct _ENTITY *owner; 25 | } PLAYER_COMPONENT; 26 | -------------------------------------------------------------------------------- /AsciiEngine/Point.c: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////// 2 | // Copyright (c) 2012 ICRL 3 | // See the file LICENSE.txt for copying permission. 4 | // 5 | // Original Author: Randy Gaul 6 | // Date: 7/17/2012 7 | // Contact: r.gaul@digipen.edu 8 | //////////////////////////////////////////////////// 9 | 10 | #include "ImageTable.h" 11 | #include "Component.h" 12 | #include "EntityCreatorTable.h" // Map entity creators to string IDs 13 | #include "EntityManager.h" // SendEntityMessage 14 | 15 | static const char *CLASS_NAME = NULL; 16 | 17 | void PointConstruct( ENTITY *self, float *x, float *y ); 18 | void PointInit ( const char *className ); 19 | void PointUpdate ( ENTITY *self, float *dt ); 20 | void PointDestroy ( ENTITY *self ); 21 | ENTITY *PointCreate( int x, int y ); 22 | 23 | // 24 | // PointEM_PROC 25 | // Purpose; Processes entity messages. 26 | // 27 | void PointEM_PROC( ENTITY *self, EM msg, int var1, int var2 ) 28 | { 29 | switch(msg) 30 | { 31 | // GENERAL 32 | case EM_CREATE: 33 | PointConstruct( self, (float *)var1, (float *)var2 ); 34 | break; 35 | case EM_DESTROY: 36 | PointDestroy( self ); 37 | break; 38 | case EM_UPDATE: 39 | PointUpdate( self, (float *)var1 ); 40 | break; 41 | case EM_CLSINIT: 42 | PointInit( (const char *)var1 ); 43 | break; 44 | case EM_INACTIVE: 45 | EntityInactive( self ); 46 | break; 47 | 48 | // POSITION 49 | case EM_SETPOS: 50 | SendComEM( self->comps.POSC, EM_SETPOS, var1, var2 ); 51 | break; 52 | case EM_GETPOS: 53 | SendComEM( self->comps.POSC, EM_GETPOS, var1, var2 ); 54 | break; 55 | 56 | // Physics 57 | case EM_SETVEL: 58 | SendComEM( self->comps.PC, EM_SETVEL, var1, var2 ); 59 | break; 60 | case EM_GETVEL: 61 | SendComEM( self->comps.PC, EM_GETVEL, var1, var2 ); 62 | break; 63 | } 64 | } 65 | 66 | // Constructor for this entity type 67 | // Notes: Do not allocate space for the entity itself! This is handled 68 | // by the entity factory. This function is for allocation of 69 | // any other necessary memory. Perhaps a dynamically allocated 70 | // string, or other various memory allocations that are to be 71 | // pointed to by this entity. 72 | void PointConstruct( ENTITY *self, float *x, float *y ) 73 | { 74 | VECTOR2D vel = { 0 }, accel = { 0 }, pos = { 0 }; 75 | AddPositionComponent( self, (int)x, (int)y ); 76 | AddPhysicsComponent( self, (int)&vel, (int)&accel ); 77 | self->CLASS_NAME = CLASS_NAME; 78 | } 79 | 80 | // Default initializer for this entity type 81 | // Notes: This function calls the Set function for this entity type. 82 | // The purpose of the set function is to set the values of the 83 | // self entity to those of the parameters. However the Init 84 | // function of an entity acts as "default parameters" for the 85 | // set function. Since parameter defaults are not apart of the C 86 | // standard this workaround becomes necessary. 87 | void PointInit ( const char *className ) 88 | { 89 | CLASS_NAME = (const char *)malloc( strlen( className ) + 1 ); 90 | strcpy_s( (char *)CLASS_NAME, strlen( className ) + 1, className ); 91 | } 92 | 93 | // 94 | // PointUpdate 95 | // Purpose: 96 | // 97 | void PointUpdate ( ENTITY *self, float *dt ) 98 | { 99 | // Update physics 100 | SendComEM( self->comps.PC, EM_UPDATE, dt, 0 ); 101 | } 102 | 103 | // Destructor for this entity type 104 | // Notes: Only free things in this function that were allocated in the 105 | // construtor! The entity factory actually handles deallocation 106 | // of the entity itself. 107 | void PointDestroy ( ENTITY *self ) 108 | { 109 | RemovePositionComponent( self ); 110 | } 111 | 112 | // Creator for this entity, assign a string ID and a creator function 113 | // For use with the EntityFactory -- allows simple dynamicly maintained 114 | // method for creation of entitys without necessity to maintain explicit 115 | // code 116 | ENTITY_CREATOR POINT_CREATOR = { 117 | "POINT", 118 | PointCreate 119 | }; 120 | 121 | // 122 | // PointCreate 123 | // Purpose: Creates a specific type of entity 124 | // 125 | ENTITY *PointCreate( int x, int y ) 126 | { 127 | ENTITY *entity = (ENTITY *)malloc( sizeof( ENTITY ) ); 128 | memset( entity, 0, sizeof( ENTITY ) ); 129 | PointInit( POINT_CREATOR.ID ); // Register class name 130 | entity->EM_PROC = PointEM_PROC; 131 | SendEntityMessage( entity, EM_CREATE, x, y ); 132 | CLASS_NAME = POINT_CREATOR.ID; 133 | return entity; 134 | } 135 | -------------------------------------------------------------------------------- /AsciiEngine/Point.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////// 2 | // Copyright (c) 2012 ICRL 3 | // See the file LICENSE.txt for copying permission. 4 | // 5 | // Original Author: Randy Gaul 6 | // Date: 8/2/2012 7 | // Contact: r.gaul@digipen.edu 8 | //////////////////////////////////////////////////// 9 | 10 | #pragma once 11 | 12 | #include "EntityCreator.h" 13 | 14 | // Definition of the creator of this entity 15 | extern ENTITY_CREATOR POINT_CREATOR; 16 | -------------------------------------------------------------------------------- /AsciiEngine/Position.c: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////// 2 | // Copyright (c) 2012 ICRL 3 | // See the file LICENSE.txt for copying permission. 4 | // 5 | // Original Author: Randy Gaul 6 | // Date: 7/17/2012 7 | // Contact: r.gaul@digipen.edu 8 | //////////////////////////////////////////////////// 9 | 10 | #include "Position.h" 11 | 12 | // Static class variables and data 13 | static const char *CLASS_NAME = NULL; 14 | 15 | // 16 | // ClassCOM_PROC 17 | // Purpose: Component procedure for this component type. Dispatches messages 18 | // recieved in the appropriate manner. 19 | // 20 | void PosCOM_PROC( POSITION_COMPONENT *self, EM msg, int var1, int var2 ) 21 | { 22 | // Only respond to Draw, Init, and Destroy msgs 23 | switch(msg) 24 | { 25 | case EM_CLSINIT: 26 | PosInit( (const char *)var1 ); 27 | break; 28 | case EM_CREATE: 29 | PosCreate( (POS *)self, (float *)var1, (float *)var2 ); 30 | break; 31 | case EM_SETPOS: 32 | PosSetPos( (POS *)self, (float *)var1, (float *)var2 ); 33 | break; 34 | case EM_GETPOS: 35 | PosGetPos( (POS *)self, (float *)var1, (float *)var2 ); 36 | break; 37 | } 38 | } 39 | 40 | // 41 | // ClassCreate 42 | // Purpose: Acts as a constructor for this class. Initializes the 43 | // data and dynamically allocates any extra space needed, and 44 | // initializes the allocated space with data. 45 | // 46 | void PosCreate( POS *self, float *x, float *y ) 47 | { 48 | self->base.CLASS_NAME = CLASS_NAME; 49 | self->base.COM_PROC( (POSITION_COMPONENT *)self, EM_SETPOS, (int)x, (int)y ); 50 | } 51 | 52 | // 53 | // ClassSetPos 54 | // Purpose: Sets the position of the class. Takes two floats. 55 | // 56 | void PosSetPos( POS *self, float *var1, float *var2 ) 57 | { 58 | if(var1) 59 | { 60 | self->pos.x_ = *var1; 61 | self->pos.y_ = *var2; 62 | } 63 | else 64 | { 65 | self->pos.x_ = 0; 66 | self->pos.y_ = 0; 67 | } 68 | } 69 | 70 | // 71 | // ClassGetPos 72 | // Purpose: Copiess values of x and y position into var1 and var2 73 | // respectively. 74 | // 75 | void PosGetPos( POS *self, float *var1, float *var2 ) 76 | { 77 | *var1 = self->pos.x_; 78 | *var2 = self->pos.y_; 79 | } 80 | 81 | // 82 | // ClassInit 83 | // Purpose: One-time initialization of the class. Use this function to load resources from disk, 84 | // set up static class variables, or anything else. 85 | // 86 | void PosInit( const char *className ) 87 | { 88 | CLASS_NAME = (const char *)malloc( strlen( className ) + 1 ); 89 | strcpy_s( (char *)CLASS_NAME, strlen( className ) + 1 , className ); 90 | } 91 | -------------------------------------------------------------------------------- /AsciiEngine/Position.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////// 2 | // Copyright (c) 2012 ICRL 3 | // See the file LICENSE.txt for copying permission. 4 | // 5 | // Original Author: Randy Gaul 6 | // Date: 7/17/2012 7 | // Contact: r.gaul@digipen.edu 8 | //////////////////////////////////////////////////// 9 | 10 | #pragma once 11 | 12 | #include "Shapes.h" 13 | #include "PositionComponent.h" 14 | 15 | // 16 | // Position class 17 | // This class is derived from the GRAPHICS_COMPONENT base, and represents 18 | // a two dimensional sprite image. 19 | // 20 | typedef struct _POS_COMPONENT 21 | { 22 | POSITION_COMPONENT base; 23 | VECTOR2D pos; 24 | } POS; 25 | 26 | // 27 | // ClassCOM_PROC 28 | // Purpose: Component procedure for this component type. Dispatches messages 29 | // recieved in the appropriate manner. 30 | // 31 | void PosCOM_PROC( POSITION_COMPONENT *self, EM msg, int var1, int var2 ); 32 | 33 | // 34 | // ClassCreate 35 | // Purpose: Acts as a constructor for this class. Initializes the 36 | // data and dynamically allocates any extra space needed, and 37 | // initializes the allocated space with data. 38 | // 39 | void PosCreate( POS *self, float *x, float *y ); 40 | 41 | // 42 | // ClassInit 43 | // Purpose: One-time initialization of the class. Use this function to load resources from disk, 44 | // set up static class variables, or anything else. 45 | // 46 | void PosInit( const char *className ); 47 | 48 | // 49 | // ClassSetPos 50 | // Purpose: Sets the position of the class. Takes two floats. 51 | // 52 | void PosSetPos( POS *self, float *var1, float *var2 ); 53 | 54 | // 55 | // ClassGetPos 56 | // Purpose: Copiess values of x and y position into var1 and var2 57 | // respectively. 58 | // 59 | void PosGetPos( POS *self, float *var1, float *var2 ); 60 | -------------------------------------------------------------------------------- /AsciiEngine/PositionComponent.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////// 2 | // Copyright (c) 2012 ICRL 3 | // See the file LICENSE.txt for copying permission. 4 | // 5 | // Original Author: Randy Gaul 6 | // Date: 7/17/2012 7 | // Contact: r.gaul@digipen.edu 8 | //////////////////////////////////////////////////// 9 | 10 | #pragma once 11 | 12 | #include "Message.h" 13 | 14 | // Forward decl 15 | struct _ENTITY; 16 | 17 | // 18 | // Common interface for all position components. 19 | // 20 | typedef struct _POSITION_COMPONENT 21 | { 22 | const char *CLASS_NAME; 23 | void (*COM_PROC)( struct _POSITION_COMPONENT *self, EM msg, int var1, int var2 ); 24 | struct _ENTITY *owner; 25 | } POSITION_COMPONENT; 26 | -------------------------------------------------------------------------------- /AsciiEngine/Properties.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////// 2 | // Copyright (c) 2012 ICRL 3 | // See the file LICENSE.txt for copying permission. 4 | // 5 | // Original Author: Randy Gaul 6 | // Date: 7/22/2012 7 | // Contact: r.gaul@digipen.edu 8 | //////////////////////////////////////////////////// 9 | 10 | #pragma once 11 | 12 | // This file contains various arbitrary categories for assigning 13 | // properties to game entities as a bit-field 14 | 15 | #define PLAYER 0x00000001 16 | #define ENEMIES 0x00000002 17 | #define DAMAGE_DEALER 0x00000004 // Will destroy self on-impact and send EM_DAMAGEHP 18 | #define AXIS 0x00000008 // TRUE is X, FALSE is Y 19 | #define DRAWME 0x00000010 // TRUE draws FALSE does not 20 | #define GRAVITYME 0x00000020 // TRUE then apply gravity, FALSE then not 21 | #define DONT_COLLIDE_WITH_ME 0x00000040 // TRUE means others cannot collide with me 22 | #define PICK_ME_UP_ITEM 0x00000080 // Enables items in item's properties to be picked up on contact 23 | #define NO_PICKUP_ITEMS 0x00000100 // Disables ability to pickup items 24 | -------------------------------------------------------------------------------- /AsciiEngine/Random.c: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////// 2 | // Copyright (c) 2012 ICRL 3 | // See the file LICENSE.txt for copying permission. 4 | // 5 | // Original Author: Randy Gaul 6 | // Date: 7/3/2012 7 | // Contact: r.gaul@digipen.edu 8 | //////////////////////////////////////////////////// 9 | 10 | // Documentation: http://cecilsunkure.blogspot.com/2010/11/prngs-psuedo-random-number-generator.html 11 | 12 | #include 13 | #include 14 | #include "Random.h" 15 | 16 | // Seeds the PRNG 17 | void InitRandSeed( void ) 18 | { 19 | srand( (unsigned int)time( 0 ) ); 20 | } 21 | 22 | // Returns random int from range of low to high (inclusive) 23 | int RandomInt( int low, int high ) 24 | { 25 | return (rand() % (high - low + 1) + low); 26 | } 27 | -------------------------------------------------------------------------------- /AsciiEngine/Random.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////// 2 | // Copyright (c) 2012 ICRL 3 | // See the file LICENSE.txt for copying permission. 4 | // 5 | // Original Author: Randy Gaul 6 | // Date: 7/3/2012 7 | // Contact: r.gaul@digipen.edu 8 | //////////////////////////////////////////////////// 9 | 10 | #ifndef RANDOMH 11 | #define RANDOMH 12 | 13 | void InitRandSeed( void ); 14 | int RandomInt( int low, int high ); 15 | 16 | #endif RANDOMH -------------------------------------------------------------------------------- /AsciiEngine/Registration.c: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////// 2 | // Copyright (c) 2012 ICRL 3 | // See the file LICENSE.txt for copying permission. 4 | // 5 | // Original Author: Randy Gaul 6 | // Date: 7/15/2012 7 | // Contact: r.gaul@digipen.edu 8 | //////////////////////////////////////////////////// 9 | 10 | // This file contains a single function for easy maintaince of 11 | // the initialization of all entity creators 12 | 13 | #include "Registration.h" 14 | #include "EntityFactory.h" 15 | #include "EntityCreatorTable.h" 16 | 17 | // Includes for different entity types 18 | #include "Hero.h" 19 | #include "Tile.h" 20 | #include "StaticBackground.h" 21 | #include "SimpleEnemy.h" 22 | #include "DamageDealer.h" 23 | #include "DamageText.h" 24 | #include "Item.h" 25 | #include "ItemParticle.h" 26 | #include "Point.h" 27 | 28 | // Includes for different component types 29 | #include "Sprite.h" 30 | #include "Cloud.h" 31 | #include "Animation.h" 32 | #include "Square.h" 33 | #include "ActionList.h" 34 | #include "Physics.h" 35 | #include "Player.h" 36 | #include "Hitpoints.h" 37 | #include "SmallInventory.h" 38 | #include "JumperLittle.h" 39 | 40 | #define REGISTER_CREATOR( TYPE ) \ 41 | INSERT_DATA( P_ENTITY_CREATOR, ENTITY_CREATOR_TABLE, &TYPE##_CREATOR, TYPE##_CREATOR.ID ) 42 | 43 | 44 | // 45 | // RegisterEntityClasses 46 | // Purpose: Register all entity class types by entering their creators 47 | // into the creator map, and initialize class resources/names. 48 | // 49 | RETURN_TYPE RegisterEntityClasses( void ) 50 | { 51 | ENTITY_CREATOR_TABLE = CREATE_TABLE( P_ENTITY_CREATOR, 101 ); 52 | REGISTER_CREATOR( HERO ); 53 | REGISTER_CREATOR( TILE ); 54 | REGISTER_CREATOR( STATICBG ); 55 | REGISTER_CREATOR( SIMPLE_ENEMY ); 56 | REGISTER_CREATOR( DAMAGE_DEALER ); 57 | REGISTER_CREATOR( DAMAGE_TEXT); 58 | REGISTER_CREATOR( ITEM ); 59 | REGISTER_CREATOR( ITEM_PARTICLE ); 60 | REGISTER_CREATOR( POINT ); 61 | return RETURN_SUCCESS; 62 | } 63 | 64 | // 65 | // RegisterEntityComponents 66 | // Purpose: Register all component classes by initializes class 67 | // resources and names. 68 | // 69 | RETURN_TYPE RegisterEntityComponents( void ) 70 | { 71 | SpriteInit( "Sprite" ); 72 | CloudInit( "Cloud" ); 73 | AnimationInit( "Animation" ); 74 | SquareInit( "Square" ); 75 | ActionListInit( "ActionList" ); 76 | PhysInit( "Physics" ); 77 | PlaCInit( "Player" ); 78 | HitPointsInit( "HitPoints" ); 79 | SmallInventoryInit( "SmallInventory" ); 80 | JumperLittleInit( "JumperLittle" ); 81 | return RETURN_SUCCESS; 82 | } -------------------------------------------------------------------------------- /AsciiEngine/Registration.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////// 2 | // Copyright (c) 2012 ICRL 3 | // See the file LICENSE.txt for copying permission. 4 | // 5 | // Original Author: Randy Gaul 6 | // Date: 7/15/2012 7 | // Contact: r.gaul@digipen.edu 8 | //////////////////////////////////////////////////// 9 | 10 | // This file contains a single function for easy maintaince of 11 | // the initialization of all entity creators 12 | 13 | #pragma once 14 | 15 | #include "GlobalDefines.h" 16 | 17 | // 18 | // RegisterEntityClasses 19 | // Purpose: Register all entity class types by entering their creators 20 | // into the creator map, and initialize class resources/names. 21 | // 22 | RETURN_TYPE RegisterEntityClasses( void ); 23 | 24 | // 25 | // RegisterEntityComponents 26 | // Purpose: Register all component classes by initializes class 27 | // resources and names. 28 | // 29 | RETURN_TYPE RegisterEntityComponents( void ); 30 | -------------------------------------------------------------------------------- /AsciiEngine/Release/AsciiEngine.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RandyGaul/AsciiEngine/ffd4766e0f81c5b2efa347484585d09a6e4d2b26/AsciiEngine/Release/AsciiEngine.exe -------------------------------------------------------------------------------- /AsciiEngine/Release/README.txt: -------------------------------------------------------------------------------- 1 | Double click exe to run demo. 2 | 3 | The demo starts in the first state of three total states. Press keys 1, 2 or 3 to go to their respective states. 4 | 5 | State 1: 6 | Loads all game entities from file using the deserialization functionality. Saves the state of all objects upon state end to disk. 7 | 8 | State 2: 9 | Deserialize the saved data from state 1. 10 | 11 | State 3: 12 | Example (unfinished) map editor. Left click to place Tile objects. This demonstrates the new button class by detecting clicks onto the drawing area via a single button. -------------------------------------------------------------------------------- /AsciiEngine/Serialize.c: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////// 2 | // Copyright (c) 2012 ICRL 3 | // See the file LICENSE.txt for copying permission. 4 | // 5 | // Original Author: Randy Gaul 6 | // Date: 8/7/2012 7 | // Contact: r.gaul@digipen.edu 8 | //////////////////////////////////////////////////// 9 | 10 | #include "Serialize.h" 11 | 12 | static FILE *fp = NULL; 13 | static const char *FILENAME = NULL; 14 | 15 | // 16 | // SerializerCloseFile 17 | // Purpose: Makes the serializer shut down the current file in use. 18 | // 19 | void SerializerCloseFile( void ) 20 | { 21 | fclose( fp ); 22 | fp = NULL; 23 | } 24 | 25 | // 26 | // SerializerSetFile 27 | // Purpose: Sets the current file name for the serializer to use. 28 | // 29 | void SerializerSetFile( const char *fileName ) 30 | { 31 | if(fp) 32 | { 33 | SerializerCloseFile( ); 34 | } 35 | 36 | FILENAME = fileName; 37 | } 38 | 39 | // 40 | // SerializeString 41 | // Purpose: Writes a string to file. 42 | // 43 | void SerializeString( const char *string ) 44 | { 45 | SERIALIZE_OPEN_FILE 46 | { 47 | fprintf_s( fp, "%s\n", string ); 48 | } 49 | } 50 | 51 | // 52 | // DeserializeString 53 | // Purpose: Reads a string in from file. 54 | // 55 | int DeserializeString( char *string ) 56 | { 57 | DESERIALIZE_OPEN_FILE 58 | { 59 | return fscanf_s( fp, "%[^\n]", string, MAX_SERIALIZER_STRLEN - 1 ); 60 | } 61 | return EOF; 62 | } 63 | 64 | // 65 | // SerializeInt 66 | // Purpose: Writes an int to file. 67 | // 68 | void SerializeInt( int val ) 69 | { 70 | SERIALIZE_OPEN_FILE 71 | { 72 | fprintf_s( fp, "%d\n", val ); 73 | } 74 | } 75 | 76 | // 77 | // DeserializeInt 78 | // Purpose: Reads an int from file. 79 | // 80 | int DeserializeInt( int *val ) 81 | { 82 | DESERIALIZE_OPEN_FILE 83 | { 84 | int msg = fscanf_s( fp, "%d", val ); 85 | fgetc( fp ); 86 | return msg; 87 | } 88 | return EOF; 89 | } 90 | 91 | // 92 | // SerializeFloat 93 | // Purpose: Writes a float to file. 94 | // 95 | void SerializeFloat( float val ) 96 | { 97 | SERIALIZE_OPEN_FILE 98 | { 99 | fprintf_s( fp, "%f\n", val ); 100 | } 101 | } 102 | 103 | // 104 | // DeserializeFloat 105 | // Purpose: Reads an int from file. 106 | // 107 | int DeserializeFloat( float *val ) 108 | { 109 | DESERIALIZE_OPEN_FILE 110 | { 111 | int msg = fscanf_s( fp, "%f", val ); 112 | fgetc( fp ); 113 | return msg; 114 | } 115 | return EOF; 116 | } 117 | 118 | // 119 | // SerializeMapDimensions 120 | // Purpose: Serializes the map's dimensions. 121 | // 122 | void SerializeMapDimensions( void ) 123 | { 124 | SERIALIZE_OPEN_FILE 125 | { 126 | SerializeInt( TILE_MAP_SYSTEM.MAP_WIDTH ); 127 | SerializeInt( TILE_MAP_SYSTEM.MAP_HEIGHT ); 128 | } 129 | } 130 | 131 | // 132 | // DeserializeMapDimensions 133 | // Purpose: Deserializes the map's dimensions. 134 | // 135 | void DeserializeMapDimensions( void ) 136 | { 137 | DESERIALIZE_OPEN_FILE 138 | { 139 | DeserializeInt( &TILE_MAP_SYSTEM.MAP_WIDTH ); 140 | DeserializeInt( &TILE_MAP_SYSTEM.MAP_HEIGHT ); 141 | } 142 | } 143 | 144 | // 145 | // EntityToFile 146 | // Purpose: Serializes a game entity to a file. 147 | // 148 | void EntityToFile( ENTITY *entity ) 149 | { 150 | SERIALIZE_OPEN_FILE 151 | { 152 | VECTOR2D pos = { 0 }; 153 | int HP = 0; 154 | int i, inventoryNumElem = 0; 155 | ITEM_ID item; 156 | 157 | SerializeString( entity->CLASS_NAME ); 158 | 159 | // Serialize position 160 | SendEntityMessage( entity, EM_GETPOS, (int)&pos.x_, (int)&pos.y_ ); 161 | SerializeFloat( pos.x_ ); 162 | SerializeFloat( pos.y_ ); 163 | 164 | // Serialize HP 165 | SendEntityMessage( entity, EM_GETHP, (int)&HP, 0 ); 166 | SerializeInt( HP ); 167 | 168 | // Serialize inventory 169 | SendEntityMessage( entity, EM_GETINVSZ, (int)&inventoryNumElem, 0 ); 170 | SerializeInt( inventoryNumElem ); 171 | for(i = 0; i < inventoryNumElem; ++i) 172 | { 173 | SendEntityMessage( entity, EM_GETINV, (int)&item, i ); 174 | SerializeInt( item ); 175 | } 176 | } 177 | } 178 | 179 | // 180 | // FileToEntities 181 | // Purpose: Deserializes all game entities from a file. 182 | // 183 | ENTITY *FileToEntities( const char *fileName ) 184 | { 185 | ENTITY *entity = NULL; 186 | 187 | SerializerSetFile( fileName ); 188 | 189 | DESERIALIZE_OPEN_FILE 190 | { 191 | DeserializeMapDimensions( ); 192 | for(;;) 193 | { 194 | char CLASS_NAME[MAX_SERIALIZER_STRLEN] = { 0 }; 195 | int hp = 0, inventoryNumElem = 0, i, item; 196 | VECTOR2D pos = { 0 }; 197 | 198 | DeserializeString( CLASS_NAME ); 199 | DeserializeFloat( &pos.x_ ); 200 | DeserializeFloat( &pos.y_ ); 201 | DeserializeInt( &hp ); 202 | DeserializeInt( &inventoryNumElem ); 203 | 204 | if(feof( fp )) 205 | { 206 | SerializerCloseFile( ); 207 | return NULL; 208 | } 209 | 210 | entity = CreateEntity( CLASS_NAME, 0, 0 ); 211 | 212 | for(i = 0; i < inventoryNumElem; ++i) 213 | { 214 | DeserializeInt( &item ); 215 | SendEntityMessage( entity, EM_SETINV, item, i ); 216 | } 217 | 218 | SendEntityMessage( entity, EM_SETHP, hp, 0 ); 219 | SendEntityMessage( entity, EM_SETPOS, (int)&pos.x_, (int)&pos.y_ ); 220 | } 221 | } 222 | 223 | SerializerCloseFile( ); 224 | 225 | return entity; 226 | } 227 | -------------------------------------------------------------------------------- /AsciiEngine/Serialize.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////// 2 | // Copyright (c) 2012 ICRL 3 | // See the file LICENSE.txt for copying permission. 4 | // 5 | // Original Author: Randy Gaul 6 | // Date: 8/7/2012 7 | // Contact: r.gaul@digipen.edu 8 | //////////////////////////////////////////////////// 9 | 10 | #pragma once 11 | 12 | #include 13 | #include "Entity.h" 14 | #include "EntityManager.h" 15 | #include "EntityFactory.h" 16 | #include "ItemList.h" 17 | #include "Component.h" 18 | #include "SmallInventory.h" 19 | #include "TileMap.h" 20 | 21 | #define SERIALIZE_OPEN_FILE if(!fp) \ 22 | fopen_s( &fp, FILENAME, "w" ); \ 23 | if(fp) 24 | 25 | #define DESERIALIZE_OPEN_FILE if(!fp) \ 26 | fopen_s( &fp, FILENAME, "r" ); \ 27 | if(fp) 28 | 29 | #define MAX_SERIALIZER_STRLEN 100 30 | 31 | // 32 | // SerializerCloseFile 33 | // Purpose: Makes the serializer shut down the current file in use. 34 | // 35 | void SerializerCloseFile( void ); 36 | 37 | // 38 | // SerializerSetFile 39 | // Purpose: Sets the current file name for the serializer to use. 40 | // 41 | void SerializerSetFile( const char *fileName ); 42 | 43 | // 44 | // SerializeString 45 | // Purpose: Writes a string to file. 46 | // 47 | void SerializeString( const char *string ); 48 | 49 | // 50 | // DeserializeString 51 | // Purpose: Reads a string in from file. 52 | // 53 | int DeserializeString( char *string ); 54 | 55 | // 56 | // SerializeInt 57 | // Purpose: Writes an int to file. 58 | // 59 | void SerializeInt( int val ); 60 | 61 | // 62 | // DeserializeInt 63 | // Purpose: Reads an int from file. 64 | // 65 | int DeserializeInt( int *val ); 66 | 67 | // 68 | // SerializeFloat 69 | // Purpose: Writes a float to file. 70 | // 71 | void SerializeFloat( float val ); 72 | 73 | // 74 | // DeserializeFloat 75 | // Purpose: Reads an int from file. 76 | // 77 | int DeserializeFloat( float *val ); 78 | 79 | // 80 | // SerializeMapDimensions 81 | // Purpose: Serializes the map's dimensions. 82 | // 83 | void SerializeMapDimensions( void ); 84 | 85 | // 86 | // DeserializeMapDimensions 87 | // Purpose: Deserializes the map's dimensions. 88 | // 89 | void DeserializeMapDimensions( void ); 90 | 91 | // 92 | // EntityToFile 93 | // Purpose: Serializes a game entity to a file. Overwrites existing files. 94 | // 95 | void EntityToFile( ENTITY *entity ); 96 | 97 | // 98 | // FileToEntities 99 | // Purpose: Deserializes all game entities from a file. 100 | // 101 | ENTITY *FileToEntities( const char *fileName ); 102 | -------------------------------------------------------------------------------- /AsciiEngine/Shapes.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////// 2 | // Copyright (c) 2012 ICRL 3 | // See the file LICENSE.txt for copying permission. 4 | // 5 | // Original Author: Randy Gaul 6 | // Date: 7/5/2012 7 | // Contact: r.gaul@digipen.edu 8 | //////////////////////////////////////////////////// 9 | 10 | #ifndef SHAPESH 11 | #define SHAPESH 12 | 13 | #include "Vector2D.h" 14 | 15 | typedef struct _AE_CIRCLE 16 | { 17 | VECTOR2D center_; 18 | float radius_; 19 | } AE_CIRCLE; 20 | 21 | typedef struct _AE_RECT 22 | { 23 | VECTOR2D center_; 24 | float width_; 25 | float height_; 26 | } AE_RECT; 27 | 28 | typedef struct _AE_COORD 29 | { 30 | int x_, y_; 31 | } AE_COORD; 32 | 33 | #endif SHAPESH -------------------------------------------------------------------------------- /AsciiEngine/SimpleEnemy.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////// 2 | // Copyright (c) 2012 ICRL 3 | // See the file LICENSE.txt for copying permission. 4 | // 5 | // Original Author: Randy Gaul 6 | // Date: 7/21/2012 7 | // Contact: r.gaul@digipen.edu 8 | //////////////////////////////////////////////////// 9 | 10 | #pragma once 11 | 12 | #include "EntityCreator.h" 13 | 14 | // Definition of the creator of this entity 15 | extern ENTITY_CREATOR SIMPLE_ENEMY_CREATOR; 16 | -------------------------------------------------------------------------------- /AsciiEngine/SmallInventory.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////// 2 | // Copyright (c) 2012 ICRL 3 | // See the file LICENSE.txt for copying permission. 4 | // 5 | // Original Author: Randy Gaul 6 | // Date: 7/24/2012 7 | // Contact: r.gaul@digipen.edu 8 | //////////////////////////////////////////////////// 9 | 10 | #pragma once 11 | 12 | #include "Message.h" 13 | #include "ItemList.h" 14 | #include "InventoryComponent.h" 15 | 16 | #define SI_SLOT_NUM 18 17 | 18 | // 19 | // HP class 20 | // This class is derived from the SmallInventory_COMPONENT base, and represents 21 | // normal HP. 22 | // 23 | typedef struct _SMALL_INVENTORY_COMPONENT 24 | { 25 | INVENTORY_COMPONENT base; 26 | BOOL drawMe; 27 | ITEM_ID data[SI_SLOT_NUM]; 28 | } SI; 29 | 30 | // 31 | // ClassCOM_PROC 32 | // Purpose: Component procedure for this component type. Dispatches messages 33 | // recieved in the appropriate manner. 34 | // 35 | void SmallInventoryCOM_PROC( SI *self, EM msg, int var1, int var2 ); 36 | 37 | // 38 | // ClassCreate 39 | // Purpose: Acts as a constructor for this class. Initializes the 40 | // data and dynamically allocates any extra space needed, and 41 | // initializes the allocated space with data. 42 | // 43 | void SmallInventoryCreate( SI *self ); 44 | 45 | // 46 | // ClassInit 47 | // Purpose: One-time initialization of the class. Use this function to load resources from disk, 48 | // set up static class variables, or anything else. 49 | // 50 | void SmallInventoryInit( const char *className ); 51 | 52 | // 53 | // ClassDraw 54 | // Purpose: Draws a visual representation of the class. 55 | // 56 | void SmallInventoryDraw( SI *self ); 57 | 58 | // 59 | // SmallInventoryUpdate 60 | // Purpose: Disables and enables PICK_ME_UP_ITEM. 61 | // 62 | void SmallInventoryUpdate( SI *self ); 63 | 64 | // 65 | // SmallInventoryGet 66 | // Purpose: Copies value of inventory at index var2 into int *var1 67 | // 68 | void SmallInventoryGet( SI *self, int *copyToMe, int index ); 69 | 70 | // 71 | // SmallInventorySet 72 | // Purpose: Copies value of ITEM_ID var1 into slot var2 73 | // 74 | void SmallInventorySet( SI *self, ITEM_ID replaceWithMe, int index ); 75 | 76 | // 77 | // SmallInventoryGetSize 78 | // Purpose: Copies the size in number of elements of the inventory array into int *var1 79 | // 80 | void SmallInventoryGetSize( int *size ); 81 | 82 | // 83 | // SmallInventoryInsert 84 | // Purpose: Inserts an item into the first available empty slot. 85 | // 86 | RETURN_TYPE SmallInventoryInsert( SI *self, ITEM_ID id ); 87 | 88 | // 89 | // SmallInventoryEject 90 | // Purpose: Creates an item entity for each item in the inventory, and empties the inventory. 91 | // 92 | void SmallInventoryEject( SI *self ); 93 | 94 | // 95 | // SmallInventoryToggleDrawMe 96 | // Purpose: Toggles boolean drawMe of SI class 97 | // 98 | void SmallInventoryToggleDrawMe( SI *self ); 99 | 100 | // 101 | // SmallInventoryGetDrawMe 102 | // Purpose: Copies drawMe into BOOL *var1 103 | // 104 | void SmallInventoryGetDrawMe( SI *self, BOOL *drawMe ); 105 | 106 | // 107 | // SmallInventorySetDrawMe 108 | // Purpose: Copies content of BOOL *var1 into drawMe 109 | // 110 | void SmallInventorySetDrawMe( SI *self, BOOL drawMe ); 111 | -------------------------------------------------------------------------------- /AsciiEngine/Sprite.c: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////// 2 | // Copyright (c) 2012 ICRL 3 | // See the file LICENSE.txt for copying permission. 4 | // 5 | // Original Author: Randy Gaul 6 | // Date: 7/16/2012 7 | // Contact: r.gaul@digipen.edu 8 | //////////////////////////////////////////////////// 9 | 10 | #include "Sprite.h" 11 | #include "EntityManager.h" 12 | #include "Camera.h" 13 | 14 | // Static class variables and data 15 | static const char *CLASS_NAME = NULL; 16 | 17 | // 18 | // ClassCOM_PROC 19 | // Purpose: Component procedure for this component type. Dispatches messages 20 | // recieved in the appropriate manner. 21 | // 22 | void SpriteCOM_PROC( SPRITE *self, EM msg, int var1, int var2 ) 23 | { 24 | switch(msg) 25 | { 26 | case EM_CLSINIT: 27 | SpriteInit( (const char *)var1 ); 28 | break; 29 | case EM_CREATE: 30 | SpriteCreate( self, (IMAGE *)var1 ); 31 | break; 32 | case EM_DRAW: 33 | SpriteDraw( self ); 34 | break; 35 | } 36 | } 37 | 38 | // 39 | // ClassCreate 40 | // Purpose: Acts as a constructor for this class. Initializes the 41 | // data and dynamically allocates any extra space needed, and 42 | // initializes the allocated space with data. 43 | // 44 | void SpriteCreate( SPRITE *self, IMAGE *image ) 45 | { 46 | self->image = image; 47 | self->base.CLASS_NAME = CLASS_NAME; 48 | } 49 | 50 | // 51 | // ClassInit 52 | // Purpose: One-time initialization of the class. Use this function to load resources from disk, 53 | // set up static class variables, or anything else. 54 | // 55 | void SpriteInit( const char *className ) 56 | { 57 | CLASS_NAME = (const char *)malloc( strlen( className ) + 1 ); 58 | strcpy_s( (char *)CLASS_NAME, strlen( className ) + 1 , className ); 59 | } 60 | 61 | // 62 | // ComponentDraw 63 | // Purpose: Simply renders the sprite 64 | // 65 | void SpriteDraw( SPRITE *self ) 66 | { 67 | float x, y; 68 | VECTOR2D WH = { 0 }; 69 | SendEntityMessage( self->base.owner, EM_GETPOS, (int)&x, (int)&y ); 70 | SendEntityMessage( self->base.owner, EM_GETWH, (int)&WH.x_, (int)&WH.y_ ); 71 | if(self->image) 72 | { 73 | WriteImageToScreen( self->image->ID, 74 | FloatToInt( x - CAMOFFX - WH.x_ / 2.f + DimensionOffset( WH.x_ ) ), 75 | FloatToInt( y - CAMOFFY - WH.y_ / 2.f + 1.f ) ); 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /AsciiEngine/Sprite.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////// 2 | // Copyright (c) 2012 ICRL 3 | // See the file LICENSE.txt for copying permission. 4 | // 5 | // Original Author: Randy Gaul 6 | // Date: 7/16/2012 7 | // Contact: r.gaul@digipen.edu 8 | //////////////////////////////////////////////////// 9 | 10 | #pragma once 11 | 12 | #include "Graphics.h" 13 | #include "GraphicsComponent.h" 14 | #include "Shapes.h" 15 | 16 | // 17 | // SPRITE class 18 | // This class is derived from the GRAPHICS_COMPONENT base, and represents 19 | // a two dimensional sprite image. 20 | // 21 | typedef struct _SPRITE_COMPONENT 22 | { 23 | GRAPHICS_COMPONENT base; 24 | IMAGE *image; 25 | } SPRITE; 26 | 27 | // 28 | // ClassCOM_PROC 29 | // Purpose: Component procedure for this component type. Dispatches messages 30 | // recieved in the appropriate manner. 31 | // 32 | void SpriteCOM_PROC( struct _SPRITE_COMPONENT *self, EM msg, int var1, int var2 ); 33 | 34 | // 35 | // ClassCreate 36 | // Purpose: Acts as a constructor for this class. Initializes the 37 | // data and dynamically allocates any extra space needed, and 38 | // initializes the allocated space with data. 39 | // 40 | void SpriteCreate( struct _SPRITE_COMPONENT *self, IMAGE *image ); 41 | 42 | // 43 | // ClassInit 44 | // Purpose: One-time initialization of the class. Use this function to load resources from disk, 45 | // set up static class variables, or anything else. 46 | // 47 | void SpriteInit( const char *className ); 48 | 49 | // 50 | // ComponentDraw 51 | // Purpose: Simply renders the sprite 52 | // 53 | void SpriteDraw( SPRITE *self ); 54 | 55 | -------------------------------------------------------------------------------- /AsciiEngine/Square.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////// 2 | // Copyright (c) 2012 ICRL 3 | // See the file LICENSE.txt for copying permission. 4 | // 5 | // Original Author: Randy Gaul 6 | // Date: 7/17/2012 7 | // Contact: r.gaul@digipen.edu 8 | //////////////////////////////////////////////////// 9 | 10 | #pragma once 11 | 12 | #include "CollisionComponent.h" 13 | #include "Entity.h" 14 | #include "Vector2D.h" 15 | #include "Math2D.h" 16 | #include "Shapes.h" 17 | 18 | // 19 | // SQUARE class 20 | // This class is derived from the GRAPHICS_COMPONENT base, and represents 21 | // a two dimensional sprite image. 22 | // 23 | typedef struct _SQUARE_COMPONENT 24 | { 25 | COLLISION_COMPONENT base; 26 | AE_RECT rect; 27 | } SQUARE; 28 | 29 | // 30 | // ClassCOM_PROC 31 | // Purpose: Component procedure for this component type. Dispatches messages 32 | // recieved in the appropriate manner. 33 | // 34 | void SquareCOM_PROC( SQUARE *self, EM msg, int var1, int var2 ); 35 | 36 | // 37 | // ClassCreate 38 | // Purpose: Acts as a constructor for this class. Initializes the 39 | // data and dynamically allocates any extra space needed, and 40 | // initializes the allocated space with data. 41 | // 42 | void SquareCreate( SQUARE *self, float *var1, float *var2 ); 43 | 44 | // 45 | // ClassInit 46 | // Purpose: One-time initialization of the class. Use this function to load resources from disk, 47 | // set up static class variables, or anything else. 48 | // 49 | void SquareInit( const char *className ); 50 | 51 | // 52 | // ClassSetWidthHeight 53 | // Purpose: Sets the width and height of the class. Takes two floats. 54 | // 55 | void SquareSetWidthHeight( SQUARE *self, float *var1, float *var2 ); 56 | 57 | // 58 | // ClassGetWidthHeight 59 | // Purpose: Copiess values of x and y position into var1 and var2 60 | // respectively. 61 | // 62 | void SquareGetWidthHeight( SQUARE *self, float *var1, float *var2 ); 63 | 64 | 65 | // 66 | // ClassSendHitTest 67 | // Purpose: 68 | // Notes : 69 | // 70 | void SquareSendHitTest( SQUARE *self, float *dt ); 71 | 72 | // 73 | // ClassHitTest 74 | // Purpose: 75 | // 76 | void SquareHitTest( SQUARE *self, COL_DATA *data ); 77 | 78 | // 79 | // ClassIHitYou 80 | // Purpose: A response message sent to the sender of a EM_HITTEST message 81 | // var1 is pointer to the sender (ENTITY *) 82 | // var2 is BOOL for x(true) or y(false) axis collision 83 | // 84 | void SquareIHitYou( SQUARE *self, ENTITY *collidee, BOOL axis ); 85 | -------------------------------------------------------------------------------- /AsciiEngine/StaticBackground.c: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////// 2 | // Copyright (c) 2012 ICRL 3 | // See the file LICENSE.txt for copying permission. 4 | // 5 | // Original Author: Randy Gaul 6 | // Date: 7/17/2012 7 | // Contact: r.gaul@digipen.edu 8 | //////////////////////////////////////////////////// 9 | 10 | #include "ImageTable.h" 11 | #include "Component.h" 12 | #include "EntityCreatorTable.h" // Map entity creators to string IDs 13 | #include "EntityManager.h" // SendEntityMessage 14 | 15 | static const char *CLASS_NAME = NULL; 16 | 17 | void StaticBGConstruct( ENTITY *self, float *x, float *y ); 18 | void StaticBGInit ( const char *className ); 19 | void StaticBGSet ( ENTITY *self, va_list args ); 20 | void StaticBGUpdate ( ENTITY *self, float *dt ); 21 | void StaticBGDraw ( ENTITY *self ); 22 | void StaticBGDestroy ( ENTITY *self ); 23 | ENTITY *StaticBGCreate( int x, int y ); 24 | 25 | // 26 | // StaticBGEM_PROC 27 | // Purpose; Processes entity messages. 28 | // 29 | void StaticBGEM_PROC( ENTITY *self, EM msg, int var1, int var2 ) 30 | { 31 | switch(msg) 32 | { 33 | // GENERAL 34 | case EM_CREATE: 35 | StaticBGConstruct( self, (float *)var1, (float *)var2 ); 36 | break; 37 | case EM_DESTROY: 38 | StaticBGDestroy( self ); 39 | break; 40 | case EM_CLSINIT: 41 | StaticBGInit( (const char *)var1 ); 42 | break; 43 | case EM_DRAW: 44 | StaticBGDraw( self ); 45 | break; 46 | case EM_INACTIVE: 47 | EntityInactive( self ); 48 | break; 49 | 50 | // DATA ACCESS 51 | case EM_SETPOS: 52 | SendComEM( self->comps.POSC, EM_SETPOS, var1, var2 ); 53 | break; 54 | case EM_GETPOS: 55 | SendComEM( self->comps.POSC, EM_GETPOS, var1, var2 ); 56 | } 57 | } 58 | 59 | // Constructor for this entity type 60 | // Notes: Do not allocate space for the entity itself! This is handled 61 | // by the entity factory. This function is for allocation of 62 | // any other necessary memory. Perhaps a dynamically allocated 63 | // string, or other various memory allocations that are to be 64 | // pointed to by this entity. 65 | void StaticBGConstruct( ENTITY *self, float *x, float *y ) 66 | { 67 | AddSpriteComponent( self, FIND_DATA( P_IMAGE, IMAGE_TABLE, "CloudBG.AEArt" ), DISABLE_CAM ); 68 | AddPositionComponent( self, (int)x, (int)y ); 69 | self->CLASS_NAME = CLASS_NAME; 70 | self->zOrder = 20; 71 | } 72 | 73 | // Default initializer for this entity type 74 | // Notes: This function calls the Set function for this entity type. 75 | // The purpose of the set function is to set the values of the 76 | // self entity to those of the parameters. However the Init 77 | // function of an entity acts as "default parameters" for the 78 | // set function. Since parameter defaults are not apart of the C 79 | // standard this workaround becomes necessary. 80 | void StaticBGInit ( const char *className ) 81 | { 82 | CLASS_NAME = (const char *)malloc( strlen( className ) + 1 ); 83 | strcpy_s( (char *)CLASS_NAME, strlen( className ) + 1, className ); 84 | } 85 | 86 | // Draw function for this entity type 87 | void StaticBGDraw ( ENTITY *self ) 88 | { 89 | float x, y; 90 | SendComEM( self->comps.POSC, EM_GETPOS, &x, &y ); 91 | SendComEM( self->comps.GC, EM_DRAW, x, y ); 92 | } 93 | 94 | // Destructor for this entity type 95 | // Notes: Only free things in this function that were allocated in the 96 | // construtor! The entity factory actually handles deallocation 97 | // of the entity itself. 98 | void StaticBGDestroy ( ENTITY *self ) 99 | { 100 | RemoveGraphicsComponent( self ); 101 | RemovePositionComponent( self ); 102 | } 103 | 104 | // Creator for this entity, assign a string ID and a creator function 105 | // For use with the EntityFactory -- allows simple dynamicly maintained 106 | // method for creation of entitys without necessity to maintain explicit 107 | // code 108 | ENTITY_CREATOR STATICBG_CREATOR = { 109 | "STATICBG", 110 | StaticBGCreate 111 | }; 112 | 113 | // 114 | // StaticBG 115 | // Purpose: Creates a specific type of entity 116 | // 117 | ENTITY *StaticBGCreate( int x, int y ) 118 | { 119 | ENTITY *entity = (ENTITY *)malloc( sizeof( ENTITY ) ); 120 | memset( entity, 0, sizeof( ENTITY ) ); 121 | StaticBGInit( STATICBG_CREATOR.ID ); // Register class name 122 | entity->EM_PROC = StaticBGEM_PROC; 123 | SendEntityMessage( entity, EM_CREATE, x, y ); 124 | CLASS_NAME = STATICBG_CREATOR.ID; 125 | return entity; 126 | } 127 | -------------------------------------------------------------------------------- /AsciiEngine/StaticBackground.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////// 2 | // Copyright (c) 2012 ICRL 3 | // See the file LICENSE.txt for copying permission. 4 | // 5 | // Original Author: Randy Gaul 6 | // Date: 7/20/2012 7 | // Contact: r.gaul@digipen.edu 8 | //////////////////////////////////////////////////// 9 | 10 | #pragma once 11 | 12 | #include "EntityCreator.h" 13 | 14 | // Definition of the creator of this entity 15 | extern ENTITY_CREATOR STATICBG_CREATOR; 16 | -------------------------------------------------------------------------------- /AsciiEngine/StringHash.c: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////// 2 | // Copyright (c) 2012 ICRL 3 | // See the file LICENSE.txt for copying permission. 4 | // 5 | // Original Author: Randy Gaul 6 | // Date: 7/3/2012 7 | // Contact: r.gaul@digipen.edu 8 | //////////////////////////////////////////////////// 9 | 10 | // This file contains functionality for hashing strings 11 | // Documentation: http://cecilsunkure.blogspot.com/2012/07/hash-tables.html 12 | 13 | #include "StringHash.h" 14 | 15 | // Hashing function from Program 14.2 in the Sedgewick book 16 | unsigned UHashMod( const char *Key, unsigned tableSize ) 17 | { 18 | unsigned hash = 0; // Initial value of hash 19 | unsigned rand1 = 31415; // "Random" 1 20 | unsigned rand2 = 27183; // "Random" 2 21 | 22 | while (*Key) 23 | { 24 | hash = hash * rand1; // Multiply hash by random 25 | hash = (hash + *Key); // Add in current char, keep within TableSize 26 | rand1 = (rand1 * rand2); // Update rand1 for next "random" number 27 | Key++; 28 | } 29 | 30 | return hash % tableSize; 31 | } 32 | -------------------------------------------------------------------------------- /AsciiEngine/StringHash.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////// 2 | // Copyright (c) 2012 ICRL 3 | // See the file LICENSE.txt for copying permission. 4 | // 5 | // Original Author: Randy Gaul 6 | // Date: 7/3/2012 7 | // Contact: r.gaul@digipen.edu 8 | //////////////////////////////////////////////////// 9 | 10 | #ifndef STRINGHASHH 11 | #define STRINGHASHH 12 | 13 | #include "GlobalDefines.h" 14 | 15 | unsigned UHashMod( const char *Key, unsigned tableSize ); 16 | 17 | #endif STRINGHASHH -------------------------------------------------------------------------------- /AsciiEngine/TestLevel.c: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////// 2 | // Copyright (c) 2012 ICRL 3 | // See the file LICENSE.txt for copying permission. 4 | // 5 | // Original Author: Randy Gaul 6 | // Date: 7/10/2012 7 | // Contact: r.gaul@digipen.edu 8 | //////////////////////////////////////////////////// 9 | 10 | #include "GameStateManager.h" 11 | #include "GameStateList.h" 12 | #include "GlobalDefines.h" 13 | #include "Graphics.h" // Various graphics functions 14 | #include "Input.h" // Various input functions 15 | #include "ConsoleFuncs.h" // RenderScreen; 16 | #include "EntityFactory.h" // Entity creation system 17 | #include "EntityManager.h" // Entity management system 18 | #include "OpenFile.h" // LoadAllArtAssets; 19 | #include "Camera.h" // GlobalCamInit; GlobalCamDisable 20 | #include "FrameRateController.h" // GetDT 21 | #include "Serialize.h" 22 | 23 | RETURN_TYPE TestLevelLoad( void ) 24 | { 25 | // Loads all art assets from a specific folder 26 | LoadAllArtAssets( "../ArtAssets/" ); 27 | 28 | return RETURN_SUCCESS; 29 | } 30 | 31 | RETURN_TYPE TestLevelInit( void ) 32 | { 33 | ENTITY_LIST = LIST_CONSTRUCT( P_ENTITY ); 34 | 35 | FileToEntities( "../MapAssets/TestLevel.txt" ); 36 | 37 | return RETURN_SUCCESS; 38 | } 39 | 40 | RETURN_TYPE TestLevelUpdate( void ) 41 | { 42 | if(IsKeyPressed( VK_1 )) 43 | { 44 | nextState = TestLevel; 45 | } 46 | 47 | if(IsKeyPressed( VK_2 )) 48 | { 49 | nextState = TestLevel2; 50 | } 51 | 52 | if(IsKeyPressed( VK_3 )) 53 | { 54 | nextState = MapEditor; 55 | } 56 | 57 | // Run all entitys' update functions. 58 | UpdateEntities( ); 59 | GlobalCamUpdate( GetDT( ) ); 60 | return RETURN_SUCCESS; 61 | } 62 | 63 | RETURN_TYPE TestLevelDraw( void ) 64 | { 65 | ClearBuffer( ); 66 | 67 | // draws all active entitys 68 | DrawEntities( ); 69 | 70 | RenderScreen( ); // Renders the DOUBLE_BUFFER to the screen 71 | return RETURN_SUCCESS; 72 | } 73 | 74 | RETURN_TYPE TestLevelFree( void ) 75 | { 76 | SerializeAllEntities( "../MapAssets/test.txt" ); 77 | 78 | // Frees all entitys within the EntityFactory system 79 | LIST_DESTROY( P_ENTITY, ENTITY_LIST ); 80 | 81 | // Reset camera for next state 82 | GlobalCamDisable( ); 83 | return RETURN_SUCCESS; 84 | } 85 | 86 | RETURN_TYPE TestLevelUnload( void ) 87 | { 88 | return RETURN_SUCCESS; 89 | } 90 | -------------------------------------------------------------------------------- /AsciiEngine/TestLevel.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////// 2 | // Copyright (c) 2012 ICRL 3 | // See the file LICENSE.txt for copying permission. 4 | // 5 | // Original Author: Randy Gaul 6 | // Date: 7/10/2012 7 | // Contact: r.gaul@digipen.edu 8 | //////////////////////////////////////////////////// 9 | 10 | #ifndef TESTLEVELH 11 | #define TESTLEVELH 12 | 13 | #include "GlobalDefines.h" 14 | 15 | RETURN_TYPE TestLevelLoad( void ); 16 | RETURN_TYPE TestLevelInit( void ); 17 | RETURN_TYPE TestLevelUpdate( void ); 18 | RETURN_TYPE TestLevelDraw( void ); 19 | RETURN_TYPE TestLevelFree( void ); 20 | RETURN_TYPE TestLevelUnload( void ); 21 | 22 | #endif TESTLEVELH -------------------------------------------------------------------------------- /AsciiEngine/TestLevel2.c: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////// 2 | // Copyright (c) 2012 ICRL 3 | // See the file LICENSE.txt for copying permission. 4 | // 5 | // Original Author: Randy Gaul 6 | // Date: 8/1/2012 7 | // Contact: r.gaul@digipen.edu 8 | //////////////////////////////////////////////////// 9 | 10 | #include "GameStateManager.h" 11 | #include "GameStateList.h" 12 | #include "GlobalDefines.h" 13 | #include "Input.h" // Various input functions 14 | #include "ConsoleFuncs.h" // RenderScreen; 15 | #include "EntityFactory.h" // Entity creation system 16 | #include "EntityManager.h" // Entity management system 17 | #include "OpenFile.h" // LoadAllArtAssets; 18 | #include "Camera.h" // GlobalCamInit; GlobalCamDisable 19 | #include "FrameRateController.h" // GetDT 20 | 21 | static ENTITY *character = NULL; 22 | 23 | RETURN_TYPE TestLevel2Load( void ) 24 | { 25 | return RETURN_SUCCESS; 26 | } 27 | 28 | RETURN_TYPE TestLevel2Init( void ) 29 | { 30 | ENTITY_LIST = LIST_CONSTRUCT( P_ENTITY ); 31 | 32 | FileToEntities( "../MapAssets/test.txt" ); 33 | return RETURN_SUCCESS; 34 | } 35 | 36 | RETURN_TYPE TestLevel2Update( void ) 37 | { 38 | if(IsKeyPressed( VK_1 )) 39 | { 40 | nextState = TestLevel; 41 | } 42 | 43 | if(IsKeyPressed( VK_2 )) 44 | { 45 | nextState = TestLevel2; 46 | } 47 | 48 | if(IsKeyPressed( VK_3 )) 49 | { 50 | nextState = MapEditor; 51 | } 52 | 53 | // Run all entitys' update functions. 54 | UpdateEntities( ); 55 | GlobalCamUpdate( GetDT( ) ); 56 | return RETURN_SUCCESS; 57 | } 58 | 59 | RETURN_TYPE TestLevel2Draw( void ) 60 | { 61 | ClearBuffer( ); 62 | 63 | // draws all active entitys 64 | DrawEntities( ); 65 | 66 | RenderScreen( ); // Renders the DOUBLE_BUFFER to the screen 67 | return RETURN_SUCCESS; 68 | } 69 | 70 | RETURN_TYPE TestLevel2Free( void ) 71 | { 72 | SerializeAllEntities( "../MapAssets/test2.txt" ); 73 | 74 | // Frees all entitys within the EntityFactory system 75 | LIST_DESTROY( P_ENTITY, ENTITY_LIST ); 76 | 77 | // Reset camera for next state 78 | GlobalCamDisable( ); 79 | return RETURN_SUCCESS; 80 | } 81 | 82 | RETURN_TYPE TestLevel2Unload( void ) 83 | { 84 | return RETURN_SUCCESS; 85 | } 86 | -------------------------------------------------------------------------------- /AsciiEngine/TestLevel2.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////// 2 | // Copyright (c) 2012 ICRL 3 | // See the file LICENSE.txt for copying permission. 4 | // 5 | // Original Author: Randy Gaul 6 | // Date: 8/1/2012 7 | // Contact: r.gaul@digipen.edu 8 | //////////////////////////////////////////////////// 9 | 10 | #pragma once 11 | 12 | #include "GlobalDefines.h" 13 | 14 | RETURN_TYPE TestLevel2Load( void ); 15 | RETURN_TYPE TestLevel2Init( void ); 16 | RETURN_TYPE TestLevel2Update( void ); 17 | RETURN_TYPE TestLevel2Draw( void ); 18 | RETURN_TYPE TestLevel2Free( void ); 19 | RETURN_TYPE TestLevel2Unload( void ); 20 | -------------------------------------------------------------------------------- /AsciiEngine/Tile.c: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////// 2 | // Copyright (c) 2012 ICRL 3 | // See the file LICENSE.txt for copying permission. 4 | // 5 | // Original Author: Randy Gaul 6 | // Date: 7/17/2012 7 | // Contact: r.gaul@digipen.edu 8 | //////////////////////////////////////////////////// 9 | 10 | #include "ImageTable.h" 11 | #include "Component.h" 12 | #include "EntityCreatorTable.h" // Map entity creators to string IDs 13 | #include "EntityManager.h" // SendEntityMessage 14 | 15 | static const char *CLASS_NAME = NULL; 16 | 17 | void TileConstruct( ENTITY *self, float *x, float *y ); 18 | void TileInit ( const char *className ); 19 | void TileDraw ( ENTITY *self ); 20 | void TileDestroy ( ENTITY *self ); 21 | ENTITY *TileCreate( int x, int y ); 22 | 23 | // 24 | // TileEM_PROC 25 | // Purpose; Processes entity messages. 26 | // 27 | void TileEM_PROC( ENTITY *self, EM msg, int var1, int var2 ) 28 | { 29 | switch(msg) 30 | { 31 | // GENERAL 32 | case EM_CREATE: 33 | TileConstruct( self, (float *)var1, (float *)var2 ); 34 | break; 35 | case EM_DESTROY: 36 | TileDestroy( self ); 37 | break; 38 | case EM_CLSINIT: 39 | TileInit( (const char *)var1 ); 40 | break; 41 | case EM_DRAW: 42 | TileDraw( self ); 43 | break; 44 | case EM_INACTIVE: 45 | EntityInactive( self ); 46 | break; 47 | 48 | // POSITION 49 | case EM_SETPOS: 50 | SendComEM( self->comps.POSC, EM_SETPOS, var1, var2 ); 51 | break; 52 | case EM_GETPOS: 53 | SendComEM( self->comps.POSC, EM_GETPOS, var1, var2 ); 54 | break; 55 | 56 | // COLLISION 57 | case EM_GETWH: 58 | SendComEM( self->comps.CC, EM_GETWH, var1, var2 ); 59 | break; 60 | case EM_SETWH: 61 | SendComEM( self->comps.CC, EM_SETWH, var1, var2 ); 62 | break; 63 | case EM_HITTEST: 64 | SendComEM( self->comps.CC, EM_HITTEST, var1, var2 ); 65 | break; 66 | case EM_IHITYOU: 67 | SendComEM( self->comps.CC, EM_IHITYOU, var1, var2 ); 68 | break; 69 | } 70 | } 71 | 72 | // Constructor for this entity type 73 | // Notes: Do not allocate space for the entity itself! This is handled 74 | // by the entity factory. This function is for allocation of 75 | // any other necessary memory. Perhaps a dynamically allocated 76 | // string, or other various memory allocations that are to be 77 | // pointed to by this entity. 78 | void TileConstruct( ENTITY *self, float *x, float *y ) 79 | { 80 | float width = 1.f, height = 1.f; 81 | AddSpriteComponent( self, FIND_DATA( P_IMAGE, IMAGE_TABLE, "Tile.AEArt" ), ENABLE_CAM ); 82 | AddPositionComponent( self, (int)x, (int)y ); 83 | AddSquareComponent( self, (int)&width, (int)&height ); 84 | self->properties |= DRAWME; 85 | self->CLASS_NAME = CLASS_NAME; 86 | self->zOrder = 9; 87 | } 88 | 89 | // Default initializer for this entity type 90 | // Notes: This function calls the Set function for this entity type. 91 | // The purpose of the set function is to set the values of the 92 | // self entity to those of the parameters. However the Init 93 | // function of an entity acts as "default parameters" for the 94 | // set function. Since parameter defaults are not apart of the C 95 | // standard this workaround becomes necessary. 96 | void TileInit ( const char *className ) 97 | { 98 | CLASS_NAME = (const char *)malloc( strlen( className ) + 1 ); 99 | strcpy_s( (char *)CLASS_NAME, strlen( className ) + 1, className ); 100 | } 101 | 102 | // Draw function for this entity type 103 | void TileDraw ( ENTITY *self ) 104 | { 105 | if(self->properties & DRAWME) 106 | SendComEM( self->comps.GC, EM_DRAW, 0, 0 ); 107 | } 108 | 109 | // Destructor for this entity type 110 | // Notes: Only free things in this function that were allocated in the 111 | // construtor! The entity factory actually handles deallocation 112 | // of the entity itself. 113 | void TileDestroy ( ENTITY *self ) 114 | { 115 | RemoveGraphicsComponent( self ); 116 | RemovePositionComponent( self ); 117 | } 118 | 119 | // Creator for this entity, assign a string ID and a creator function 120 | // For use with the EntityFactory -- allows simple dynamicly maintained 121 | // method for creation of entitys without necessity to maintain explicit 122 | // code 123 | ENTITY_CREATOR TILE_CREATOR = { 124 | "TILE", 125 | TileCreate 126 | }; 127 | 128 | // 129 | // TileCreate 130 | // Purpose: Creates a specific type of entity 131 | // 132 | ENTITY *TileCreate( int x, int y ) 133 | { 134 | ENTITY *entity = (ENTITY *)malloc( sizeof( ENTITY ) ); 135 | memset( entity, 0, sizeof( ENTITY ) ); 136 | TileInit( TILE_CREATOR.ID ); // Register class name 137 | entity->EM_PROC = TileEM_PROC; 138 | SendEntityMessage( entity, EM_CREATE, x, y ); 139 | CLASS_NAME = TILE_CREATOR.ID; 140 | return entity; 141 | } 142 | -------------------------------------------------------------------------------- /AsciiEngine/Tile.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////// 2 | // Copyright (c) 2012 ICRL 3 | // See the file LICENSE.txt for copying permission. 4 | // 5 | // Original Author: Randy Gaul 6 | // Date: 7/17/2012 7 | // Contact: r.gaul@digipen.edu 8 | //////////////////////////////////////////////////// 9 | 10 | #pragma once 11 | 12 | #include "EntityCreator.h" 13 | 14 | // Definition of the creator of this entity 15 | extern ENTITY_CREATOR TILE_CREATOR; 16 | -------------------------------------------------------------------------------- /AsciiEngine/TileMap.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////// 2 | // Copyright (c) 2012 ICRL 3 | // See the file LICENSE.txt for copying permission. 4 | // 5 | // Original Author: Randy Gaul 6 | // Date: 7/8/2012 7 | // Contact: r.gaul@digipen.edu 8 | //////////////////////////////////////////////////// 9 | 10 | #ifndef TILEMAPH 11 | #define TILEMAPH 12 | 13 | #include "GlobalDefines.h" 14 | #include "Shapes.h" 15 | #include "EntityFactory.h" 16 | 17 | #define COLLISION_LEFT 0x00000001 //0001 18 | #define COLLISION_RIGHT 0x00000002 //0010 19 | #define COLLISION_TOP 0x00000004 //0100 20 | #define COLLISION_BOTTOM 0x00000008 //1000 21 | 22 | #define TILE_WIDTH 1.f 23 | 24 | typedef int COLLISION_FLAG; 25 | typedef int CELL; 26 | 27 | typedef enum 28 | { 29 | NO_COLLISION, 30 | COLLISION 31 | } COLLISION_TYPE; 32 | 33 | typedef struct _MAPDATA 34 | { 35 | int width; // Width of the data array 36 | int height; // Height of the data array 37 | int *data; // Data array 38 | } MAPDATA; 39 | 40 | typedef struct 41 | { 42 | BOOL ACTIVE; // Boolean for map system active/inactive 43 | int MAP_WIDTH; // Width of the current map 44 | int MAP_HEIGHT; // Height of the current map 45 | MAPDATA *TILE_MAP; // Contains the current tile data array 46 | MAPDATA *COLLISION_MAP; // Contains the current collision data array 47 | } TILE_MAP_SYSTEM_DATA; 48 | 49 | extern TILE_MAP_SYSTEM_DATA TILE_MAP_SYSTEM; 50 | 51 | // 52 | // MapBoundCheck 53 | // Purpose: Checks to make sure a coordinate is within the boundaries of the 54 | // current map size. 55 | // 56 | BOOL MapBoundCheck( int x, int y ); 57 | 58 | // 59 | // SwapMap 60 | // Purpose: Swaps the current active map for another. 61 | // 62 | RETURN_TYPE SwapMap( const char *fileName ); 63 | 64 | // 65 | // CellAt 66 | // Purpose: Returns a pointer to the cell at a location 67 | // 68 | CELL *CellAt( MAPDATA *map, int x, int y ); 69 | 70 | // 71 | // ImportMAPDATA 72 | // Purpose: Imports a map from a data file 73 | // 74 | RETURN_TYPE ImportMAPDATA( const char *FileName ); 75 | 76 | // 77 | // CheckHotspotCollision 78 | // Purpose: Checks hotspots around a rectangle for collision within 79 | // a the current collision array. 80 | // 81 | COLLISION_FLAG CheckHotspotCollision( const AE_RECT rect ); 82 | BOOL HotSpotCollisionCheck( VECTOR2D hotspot ); 83 | 84 | // 85 | // FreeMap 86 | // Purpose: Frees the current map! 87 | // 88 | void FreeMap( void ); 89 | 90 | // 91 | // DrawMap 92 | // Purpose: Draws a map onto the DOUBLE_BUFFER 93 | // 94 | RETURN_TYPE DrawMap( void ); 95 | 96 | // 97 | // MapSystemInit 98 | // Purpose: Initialize various aspects of the MapSystem for tile mapping 99 | // 100 | RETURN_TYPE MapSystemInit( const char *FileName ); 101 | 102 | // 103 | // DimensionClampX 104 | // Returns a clamped version of a coordinate 105 | // 106 | int DimensionClampX( int x ); 107 | 108 | // 109 | // DimensionClampy 110 | // Returns a clamped version of a coordinate 111 | // 112 | int DimensionClampY( int y ); 113 | 114 | RETURN_TYPE CreateTileEntitiesFromMap( void ); 115 | 116 | #endif TILEMAPH 117 | -------------------------------------------------------------------------------- /AsciiEngine/Vector2D.c: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////// 2 | // Copyright (c) 2012 ICRL 3 | // See the file LICENSE.txt for copying permission. 4 | // 5 | // Original Author: Randy Gaul 6 | // Date: 7/5/2012 7 | // Contact: r.gaul@digipen.edu 8 | //////////////////////////////////////////////////// 9 | 10 | #include "Vector2D.h" 11 | 12 | // 13 | // Vector2DZero 14 | // Purpose: Zeros the x_ and y_ data members of a vector 15 | // 16 | void Vector2DZero( VECTOR2D *vector ) 17 | { 18 | vector->x_ = 0; 19 | vector->y_ = 0; 20 | } 21 | 22 | // 23 | // Vector2DSet 24 | // Purpose: Sets the x_ and y_ data members of a vector to 25 | // provided values x and y 26 | // 27 | void Vector2DSet( VECTOR2D *vector, float x, float y ) 28 | { 29 | vector->x_ = x; 30 | vector->y_ = y; 31 | } 32 | 33 | // 34 | // Vector2DNeg 35 | // Purpose: Sets a vector to the opposite of another vector 36 | // 37 | void Vector2DNeg( VECTOR2D *vector, VECTOR2D *opposite ) 38 | { 39 | vector->x_ = opposite->x_ * -1; 40 | vector->y_ = opposite->y_ * -1; 41 | } 42 | 43 | // 44 | // Vector2DAdd 45 | // Purpose: Sets a vector to the sum of two vectors 46 | // 47 | void Vector2DAdd( VECTOR2D *vector, VECTOR2D *addend1, VECTOR2D *addend2) 48 | { 49 | vector->x_ = addend1->x_ + addend2->x_; 50 | vector->y_ = addend1->y_ + addend2->y_; 51 | } 52 | 53 | // 54 | // Vector2DSub 55 | // Purpose: Sets a vector to the difference of two vectors 56 | // 57 | void Vector2DSub( VECTOR2D *vector, VECTOR2D *addend1, VECTOR2D *addend2) 58 | { 59 | vector->x_ = addend1->x_ - addend2->x_; 60 | vector->y_ = addend1->y_ - addend2->y_; 61 | } 62 | 63 | // 64 | // Vector2DNormalize 65 | // Purpose: Sets a vector to the unit vector of another vector 66 | // Notes : This function should be used mainly to initialize values; since 67 | // it uses the sqrt function, calling it each game cycle will be 68 | // rather costly. 69 | // 70 | void Vector2DNormalize( VECTOR2D *vector, VECTOR2D *toNorm ) 71 | { 72 | VECTOR2D temp; 73 | float sqrtVal = (float)sqrt((toNorm->x_ * toNorm->x_) + (toNorm->y_ * toNorm->y_)); 74 | temp.x_ = toNorm->x_ / sqrtVal; 75 | temp.y_ = toNorm->y_ / sqrtVal; 76 | 77 | vector->x_ = temp.x_; 78 | vector->y_ = temp.y_; 79 | } 80 | 81 | // 82 | // Vector2DScale 83 | // Purpose: Scales vector toScale by value c and stores the result in vector 84 | // 85 | void Vector2DScale( VECTOR2D *vector, VECTOR2D *toScale, float c ) 86 | { 87 | vector->x_ = toScale->x_ * c; 88 | vector->y_ = toScale->y_ * c; 89 | } 90 | 91 | // 92 | // Vector2DLength 93 | // Purpose: Returns the absolute length of a vector 94 | // Notes : Due to the use of sqrt, this function can be much 95 | // more innefficient than Vector2DSquareLength. 96 | // 97 | float Vector2DLength( const VECTOR2D *vector ) 98 | { 99 | return sqrtf( (vector->x_ * vector->x_) + (vector->y_ * vector->y_) ); 100 | } 101 | 102 | // 103 | // Vector2DSquareLength 104 | // Purpose: Returns the length of a vector squared 105 | // Notes : This function should be used as an optimization to 106 | // the Vector2DLength function to avoid the use of the 107 | // sqrt function. 108 | // 109 | float Vector2DSquareLength( const VECTOR2D *vector ) 110 | { 111 | return (vector->x_ * vector->x_) + (vector->y_ * vector->y_); 112 | } 113 | 114 | // 115 | // Vector2DDistance 116 | // Purpose: Returns the absolute distance between two points 117 | // Notes : This function can be highly innefficient compared to 118 | // Vector2DSquareDistance due to the use of the sqrt 119 | // function. 120 | // 121 | float Vector2DDistance( const VECTOR2D *pointA, const VECTOR2D *pointB ) 122 | { 123 | return sqrtf( (pointA->x_ - pointB->x_) * (pointA->x_ - pointB->x_) + 124 | (pointA->y_ - pointB->y_) * (pointA->y_ - pointB->y_) ); 125 | } 126 | 127 | // 128 | // Vector2DSquareDistance 129 | // Purpose: Returns the absolute distance between two points squared 130 | // Notes : This function can be highly efficient compared to 131 | // Vector2DSquareDistance due to the use of the sqrt 132 | // function in its counterpart. 133 | // 134 | float Vector2DSquareDistance( const VECTOR2D *pointA, const VECTOR2D *pointB ) 135 | { 136 | return (pointA->x_ - pointB->x_) * (pointA->x_ - pointB->x_) + 137 | (pointA->y_ - pointB->y_) * (pointA->y_ - pointB->y_); 138 | } 139 | 140 | // 141 | // Vector2DDotProduct 142 | // Purpose: Returns the dot product of two vectors. 143 | // 144 | float Vector2DDotProduct( const VECTOR2D *vectorA, const VECTOR2D *vectorB ) 145 | { 146 | return vectorA->x_ * vectorB->x_ + vectorA->y_ * vectorB->y_; 147 | } 148 | 149 | // 150 | // Vector2DCrossProduct 151 | // Purpose: Returns the dot product of two vectors. 152 | // 153 | float Vector2DCrossProduct( const VECTOR2D *vectorA, const VECTOR2D *vectorB ) 154 | { 155 | return vectorA->x_ * vectorB->y_ - vectorA->y_ * vectorB->x_; 156 | } 157 | 158 | // 159 | // Vector2DFromAngle 160 | // Purpose: Returns a normal vector in the direction of an angle (radians) 161 | // 162 | void Vector2DFromAngle( VECTOR2D *vector, float angle) 163 | { 164 | vector->x_ = cosf(angle); 165 | vector->y_ = sinf(angle); 166 | } 167 | 168 | // 169 | // VelocityClamp 170 | // Purpose: Clamps a velocity vector within a maximum speed 171 | // 172 | void SpeedClamp( float *vel, float maxSpeed ) 173 | { 174 | if(*vel > maxSpeed) 175 | { 176 | *vel = maxSpeed; 177 | } 178 | else if(*vel < -maxSpeed) 179 | { 180 | *vel = -maxSpeed; 181 | } 182 | } 183 | -------------------------------------------------------------------------------- /AsciiEngine/Vector2D.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////// 2 | // Copyright (c) 2012 ICRL 3 | // See the file LICENSE.txt for copying permission. 4 | // 5 | // Original Author: Randy Gaul 6 | // Date: 7/5/2012 7 | // Contact: r.gaul@digipen.edu 8 | //////////////////////////////////////////////////// 9 | 10 | #ifndef VECTOR2DH 11 | #define VECTOR2DH 12 | 13 | #include "math.h" 14 | 15 | typedef struct _VECTOR2D 16 | { 17 | float x_, y_; 18 | } VECTOR2D; 19 | 20 | typedef struct _INT_VECTOR2D 21 | { 22 | int x_, y_; 23 | } INT_VECTOR2D; 24 | 25 | // 26 | // Vector2DZero 27 | // Purpose: Zeros the x_ and y_ data members of a vector 28 | // 29 | void Vector2DZero( VECTOR2D *vector ); 30 | 31 | // 32 | // Vector2DSet 33 | // Purpose: Sets the x_ and y_ data members of a vector to 34 | // provided values x and y 35 | // 36 | void Vector2DSet( VECTOR2D *vector, float x, float y ); 37 | 38 | // 39 | // Vector2DNeg 40 | // Purpose: Sets a vector to the opposite of another vector 41 | // 42 | void Vector2DNeg( VECTOR2D *vector, VECTOR2D *opposite ); 43 | 44 | // 45 | // Vector2DAdd 46 | // Purpose: Sets a vector to the sum of two vectors 47 | // 48 | void Vector2DAdd( VECTOR2D *vector, VECTOR2D *addend1, VECTOR2D *addend2); 49 | 50 | // 51 | // Vector2DSub 52 | // Purpose: Sets a vector to the difference of two vectors 53 | // 54 | void Vector2DSub( VECTOR2D *vector, VECTOR2D *addend1, VECTOR2D *addend2); 55 | 56 | // 57 | // Vector2DNormalize 58 | // Purpose: Sets a vector to the unit vector of another vector 59 | // Notes : This function should be used mainly to initialize values; since 60 | // it uses the sqrt function, calling it each game cycle will be 61 | // rather costly. 62 | // 63 | void Vector2DNormalize( VECTOR2D *vector, VECTOR2D *toNorm ); 64 | 65 | // 66 | // Vector2DScale 67 | // Purpose: Scales vector toScale by value c and stores the result in vector 68 | // 69 | void Vector2DScale( VECTOR2D *vector, VECTOR2D *toScale, float c ); 70 | 71 | // 72 | // Vector2DLength 73 | // Purpose: Returns the absolute length of a vector 74 | // Notes : Due to the use of sqrt, this function can be much 75 | // more innefficient than Vector2DSquareLength. 76 | // 77 | float Vector2DLength( const VECTOR2D *vector ); 78 | 79 | // 80 | // Vector2DSquareLength 81 | // Purpose: Returns the length of a vector squared 82 | // Notes : This function should be used as an optimization to 83 | // the Vector2DLength function to avoid the use of the 84 | // sqrt function. 85 | // 86 | float Vector2DSquareLength( const VECTOR2D *vector ); 87 | 88 | // 89 | // Vector2DDistance 90 | // Purpose: Returns the absolute distance between two points 91 | // Notes : This function can be highly innefficient compared to 92 | // Vector2DSquareDistance due to the use of the sqrt 93 | // function. 94 | // 95 | float Vector2DDistance( const VECTOR2D *pointA, const VECTOR2D *pointB ); 96 | 97 | // 98 | // Vector2DSquareDistance 99 | // Purpose: Returns the absolute distance between two points squared 100 | // Notes : This function can be highly efficient compared to 101 | // Vector2DSquareDistance due to the use of the sqrt 102 | // function in its counterpart. 103 | // 104 | float Vector2DSquareDistance( const VECTOR2D *pointA, const VECTOR2D *pointB ); 105 | 106 | // 107 | // Vector2DDotProduct 108 | // Purpose: Returns the dot product of two vectors. 109 | // 110 | float Vector2DDotProduct( const VECTOR2D *vectorA, const VECTOR2D *vectorB ); 111 | 112 | // 113 | // Vector2DCrossProduct 114 | // Purpose: Returns the dot product of two vectors. 115 | // 116 | float Vector2DCrossProduct( const VECTOR2D *vectorA, const VECTOR2D *vectorB ); 117 | 118 | // 119 | // Vector2DFromAngle 120 | // Purpose: Returns a normal vector in the direction of an angle (radians) 121 | // 122 | void Vector2DFromAngle( VECTOR2D *vector, float angle); 123 | 124 | // 125 | // SpeedClamp 126 | // Purpose: Clamps a velocity vector within a maximum speed 127 | // 128 | void SpeedClamp( float *vel, float maxSpeed ); 129 | 130 | #endif VECTOR2DH -------------------------------------------------------------------------------- /CHANGELOG.txt: -------------------------------------------------------------------------------- 1 | 7/??/2012 -- INITIAL COMMIT 2 | 7/03/2012 -- Created ObjectFactory object management system. 3 | 7/10/2012 -- Version 1.01 4 | -Created AsciiEngine Image Editor v1.00 (AEIEditor) 5 | -Bugfix in ObjectFactory when deleting objects 6 | -Minor updates to graphics and tile mapping 7 | -Added support for loading .AEArt files (art files created with AEIEditor) 8 | -Added support for loading all .AEArt files within an entire directory 9 | -Other minor updates 10 | 8/27/2012 -- Version 1.02 11 | -Swapped all hash tables for the generic hash table. 12 | -Swapped all linked lists for the generic linked list. 13 | -Recreated factory and object management, renamed to entity and entity management. 14 | -Created component based entity system for ease of entity design and creation. 15 | -Physics component 16 | -Euler integration 17 | -New collision scheme working from the Vector lib and Math lib 18 | -Requires position component 19 | -Graphics component 20 | -Sprite component 21 | -Single 2D image 22 | -Requires position component 23 | -Animation component 24 | -Single 2D animation 25 | -Requires position component 26 | -Cloud component 27 | -Collection of sprites and/or animations. 28 | -Each sprite or animation in the cloud has a coordinate and corresponding 29 | string name. 30 | -Each sprite or animation is a Zorder for ordered drawing. 31 | -All coordinate positions are relative to a single point: this point is 32 | retrieved from the position component. 33 | -Position component 34 | -X and Y floats stored in Vector format 35 | -Player component 36 | -Allows user input to affect the state of other components. 37 | -Requires position and physics component 38 | -Inventory component 39 | -Allows object to store arrays of Item entities within it 40 | -Hitpoints component 41 | -Integer HP represenation 42 | -Utility functions for reducing HP 43 | -Ability to send destroy message to owning entity on HP zero 44 | -Functionality to autmotically create in-game text reprentation of HP changes 45 | -Collision component 46 | -Handles detection of collisions, and resolutions of collisions with other entities. 47 | -Brain component 48 | -Creates actions to insert into the action list component, depending on context 49 | the owning entity is currently within. 50 | -Requires action list component 51 | -Actionlist Component 52 | -Simple and elegant all-purpose queue for storing actions for the entity to perform. 53 | -Began work on example map editor. 54 | -Created simple serialization/deserialization functions for entities. 55 | -Recreated the demo. 56 | -Craeted button class for easy UI creation. -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012 ICRL 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. -------------------------------------------------------------------------------- /README.txt: -------------------------------------------------------------------------------- 1 | Please see: http://cecilsunkure.blogspot.com/2012/07/windows-console-game-ascii-engine.html for additional documentation. 2 | 3 | Please read the README in the Release folder to see the demonstration. --------------------------------------------------------------------------------