Framework and a Level Editor! - Python/Pygame Devlog #1

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
this video is part of a new series where I'll go over the things I'm working on like game dev stuff and I'll explain how things work and show you the progress I've made along the way so first of all you'll notice that there's some stuff playing in the background of this video for these videos I'll probably be using footage from my games for most of the backgrounds since you'll probably looking at the background a lot especially compared to a normal coding videos I thought it was appropriate to just show my games in the background and also since that's what I'm working on in a sense all those in this is the first video I'm going to be using some footage from some of my older games for this video but the footage is from drawn down abyss which is about a year old so in general being able to squeeze in game dev has been a bit tricky for me because at the beginning of March I got a full-time job and then since October of last year I've been working on a game development project part-time for someone else and then I'm also working on a competitive service for beat Sabre which beat sabers another thing takes up a lot of my time in general cuz I spend a lot of time playing it and also finally I spent a lot of time working on forget for this YouTube channel it's actually only a couple hours every weekend pretty much but it still takes up a decent amount of my time especially when I'm busy pretty much all week with my full-time job so the current project I'm working on right now is really one project with two separate goals and there's kind of two separate sections to it so I'm making a framework and basically a prototype to test out my abilities in environmental game development kind of I'm trying to make environments look as nice as possible and just kind of feel immersive even though it's 2d and picard and the other goal is to basically make a framework so that I can reuse for my other games it's really one project though because I'm making a framework right now for this prototype but it needs to be adaptable to other games that make in the future so in this video I'm mostly covering the progress I have made on that framework if you see my Twitter you'd know that the first thing I've worked on was my text rendering system which I started back in beginning of April pretty much a lot of people have been asking about how I do my texts and stuff because when you use a normal text system and you try to render it at a pixel art scale it gets all garbled up or whatever and it looks weird so what I've done is I've made men's system where it just works off of a bunch of images it has an order of characters and based on the order of characters that knows what character images we're in the image I'm loading my fonts from and then when you pass the font class basically a string of text it can generate a string of character images based on the character order and the font image I gave it in this particular font system I can load my fonts from images and it'll auto detect the orders of the character images based on these bars I add to the image it's loading it so it's got a couple other and useful features like telling how wide some text would be so that I can use that value to Center texts and stuff like that but overall it's a pretty simple system the next thing I've worked on was my spreadsheet generator and my spreadsheet loader so the spreadsheet generator can take an image and I can click on things basically and generate a sprite sheet from it the use of this is just that I can take some image I've been sketching all over and just drawing things in random places and then organize it and organize it in a way that can be easily read by my spreadsheet loader the sprite sheet generator breaks things up into rows and columns if I press R it goes to a new row and generally my spreadsheet system if it's a towel set everything on the x-axis is a variant of the thing on the y-axis so you go down in rows and every row is basically a single type of tile and then all the variants are along that x-axis and I use different pixels to indicate different sections for the spreadsheet loader like I use magenta to mark the beginning corner of an image and then I use cyan dots to mark the ending corners of an image and for these spreadsheet loader that just comes down to scanning for it well first of all the yellow pixels to tell where the row starts although in the end you don't actually need those I could have done that without them I don't know I didn't but it's going through the yellow pixels and then it looks to the right of those yellow pixels from magenta pixels and then forever depicts what looks to the right in below until it finds the cyan pixels so that it knows where the image ends and then using those coordinates of the magenta and cyan pixels it can clip out the image from the sprite sheet and then I can say fit in the structure for my sprite sheets is basically just a dictionary with each sprite sheet as a value as a key in the dictionary and then each of the sections of that dictionary contains another dictionary where each of the keys is the coordinates of the tile on that sprite sheet that's a little bit confusing but yeah that's how I do it it makes the image is easily accessible without iteration really another thing I've been working on is my chunk system and this is the biggest thing and it's something that I've wasted a lot of time writing over and over again for different projects the reason why I wrote it over and over again without making a framework for it is because it's a little bit quicker to write a tile system specific to the needs of one project than to make a tile system that works for all of my projects so I don't know if you guys have seen my video I did on optimization but in there I covered a chunk system basically so my chunk system I wrote for this framework is not just a chunk system it's just an overall tile system but it's the mainly broken down into chunks I covered this in my optimization video but basically chunks L are like they are in Minecraft you can split up different sections of tiles into different categories so you can access them quicker if you know where they are the way you can access on quicker is you store all of those chunks and the dictionary behind keys of their coordinates like for that chunk and then you can just access and do that of those coordinates for the chunk in that dictionary to get all the tiles up in that chunk so that way you break down your tiles into a more easily accessible format so you don't have to iterate through all of your tiles every single time you want to render my chunk system I wrote also incorporates layers into that so it goes chunks and then each chunk has a few layers in it and inside those layers are the list of tiles for that chunk and then I also have off grade tiles which do not fit the chunk system so they're loaded a bit differently in more of an iterative fashion my chunk system has a few basic functions like adding tiles getting tiles deleting tiles and it has to be able to do that for both the off-grid and grid system some good systems work is going into the chunk system the off-grid stuff is just kind of in its own system it's under my chunk system library kind of but it's not technically using chunks because this is more of a towel system than anything else one of the most important features I've gotten this library is the get visible function which I can use to just call and get all of the visible grid towels and off grid tiles based on the screen size and the location of the string and the game's world typically I call that the store value this whole tile system is the class so that when I want to make a map I can just store it as an object and it has all these functions built-in so I just do like level map equal chunk system and I pass the parameters for that chunk system like the jump size it cell size and then the display size and then I can load the map from a JSON file which I store all of my data in JSON files because you can just dump things that are dictionaries and lists in Python into JSON it translates very nicely using the JSON library and then you can load it back in as long as you're you don't have any objects in there and it's just lists and dictionaries you can just pass it straight in which is where if my chunk systems I just store everything in lists and dictionaries and I don't have to really think about it much after I've loaded my app into the chunk system object that I've made I can just do all the gnome operations on it like get the visible tiles and head tells delete tiles and stuff like that this object in general is very convenient it allows me to easily access a bunch of very powerful features for the system and it simplifies what I have to do for it so that I'm really not writing too much code when I'm using this library or framework or whatever and it just does everything behind the scenes kind of and just gives me a huge performance boost when dealing with large amounts of tiles some people may be confused about hummed in layers because for some of people that's a confusing subject basically how it works is I've got a list of layers and then I can sort those layers by their layer number basically to get the order things need to be rendered in because when you render something and you render something after that the thing we rendered second appears on top so you can basically build layers out of that so you just render the layers in the back first and always in the front last when I request from my chunk system the visible tiles it gives it back in a form where it's all separated by the layers so I can still render those tiles in the correct order so there's a little bit work on my end in terms of stuff acted you outside of this tile cest a system when I make again because I have to set it up to render those things properly I don't want to build the rendering into this framework because that just kind of feels restrictive I don't really want to do anything that's going to be super specific to anything because there's all sorts of ways that can end up rendering things so I don't want to lock myself down to any of those ways and if I do try to I'll just end up writing a different system for the next game I make it was I just ruin for the chunk system I wrote or the tile system he wrote the next thing I worked on was my level editor which is basically just an interface for this chunk system because my chunk system already has the ability to load from files and save to files with jarran Jason so my level editor just has to be able to call the add tile and delete tile functions and have some other useful features in terms of those useful features some of my ideas were just things like flood fill it's in general an interface for layers that looks nice so I can work with that well and auto tiling where it automatically determines what tiles are used based on the shape of the terrain so when you have a towel so that you have some tiles that you want to appear if they had it's being bordered by a towels on certain sides and I can specify that in a JSON file it's like the config from my level editor and it based on that it knows which Tylar to use from a towel set that I've got swept and and all that's done by just selecting the tiles I want to modify and then pressing ctrl T and then it just Auto tiles little thing in terms of the layering features I wanted I it's pretty simple I just set it up so that I have an option where all of the layers that are not the ones I'm on are shown at a semi-transparent level and then the one I'm on is fully opaque then allows me to see what I'm working on and just kind of layering over all the level editor also have some basic UI features for selecting tiles and tile sets my fetch is kind of expected so really in the end this level editor is not too complicated it basically just calls the functions from my tile system to add things from move things and save things and load things there's some special stuff I did here though when I was making super potato bra I had to make I think 60 something levels I don't know how many it was it was a lot and it was very time consuming and I got very tired of it and it felt like I was doing something I didn't want to do but I knew I needed to get it done so I could finish that game and the reward of finishing that game was worth it but overall was a very boring process to make so many levels it level design is definitely my least favorite part of game development so I just had to throw in some stuff to make it a little bit more entertaining so the first thing I threw in was some particle effects when I removed things so it would take the image of the tile I remove just kind of break that down into its colors at certain locations and then just create particles out of those colors which by the way you can get the color at a specific location on an image in pygame only if the surface get at I believe the other special effect I added to make level editing more entertaining is that when I place a tile it's got a wet and white effect shooting out and it just kind of like a square effect and it's very nice especially when I draw in a line or something and funny enough it was supposed to be just a rectangle going out that just disappeared after the width of the rectangle gets thin enough but I forgot about the fact that when drawing rect sand pygame and you specify width if you specify a width of zero and that's set to fill in the whole shape instead of having the width of zero so when I set up my system that just kind of shrunk the width of that rectangle over time or the borders of the rectangle it would get down to zero and then it would briefly flood fill basically that wrecked before my visual effects system deleted so they had this flash at the end which that ended up being a bug turned feature for me I thought it looked cool so I kept it so that's pretty much it for the level editor an intern for a framework there was a bunch of miscellaneous useful functions I threw into a core functions script this included things like just functions for reading files writings of files swapping out palettes in images selects welcome swapping out a specific color and image for another color I've got a function for clipping out a subsurface from a surface I've got functions for just defining rights from specific points and sorting points to make a rect friendly assortment of points though it's complicated but it's useful for selection and stuff like that in my level editor so maybe have the top right point in the bottom left point and I've got fun a function to convert that into top left and bottom right basically and I've also got function in here for generating a list of points between two points in a two-dimensional space if it's assumed that is their rectangle that you're looking for points inside of so basically getting a list of all the points in a rectangle that's useful for my selection tool in my level editor so if I can select andouille because it'll generate the list of points in that rectangle and I just adjust those points well the parameters from generating those points based on the scale of the tile system that's pretty much it for the new stuff I've done with this library or framework I basically put my old framework into this framework though my old framework was pretty much as an entity system with like things like an action system with animations there's a particle system in there and then there was physics for the entities and I just over hold some sections of that to make it work a bit better so if I could use it with a little bit less code but for the most part I kept it the same and I just threw that into this current framework I'm working on so that actually saved me a lot of time this in a sense but that code was not written to the standard I would prefer so it's a bit messy in there and there's all sorts of different variable naming scheme and stuff like that in there anyway that's pretty much it for the framework I was using many people have already asked me if I'll be releasing this framework and I will but I would recommend against using it because you're going to need to understand it to use it and you're probably going to need to make changes to some of the frameworks code if you want to do anything advanced and which you can't make those changes unless you really understand the framework itself so if you're going to get to that point where you understand the framework well enough to use it effectively I would say just make your own because you'll understand the stuff you make best and it doesn't take too long in general it's also a great learning experience to just write all the stuff for yourself so now on to the stuff I was doing for the prototype game that's the main focus of what I'm working on here I'm not going to cover too much in this video I'm actually way ahead of what I'm covering in this video as of the time of this recording but the first thing I did was I just started drawing the towel set I don't know if this is normal but that's generally what I started doing first I'll draw the basic training tile set which consisted of like grass and stuff and I actually did this section on stream and in the time of two and a half hours or something I drew all of this and then after that scream I streamed again the next day and then came back and did a few more tiles and during the second stream I started working on the actual code for the prototype which I'll show in the next vlog anyways a lot of people asked me about how long it takes me to do stuff I worked on and I added it up for like all the framework and the early work I did on my prototype game and all the stuff occurred in this video was about 20 hours I think once you have a lot of experience you can generally get this stuff done pretty quickly which is very nice anyway so that's pretty much it for this day vlog I hope I'll see you guys in the next video
Info
Channel: DaFluffyPotato
Views: 44,097
Rating: undefined out of 5
Keywords: DaFluffyPotato, python, pygame, game development, videogames, video games, computer science, programming, python programming, pygame games, pygame framework, framework, level editor, pygame levels, pixel art, gamedev, indie games, python video games, python games, devlog, Framework and a Level Editor! - Python/Pygame Devlog #1, game design, optimization, platformer, pygame optimization, programming chunks
Id: 8SA5mOk7i1s
Channel Id: undefined
Length: 17min 19sec (1039 seconds)
Published: Sun May 03 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.