-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
episode 9 - the level class - part 3
- Loading branch information
mark
committed
Sep 28, 2015
1 parent
3d225dd
commit c2ce873
Showing
7 changed files
with
254 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
===================================================== | ||
Remaking Cavestory in C++ | ||
Episode 9 - The level class - Part 3 | ||
By: Limeoats | ||
Website: www.limeoats.com | ||
Twitter: @Limeoats | ||
Github: https://github.com/Limeoats/cavestory-development | ||
Reddit: http://www.reddit.com/r/Limeoats | ||
===================================================== | ||
|
||
|
||
===================================================== | ||
Problem | ||
===================================================== | ||
-Now that we have our map built, we need our program to read and understand it | ||
-Before that, WE need to understand it | ||
|
||
|
||
|
||
===================================================== | ||
Details | ||
===================================================== | ||
-We'll parse XML with TinyXML library | ||
|
||
|
||
|
||
===================================================== | ||
Solution | ||
===================================================== | ||
-Add SDL_DestroyRenderer (thanks Symbiotic) | ||
-Create Tile class | ||
-Create Tileset struct (in level.h) | ||
-Add new variables to Level class | ||
-Include TinyXML in level.cpp and implement LoadMap | ||
|
||
|
||
|
||
===================================================== | ||
Next time | ||
===================================================== | ||
-Gravity! | ||
-Collision! | ||
-Jumping! | ||
-Player spawn point | ||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#ifndef TILE_H | ||
#define TILE_H | ||
|
||
#include "globals.h"; | ||
|
||
struct SDL_Texture; | ||
class Graphics; | ||
|
||
class Tile { | ||
public: | ||
Tile(); | ||
Tile(SDL_Texture* tileset, Vector2 size, Vector2 tilesetPosition, Vector2 position); | ||
void update(int elapsedTime); | ||
void draw(Graphics &graphics); | ||
private: | ||
SDL_Texture* _tileset; | ||
Vector2 _size; | ||
Vector2 _tilesetPosition; | ||
Vector2 _position; | ||
}; | ||
|
||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#include "tile.h" | ||
#include "graphics.h" | ||
|
||
#include <SDL2/SDL.h> | ||
|
||
Tile::Tile() {} | ||
|
||
Tile::Tile(SDL_Texture* tileset, Vector2 size, Vector2 tilesetPosition, Vector2 position) : | ||
_tileset(tileset), | ||
_size(size), | ||
_tilesetPosition(tilesetPosition), | ||
_position(Vector2(position.x * globals::SPRITE_SCALE, position.y * globals::SPRITE_SCALE)) | ||
{} | ||
|
||
void Tile::update(int elapsedTime) {} | ||
|
||
void Tile::draw(Graphics &graphics) { | ||
SDL_Rect destRect = { this->_position.x, this->_position.y, | ||
this->_size.x * globals::SPRITE_SCALE, this->_size.y * globals::SPRITE_SCALE }; | ||
SDL_Rect sourceRect = { this->_tilesetPosition.x, this->_tilesetPosition.y, this->_size.x, this->_size.y }; | ||
|
||
graphics.blitSurface(this->_tileset, &sourceRect, &destRect); | ||
} |