GDC-WM / 2DGame2021

Has a very nice backend structure but no real gameplay (yet?)
MIT License
1 stars 1 forks source link

Map: Draw tile spritesheet onto window #15

Open BlastWind opened 3 years ago

BlastWind commented 3 years ago

Produce:

loadMap(filePath) 
draw(window) // note, we should draw map only once, might need a boolean flag  

Links to #16

BlastWind commented 3 years ago

1) Gonna self assign myself to this one. Harder than I think. Here's an example problem we need to consider: 2) On map data specification If the background is completely tile based, here's one way to represent map data:
demoLevel1Data.txt:

// 2D int array where each int maps to a specific asset
0 0 0 0 
0 1 2 0 
0 1 2 0 
0 1 1 0 

In the draw(window) function specified in the issue description, we specify which asset does each int map to:

switch(integerValue){
 case 0: 
  // dealing with dungeon wall 
  // so draw the damn dungeon wall 
 case 1: 
  // dealing with torches 
 case 2: 
 // dealing with statues
 ...
}

However, what if one asset spans longer than two tiles? What if we want to specify which way the asset is facing in the data? Then, a 2d int array might not suffice. However, we can probably still model the data with a 2d array, just not with a single integer.

Aside: We want to use the flyweight design pattern so that, for example, when we are rendering 100 dungeon basic floor tiles, they are pointing to (and not storing) the same asset in the spritesheet.

aaronamk commented 3 years ago

Very good article you have there, I like the flyweight idea.

BlastWind commented 2 years ago

Splitting task into smaller tasks: