Game loop, map converter & loading, & sprint 1 retrospective – MOSGD (Lenxion: The Cursed Castle)

Game loop, map converter & loading, & sprint 1 retrospective – MOSGD (Lenxion: The Cursed Castle)


[Music] Saluton al ĉiuj! how’s everyone doing today I have three things I’m planning on doing and then after I get done with the game dev I’m gonna play some more deaths training but I didn’t do any game type yesterday so I need to do some today actually there are four things we need to have a retrospective I’m just putting that on my list of things to do um that actually kind of sets the most fun but I should leave it for the end when I’m done with the other things I’m going to do today but today I’m going to talk a little bit about the high-level view of how I structure a game saw be in GIMP and illustrating things as I talk and then we’ll get into some coding I need to make the map and export it and then we’ll work on loading it in the game and the things related to that so [Music] okay so let’s talk a bit about how a game is structured so if you’re at all familiar with making software or making web pages those are different ways so let’s say if we just had a piece of software where you had buttons and it did some stuff it would just sit here and wait and when you click on a button it would actually call a function to do something so this is more event-driven like there’s unless there’s something going on at the same time like let’s say this is a random video player so a video is playing right here and that does its thing while it’s running but then it just kind of waits for you to press a button to do any changes to make any any updates that’s not what game development is like so when you have your game the game is going to continue running whether or not usually you’re doing anything even was a turn-based game stuff will still be animating there could be other little things happening but there’s the game is going to continue running so if you think of like Mario and you have like enemies that’ll go back and forth while you’re walking rings will kind of spin around things will keep happening so the world continues it’s not just waiting for you to do something so this means we need a game loop also with programming if you’ve ever written a simple program before when you start running the program it runs through the code and once it hits the end if you don’t have any loops in there it will exit immediately so this is good for scripts if you need it to do a task really fast and then exit but that’s not what we want for a game we don’t want it to exit until the user actually tells us to exit so with the game loop the basic idea is that we’re going to initialize the game so that means just setting everything up whether that’s like initializing variables if you need it or setting up different managers or calling the library setup functions so we have s/m m/l ready to go and then we enter into a game loop so in the game loop we will basically always loop and it’ll have some sort of delay based on the frames per second but I like to think of it it as check with for input from the player respond to that do updates so that can be like hey Goomba move to the left or something like the players gonna have updates the enemies are gonna have updates items might have updates if you have a game timer that might update and so on and then finally you draw so you draw everything to the screen the input maybe it’s exit or something like that and so at that point you would have a clean up so input this can be keyboard input mouse input just kind of detecting if the player is doing anything in the world and for example let’s say they’ve hit the right mouse or the right arrow key and let’s say they move with a velocity we’re not going to do this for this game but let’s just say their velocity is now 10 so that doesn’t necessarily move them right away we’re just saying their velocity is 10 in that direction or whatever then in the update phase we would actually move them this weird right sideways we would actually move them by that velocity so the input phase updated the velocity the update sorry input phase that is I want to said input phase updated the velocity then the update phase changes the game state based on that so update that will be and really these cut two can kind of go together it it depends on what the library is like since with s FML I don’t have to have like a separate keyboard object doing a bunch of pinging and then sending data to the other thing this will actually be more together because I can literally make a player update function and inside of that check for the keyboard data whereas if I were using a different library I might have to do that detecting keyboard presses ahead of time and pass that to the player to update things so with will have stuff like the player will update and that could be their movement it could also be like let’s say the player got poisoned and then there’s a timer running down on how long they’re poisoned if that would be handled and update maybe they you know well we’ll see things I’m trying to think of what will be in the game for the most part we’ll just handle moving around with the player and then also checking input to see if they’re attacking so those will be the main things will also have enemy updates so each enemy will also update and usually that will be like where does that enemy want to move based on its behavior does it chase the player does it chase the treasure does it randomly move does it follow us that path so that’s where its behavior will be decided and that will be updated and we could have a map update depending on what we need I know in adventure there are those moving walls I’m not really gonna do that I don’t think I would just make those enemies actually I wouldn’t make those part of the map but if we need a map to update we can do that and anything else so another thing would be at this point when we’re updating things we’d also see check the collision so is the player hitting an enemy is the player hitting the treasure so I’m just putting item and also before we move the player and before the enemy moves is there going to be a collision between a player and something solid in the map if no then you can let the player move in the direction they were intending to move if yes then you can only move as far as you can until you hit that wall and don’t let them continue going past that what else do I have written here we might have projectiles so with a projectile we’ll have like a direction it’s moving and a speed it moves at so every time that’s not in the collision well we’ll check print check knowledge its enemy but we’ll have projectile update so as it’s moving it will say ok we’re at this position we have this speed we’re gonna update it by this amount are you hitting the map I don’t know if it hits them out maybe it just goes away are you hitting an enemy kill the enemy so we have all of these things to check on yeah and then drawing that will just be call the players draw function call the draw function for all of the enemies call the maps draw function which will handle drawing the tiles draw the projectiles call the projectiles draw function and all of that also in the update I just want to mention that if we have like an enemy if enemy player and projectile and those are the main things sometimes to make a decision on what is doing in that update it needs to have access to another entity so on its own by itself enemy only knows about its own that own instance is X Y width height whatever if it’s going to chase the player we’re going to need to provide that enemy that the player information to the enemy so for example maybe the update maybe it’ll have a reference to the player so you can access the player position to move towards that direction or maybe there will be something like a set goal function where we pass in the player or we pass in the treasure or something like that let me also put we have items treasure items so sometimes you’ll just have to pass that data over now these are these three are all of these are going to inherit from each other not from each other sorry we’re gonna have a base object and everything will inherit from these so we’ll have items tiles projectiles enemies players this is not quite the family tree I’m going to use let me I can draw this a little bit nicer we’ll have the base object this is at least how I usually do it the base object will have X&Y width and height and maybe that’s all the information needed at that very basic level so the item might inherit just straight from the base object if it isn’t an item that moves it just has an image the image yeah it has a picture and it has a place where it’s sitting and sits there then we might have a character class so usually in a character I put in a animation functionality so I’ll go over that when we get to it collision well this is just gonna be a bounding box when I put collision info we’ll see collision info movement mmm health may be horsing this one it’ll be like everyone has one health point and if it gets hit that you die and then from there we’d have player who specifically uses like keyboard input and we’d have enemy who uses their AI to make decisions on how to move and then also item and tile can really kind of be the same thing where it has a collision rectangle it has an image X Y width height and all of that so this is all to say that because we have this parent object that’s come in to everything if the enemy has a set goal function we can just pass in a base object it doesn’t mean to know if it’s a player specifically or an item it just needs to know it’s a base object that has X Y width and height and so when the enemy has a new goal X and whites go to it just needs to know it’s a base object likewise with collision at least for our we’re gonna have two types of collision from what I’m currently thinking but let’s say our bounding box collision that can just take in two base objects and then check their X Y width and height against each other to see if they’re colliding and then that way we don’t have to write new collision functions for each type of item let’s see what else do I have written down okay let’s cut that so in the wider game itself this game we mostly elbe loops in the entire thing but this will be mostly the game state here but the main program in Maine this one actually has the game when it calls game state update game state draw for us but for the program itself it’ll have initializing which is mostly going to be SF ml and the managers get them ready to go read the config and whatever um updates um it’ll take care of the state so it’ll set up the next state and called the state update and draw through the state manager it’ll also be responsible for changing the state so if a state’s go to state parameter is set to something besides an empty string that’ll say oh now we’re going to change this state and make it a different state so we call the state in it and then they it becomes the thing that gets called in the update and draw and you know maybe we need to communicate some information between the different states so the state itself if you think of like just writing a really simple program and you have everything in Maine like in all of the game logic in Maine we’re kind of doing that but putting that stuff into the state to make it cleaner so you know state manager to handle changing between states and if we need data to be passed between states maybe they’ll be like a messaging not like a formal messaging cue type of thing just kind of like a a store like a global store it’s a static class or something you can store some data by key and data so for instance like in previous games I’ve did maybe you’re at the menu like the the level select screen and you click on I want to play level 5 so maybe I’ll put that the global store changed to the gamestate it will check what level to load based on that global data and then load it up and then we don’t have to do anything special for each level it just knows which one to load okay so hopefully that wasn’t too confusing hopefully you at least got the idea of the game loop and then just everything that has to be done in those and then we’ll be doing the coding and you’ll kind of see that from the in depth point of view but I just wanted to state that in our game state we have updates that happen we have input updates and drawing and drying is easy the updates are going to be the big thing of handling movement collision and anything else that happens to be needed so let’s build our map export it take a look at that map data and then get started on loading it into our game [Music] okay while I’m thinking about it um so there are different ways we can handle collision with these maps as well let me also just open a little thing to draw in I usually like to do it where I have a specified like collision tile to specify you can’t walk there so I’ll do that really quick we’ll just hmm I usually like to make a top right so I can find it easy we’ll just I guess make this the collision tile right here not on that the grid okay so to do that we will set this here and now we have this so I’m going to make a collision layer and really it doesn’t necessarily have to be this X I just think it’s more helpful for us humans to see it this could literally be like if there’s anything on this layer don’t allow collision with it but it’ll be more human readable if it’s like this so I usually like doing this sort of thing because that means I could make like see could walk through walls and stuff the other way we could do it is if we just say hey any set of bricks are solid don’t move through bricks so we could do it either way and then just have like a special like pass through brick it’s like a secret you know that we show so for instance maybe we wanted to specifically allow certain brick types we’ll just make it up here this is the secret pass through brick we’ll make it a tiny bit lighter there and we’ll save this so this is the secret pass through brick so if we were let’s get rid of that making this so you could go through this wall this one’s a little bit lighter and then I guess we’d have like a secret pass through ceiling also then you could see that in the game or I can make it like very solid colored and it’s the same color and just say this is the firt the pass-through version this is the solid version and then you could go through there to find a secret but I tend to like doing it with the collision layer like that and just saying you can’t move through any of these yeh or you can’t move into these candlesticks the only thing that’s annoying is I would need like maybe a half collision for these which we can kind of draw in or we can just say they can’t step in any of this Squarespace but that doesn’t really make a lot of sense so let’s do that really quick I might also make this list opaque where’s this is I think I put that on the ceiling layer we’ll put this on a collision layer and we’ll make that like half transparency and we’ll make a version that maybe specifies that you can’t go this way I don’t want that entire thing I just want to do something like that so do a few of these for each direction and we’ll save that so then in the game code I could say Oh which type of collision is this this is like a diagonal type of collision yeah and can I just handle it that way so you just got a color in all these collision areas and then we could also just hide it on this layer if we wanted to see what it looked like without it I’m gonna put these in here except we did that that doesn’t matter and down here well actually not gonna move in there at all and over here so then there’s our our collision information and this one’s not gonna have like a secret pass through I suppose if I put like a wall right here I could make it so you could pass through because it’s like like a wall and you see the ceiling and there’s a separator but maybe there’s a door in between but whatever we’ll just do this this is our test map I’m going to delete that because that’s not gonna be part of the map I guess I could also make this just different types of properties like if I wanted this to like carpet to slow you down or something but we’re not going to do that then we need to export and I will put this somewhere in there later but let’s we need a Content folder it’s not what I meant to do we’re in here in here content maps so this is just let’s just say this is room dot and they can the export to a Lua file a JSON file a tiled Maps a tiled map file CSV right now this game doesn’t have any new AI in it so let’s see what the CSV file looks like and we might have to write something to parse it ourselves which we will we will do it will be fine Maps whoa what oh if it put all of the different layers in their own CSV file so this is yeah you can I mean you can kind of see what’s going on there you can there’s the collision and then there the ceiling tiles the some of the decor the ground is all over there’s the carpet there’s some shadows there the walls so this is a lot like how I made maps when I first began programming and I literally would just make a big grid like that that is not my favorite we are going to possibly export that to something else I have also written a map converter I don’t know if it’s in my bit bucket we’ll see because I don’t really like the tiled map style okay let me check my get lab maybe it’s in I get laughs I might have to write a new converter if I don’t like it or you can just try to parse it will see that is not you get lab this is good I don’t think I put it in here yeah I used to just have a converter that would convert from like the Lua output to something I liked more let’s just look at all of the Styles let’s look at Lua let’s look at JSON it’s okay tiled so if we had a tiled map that gives us some XML with all of the layers in a grid like that if we look at the Lua that’s also going to give us that but it’ll have this data ahead of it JSON oh that’s nice whatever so I guess I took like the Lua scripts and made them into the a format that I liked better um now I could just write a parser to parse this that’s kind of less desirable because I don’t want to have to deal with the curly brackets I’m just trying to think of what the best way to do this is because in C++ like it’s a lot easier to parse and just like skip over white space here and there and kind of deal with labels then it is to do it this way so I could write another converter but it will also take part of the day and then also I don’t really like having my data in just a grid so when I first started programming games I you know make my maps like this and then say like oh here’s the ground here’s some obstacle and so on and I would make my Maps like that but now I actually prefer to make my Maps more like you know here’s tile I mean if I’m gonna make it easy to parse tile begin exposition is that blah Y position is that blah image code is ten which the image code here is like one hundred forty five or zero for nothing 163 for a floor or carpet or something and then maybe I could put that collision is true or something like that and then tile end and then that would be really easy to parse in C++ you just kind of loop through that and then oh we could also have like a Z coordinate instead of having these all these separate grids here we could just have one big list of tiles and then have a Z coordinate for which which position things are going to be in because we need to have the ceiling above the walls otherwise that’s not gonna look right you’re gonna have to need the shadows above the floor otherwise that’s not gonna look right and all that so or I could just go write my own map editor but that would be a big waste of time thinking thinking you might just pull out the lua and make it ourself or if we try to parse the json file I could do PHP I guess or something the thing is like I haven’t used Lua in a while so I just be like fumbling around with the syntax and stuff trying to get it right [Music] does Python have a JSON reader maybe I can do that Python JSON I’m pretty sure it does maybe we’ll write a converter in Python that might be what I do and then we’ll have to write okay well I really want to write a converter and I’ll put it on gitlab and I’m going to record it but I’m gonna just fast-forward through all of it because I don’t really want to go into the specifics I’m basically just going to read the data and then I’m going to output the data again but in a format that I like so it’s gonna be a lot of code that’s kind of ugly and I the logic itself is just read the data and then output it again but just in a different way so I don’t feel like really explaining all that and then we’ll go in and load the map files so I guess that’s what I’ll do next [Music] [Music] [Music] [Music] [Music] [Music] [Music] okay I have converted the map file so there is a load which is easy to use this convert and then there is a output data so if you wanted to modify this for your own use it should be relatively easy to do so I’m just going to commit this so basically we go from this format which would be kind of a pain to parse in C++ all of the data is here and it has information here’s height and then here’s the rest of the map data it loads that into just an object like a dictionary in Python and a list for the tiles and then it outputs it in this format so this will be a lot easier to parse in C++ just because of the white space and it’s also in the format where each tile has its own set of data the Z coordinate is basically just corresponds to which layer it was on but I also put in the layer floors like the the text information about it I did have to go back and change these to not have spaces because that would also kind of just mess up my parsing but that should be good then we can load in that map data yay and if you want to use that that is now also up in my git lab under personal projects there it is the tiled map converter yay [Music] it is a short intermission time I would like some sex have you had a glass of water recently it is important to stay hydrated so I hope you’ve been drinking water don’t be like Sam Porter Bridges only drinking monster drink water have a nice cup of water right now hello now we’re gonna do maps so first off we have a game object this is not all the stuff that’ll be in it this stuff will belong in a character but I do need to make a child version of the base object that has the tile image information so let’s start by changing this up a little bit we’ll go ahead and make a character object and we’ll make that tile object so I’m just gonna move some stuff over to kind of get everything ready all game objects are going to have a texture associated with them and I’m making this a reference because we don’t want to make copies of the texture we don’t want to have every tiles going to use the same tile set we don’t want to copy that tile set a billion times so it’s just referencing the textures the texture will be handled in a texture manager [Music] I’m also creating a texture coordinates value which will be pointing to where on a sprite sheet or tile map the image will be used so you know we’d have to say Oh at X location zero Y location 192 we’re taking this with 3232 and using just this section for a specific wall tile I might have to turn this into a pointer for now again and also again follow up on pointer stuff Nikki into a newer pointer just because I’m not sure if like the reference has to be set you can’t really like change the reference after the fact but with a pointer you can set it to null actually I might not even need this to store the texture because in SF ml it stores a texture object which is the image and then the sprite is a smaller thing linked separate but references the textures so I don’t think I need to do that I think I just need to reference that and then use this dot set texture so that makes it a little easier on me [Music] okay I don’t know if the tile will really really need more information than what the game object already offers but here we have a tile we can expand on that as needed I’m going to in the game state get rid of these objects here because we don’t really we’re not gonna be testing with those so we’re just gonna look at the map stuff okay now we need to make a map that stores all of the tiles so what should we put that under code boxes glitching out again gotta close gotta reopen [Music] okay so some of the things we will need for the map just some basic information like the map width will load in map height I don’t know if we really mean the tile width and height because yeah I don’t think we need that and then we’re going to need that list of tiles now they have different Z coordinates and I want them to be drawn in a certain order but I’m trying to think here they’re in an order where the zeros will be drawn first anyway so I’m wondering whether it’s fun to just put them all in the same list except the ceiling tile if we happen to have any art that will go above the player such as if you let’s say that wall is I don’t know then let’s say you just had somewhere where you were walking under the ceiling and had to get through and it’s fine you can go through here we would want that to show over the player sprite so that’s usually you’ll have like the stuff that renders below the stuff that renders above or at least that’s what I usually do so let me just use the vector library and we will have a vector of tiles for under and over okay and we will need a function to load the map so let’s really that doesn’t I’m trying to think you know say load map include some string and and other programs I’ve done I’ve written something where it knows the path automatically if we’re to find maps trying to think that could just be in config file or something but I don’t usually like passing the whole path it doesn’t matter that much right now we’re just doing this so let’s go ahead and create void map load map and we’re going to also need a draw if we want to draw the stuff to the screen so void draw we need that tiles already have a draw but we need the render window to pass around and now we can load the map so we’ll just use our standard input/output stuff with C++ so we need the F stream library while we’re doing this let’s go ahead and tell this to load but it will be loading a map so map map no nope lower case and then in initialize we will load a map and we’ll pass it content maps and room dot mu and we will go ahead and also call the draw function down here with the window and as we’re working on it we can keep trying to test it out here there so loading the map we need to create an input file stream pass in that file name and usually I’ll make like a buffer string listen to me from the STD library and what I do is while while in file can read into buffer so it’ll only it’ll stop at the whitespace and read one thing at a time and then based on that we can figure out how to parse it so just while we’re testing I’m gonna put in iostream so we could show you what it’s reading in so see out what’s in the buffer so let’s see if we if we run this now okay game state is this the snaps holder so that’s there but we can see here it’s outputting all of the data that it was loading so here’s a bunch of tile data so let’s close that we know it’s reading an information so I tend to use code blocks does things sometimes and I should just be using space max but I don’t know I would have to take some time to get things set up how I want it um okay loading in the map open the map open that oh the annoying thing is also there are code blocks doesn’t automatically save file I put in here add file maps we’re adding this map okay now save the project okay so if buffer is map wit then we’re going to load that next the next thing from the input file as the map width so in file store the map with okay this is gonna be a little long so you could kind of try to make things a little bit more concise if buffer is map height then we’re going to store and to map height so at least parse those in there I don’t really care about tile width and height we don’t have to write it if statement for those it’ll just pass over those if it doesn’t meet any of these if criterias then we don’t really care about tile begin we could use that to kind of clear out information we’re storing so what’s to say if buffer is tile begin these need to be in double quotes also these are not enews if that then we’re starting to loading a new map we’re going to need to keep track of the X&Y I don’t really need the Z coordinate I guess we it wouldn’t hurt to store it but that I’d have to add it to the game object whatever let’s do this for now image code I don’t know if we need layer name did I put that in our tile I put tile type okay so we’re beginning this let’s just initialize everything’s like negative ones we really don’t have to do this step but sometimes it can be helpful just to make sure everything is starting from a clean slate it’s in case for some reason some data is missing which it shouldn’t be tile type name is empty string and if the buffer is tile end then we know we can save this data so at the end here and we’re going to save what was stored in those holder variables here otherwise we’re going to be checking for but for equaling capital X really all we do is X store whatever the next in file item is into X so if it’s why we’re storing it into Y if it’s doubled over there W just stirring it into W and so on so starting at I’ll save the tile to be a list of tiles so then we need to make a new tile hold that over here and we’re just gonna set up all that information so tile dot set up its x-coordinate its y-coordinate those are from the temporary variables it needs a name we don’t we can’t let’s give it a name I’m gonna make a counter as well and something else I’m going to have to put in here something does it convert an INT to a string or a string join it I don’t know well so we get their tile well yeah we need it here because we need a change tile to plus counter and we can’t just do this and C++ they don’t make it super easy so I wonder if I have this in my kit lab or in my github or we’re not my dad my mid-fuck yet but I had a bunch of C++ utilities that I always reuse also it didn’t cuckoo I could just grab it out of cuckoo utilities let’s just tell pull these utilities down while we’re at it so I’m gonna make a utilities folder okay so let’s step through these really quick just so I’m not like skipping a step and leaving everyone in the dark we have my lovely lager now that we can use I don’t have to rewrite this entire thing so it’s just it stores logs from the program in a HTML file so it builds out the HTML for me and it makes it easier to read I have a this is just my global pass things between states things it’s really just a dictionary that you store data in platform this just tries to get the operating system that it thinks you’re running and it also has something to open the URL like if you click on the social media icon it’ll try to open that up and then my string utility which could rename needs to be a little bit more short but excuse me I have something to get a nice looking time for the string I have some white space and then this is to get like an address for a pointer integer change the flow to a string and all that so we’ll just go ahead and add those from here I don’t think it has anything in there that needs SDL which is what cuoco is written in I think it’s all pretty much standalone but now I can also use this cool logger but we have string util as well so we’re setting the name from tile to you know tile number zero tile number one and so on I could do some type deaths or just rename these let’s just do I to s4 into string float to string Haiti string I don’t know call me that string to int that’ll make it a little bit shorter and also the these are all static functions as well once they minister just to make everything short I know I could do a type def I don’t feel like it I’m not a big fan of just giving things alternative names I guess so string into string and the counter and I also need to make sure I include that up here so include from the utilities totally the logger also and the string you toe so cool let’s open up the logger I know I’m like kind of going off on a tangent we’re not going to use the logger right now we’ll do that later because it requires a little bit of setup okay so name that tile that we also need to set its image and the code so if tile type name and let’s look at what these are again tile type name dot find the text collision is not equal to what was it string in POS no PO no position basically I should make a a utility function for that too let’s do that really quick cuz this is ugly static pool is couldn’t let’s use string contains contains comps haystack constant string needle like that so take a CPP file that down here and we just return whether the haystack dot find needle if it is not equal to string no position then it exists if it’s equal to string no position then it doesn’t exist so okay if tile type name dot couldn’t tape that dream contains this and collision then we’re going to call title type type type is equal to collision else if it includes floor shadow wall decor if it contains the text ceiling and so on [Music] okay and we don’t have setting up the tiles graphic yet because we haven’t loaded the tile set texture so we’ll do that here in a second I just want to add this to the list so if the type is ceiling then it’s gonna go in the over tiles list and if not it’ll do in the under tiles list so this dot push back our new tile otherwise over tiles all right so that does not build because the logger uses string utils good um great let’s replace stringing util with STR the place yes okay now if we want to have the texture I’d rather just go ahead and make our texture class and our texture manager so that we can have all of the textures stored in one area and then just pass references where they are needed so we’re gonna work on a new manager [Music] okay so for this text your manager I’ve made the HPV file and the CPP file this is because with managers they can be used all throughout the entire program I generally make all of their members static and to do that in C++ it requires you to do this and just put that variable over here for some reason I don’t remember the exact reason for that C++ is kind of weird but yeah so we’re gonna make all these static yay and the map is going to be utilizing the manager so include managers text your answer so it will access it to get textures you [Music] okay so within the text your manager will have an add text to your function we could also have something like clear textures so if we wanted to like clear out all textures when a game state ends and then add new ones when the game state different game state starts then we can clear out that memory so here when we want to add a text here we’re going to create an SF texture and we’re going to load if texture dies load from file a path is supposed to be passed in and this is an error if that doesn’t work it does work that’s just something we’ll return we could throw an exception but for now we’re just returned you know always stuff you can clean up and then in the in textures map we’re gonna set the item at that key that’s passed in to this texture that we’ve made now I’m trying to think this should just copy that right this is also one of the tricky parts of C++ if I made this a reference this would not work because this is a local variable it’s allocated on the stack and if this were a texture reference it would basically be referencing nothing once this left if it were a pointer I would have to make this dynamically allocate that memory for the texture I think that since this is these are just gonna be on the stack I don’t think this will cause any memory problems it’s gonna allocate memory on the stack and then copy it here I hope I hope the copy is works for textures in this to melt and then I think it should be good and then we can just get get stuff back and then I’m not sure how to clear the map is it just clear and then we want something like SF texture with a reference get texture and to get it you’ll have to pass in the key so down here and we can also add error checking to see like did you pass in the wrong keys is that key even exists in the map but for now we are going to pretend that I don’t make any errors ever and we are going to return that reference so it seeps us builds and we’re going to set things up okay since we’re working with a static class anyway I’m gonna go ahead and initialize the logger inside of main so we can just use it include utilities logger so the logger needs to be set up before we can use it even though it’s static so we have set that one up first it’s important so vlogger setup I could pass in a log level don’t you then I just turned off my monitor okay and at the end of the program I have clean up so once the program is done logger cleanup that closes the that quote that finishes writing when it needs to to the log file and then closes it so in our text to your manager if something goes wrong we can say logger error unable to load texture at path hey we can just copy that in and I like to put in the location so I’ll just usually add this sort of thing okay now I feel like maybe it’s getting a little confusing now but just bear with me for a minute in the game state I’m going to add our tile set so include the texture manager I’m going to need to move that tile set somewhere because I don’t think it’s currently in here we need a graphics folder I just kind of have the tile set sitting here as tile set test I like keeping things as clean as possible that I did not mean to cut copy we’ll just name this tile set okay and inside of our game state initialization we will need to call text your manager add texture tile set and we’ll give it that path so it’s gonna be content graphics tile sets tile set King okay so that should load that in we can also add logging in the texture manager anytime that happens since this isn’t something that happens every cycle it’s just you one-off thing I like to add logs in this case so just output that we’re adding texture with key to path and the location so we’ll pass this over here [Music] I wonder if the error messages and C++ have been changed in more recent versions because I feel like I’m not recognizing the error messages as much as I used to but maybe they just changed how errors or oh did I not make that static it needs to be static that’s why it’s saying that it needs a member or for a member function it needs to have the object initialized or instantiated and I don’t want to do that I just wanted to be static okay let’s run it it should load the texture and then really not do anything else close that window close that window now if we go into the project path we’ll have a log file and it looks like this so it added that texture it didn’t give an error and then the the program closed so I also will need to add log dot HTML don’t don’t save them source control okay okay so where were we we were loading in our Maps [Music] so I’m just going to store this in a reference here so we don’t have to keep calling text your manager get texture all of these tiles are going to have the same texture so tile dot set texture and then we need its coordinates so we’ll need to make an indirect and that’s going to correspond to where it is in the tile set so the coordinates in here and we find that out B based on the image this is another annoying thing I could have added this into the converter so tiled I should have added this into the converter I believe that tiled will go like 0 1 2 3 4 5 6 blah blah blah blah blah and it will keep it’ll just keep track of a linear number instead of an XY coordinate so I need to know what the width of the tile set is to calculate the actual X&Y coordinate on that thing and let’s look at what this exports again real quick because I might need to go back and add some more information [Music] okay I’m not seeing the information about the title set and how wide it is I’m sure it’s being stored because it asks me every time I reload this thing [Music] okay so for the time being I think we’re gonna hard code some shit or really we can pull the width and height of that title set from the texture information or something so we’ll just do this the more annoying way let me look in the documentation on how to get the dimensions of an image [Music] okay so tile set width is going to be texture well actually it’s gonna be a vector that’s enough vector to you tile set dimensions is our texture dot get size so that will be this width this height we know our tiles are all going to be 32 by 32 which we load that in somewhere we could load that in in here I want to write this in the right way I could just hard code 32 and 32 in here I can I just do that but we should do it the correct way [Music] okay let’s do that for now I’m hard coding that right now for there right there okay so these are going to correspond will have tiles 0 1 2 3 4 5 unless it starts at 1 and I’m not sure if it does I don’t it might you might have to keep that in mind because 0 might just mean no tile is there then we might have 1 2 3 so we’re gonna have to offset stuff by 1 also where’s my train of thought so to find the correct number tile width is 32 [Music] okay the other thing I need is total tiles per let’s just say total columns is equal to the tile set dimensions dot X divided by the tile width so if this is 512 pixels wide and we know that tiles are 32 pixels wide also then we have 16 columns 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 so from there if we know that 16 columns if we need to find like 145 we’re gonna have to go 16 16 again like 232 6148 62 itself so I believe what I would do is take the image code which 34 that should be relatively easy we have an image code if we divide it by the amount of columns we get a 2 if we take an integer division it’s 2 and then if we do 34 mod 16 we get to so let’s look at it let’s look at 2 2 so 0 1 2 0 1 2 I hope it’s this one I don’t know like I’m kind of mad now so my brain isn’t working as good as it should this is the ceiling so that it’s possible I don’t know it’s 18 18 18 18 34 3 4 3 4 ok it’s it should be this one I think let’s just calculate something and see what we get [Music] I also forgot one more thing we don’t want the actual X&Y here because that’s gonna be zero one two three because this is grid-based we need this to be multiplied by the width and height so yay we’re hard coding some more numbers there now we have a lot of ceilings for some reason I am NOT calculating this correct so this let’s try times 32 because again we have that issue okay that’s not correct [Music] something else I should have put in here if the image is zero or nothing we should just not store it sorry this is like kind of getting all blobby [Music] okay since I’m editing this anyway I’m gonna change this up so that instead of like a tile based XY I’m gonna get you half the pixel based XY because that’s how I like it anyway if I wanted to make a game where things aren’t stuck on a grid I could reuse this map format so we’re not gonna use tile based XY we’re gonna use grid based will still use 0 1 2 3 4 5 6 7 frizzy though okay at the moment now these are pixel based so that simplify is that part at least we still have a problem of trying to find the code and I’ve done this before [Music] we’re closer so right now this is the off by one problem we have this as the floor everywhere instead of that as the floor everywhere so first we are going to take the image code and subtracted by one so this minus one and now let’s see what we get there now it’s loading right okay I had these also backwards it helps to have those in the correct order um okay so let’s open up room mu let’s see if that it works it doesn’t but I don’t want to display the collision so usually [Music] we don’t I would kind of rather put that as property used but I’m just gonna store collision tiles and just keep that as collision information so if it is else if type is collision we’re gonna store this information in the collision tiles otherwise we’re gonna store it in the under house okay the ceilings not being displayed because I commented that out we’re going to need to separate draw functions because we’re gonna need to draw before and after so draw below or draw under draw over this will be under and draw over and then in our game state will have draw under then we’ll have a place to draw characters so draw characters here build run there we go we have maps now we did it I didn’t update the board but we maps that’s building the maps out um map loading tile object map manager I didn’t write the map manager I should have put those in different tasks done we did it yay I also did really basic game objects so that’s done we have a game of state but it’s not finished but it’s a game state I mean we’ll continue working on it I made a character into me well I made a character object I made a map we’ll need to make more maps in the future and it is Saturday so we’re gonna have a post-mortem also um I did some main character art I’m not done with it but I did some we’ll make us more tickets for this we did some environment art and haven’t done audio yet so [Music] retrospective time so what did I do well what did I not do well let’s do plus minus or change or update so I spent a lot of time on art so I kind of wish I would have given myself more time for art to kind of get all that done because I it’s not really usable right now but I did do a lot of environment art and I did that stuff I feel like I didn’t I feel like I didn’t split out tasks well enough let me make it smaller attending like I put too many things in a task at a time like the map manager plus map so probably Monday I will work on changing tasks up a little bit and expanding stuff out just do some more planning for the next sprint um I did a lot of art like I did enough art to really kind of keep I did enough environment art for this sprint and next sprint so did a a lot of environment art what didn’t go well OBS recorded the wrong screen the wrong window when I was trying to animate my character which was frustrating and that caused me to not want to do any more game dev that day I could have worked on the map stuff that day but I got sad so double-check that shit video capture yes it’s going um I think I did a good job of making videos so I didn’t do them everyday but I did them about every other day made videos regularly they do take a lot of editing though and I fell behind on doing the captions so I need to do that maybe tomorrow I’m still kind of working on figuring out how to format videos and some are really short and some are really long I also don’t know if they’re a good educational resource the way I currently have them maybe they’re just like if you’re a complete beginner it’s not going to be helpful maybe you’ll watch it and like gain some things but you’re also gonna be like holy shit what’s going on maybe not great educational resource but you know I can always make other resources and I will be because I think I’m going to be teaching a database class next semester did some animations did some sprites so that’s good I didn’t finish the sprites didn’t finish I am or I guess I renamed her to Ida sprite loaded maps and I think that like I was planning on making basic objects but I feel like I should have done this by feature instead of just like by object so I don’t like audio manager isn’t really even that important until later so we’ll just put that under the planning stuff I did a enough coding I did coding i coded mostly I’m wondering about what to change for next sprint and if you have any suggestions for what I should change for next sprint which is next week like comment and subscribe no I don’t care don’t do that honestly I don’t think I’ve ever said those words in any videos and the entire time I’ve had youtube but you can comment down below in the doobly-doo if you have any suggestions on what I should change for next friend I didn’t really post any screenshots or I post like two screenshots or something to patreon I mostly just posted the videos early so but in a way it’s like a weird balance of like it takes a lot of time to make a game it also takes a lot of time to edit videos things like I don’t want to over encumber myself too much [Music] yeah I think that’s it like I think that’s okay I can’t I know I had some thoughts about a retrospective like yesterday but I forgot it I should have kept notes keep retro notes because I’m gonna forget okay well I I guess that’s all I have I’m gonna finish editing this video and get it posted up and then I’m gonna play some video games or maybe I’ll hang out with my husband and then play video games we’ll see that sure was an exciting sprint right did you enjoy watching the videos I hope so I probably going to take sunday off and cuz today saturday i’ll take sunday off and then get back to work on Monday [Music]

Leave a Reply

Your email address will not be published. Required fields are marked *