Tuesday, December 27, 2011
Motivation waning...
1. Copy the most recent codebase off my craptastic laptop so I can work on it on my much nicer desktop machine.
2. Reorganize the game engine, and start a rewrite focusing on making things more clear and encapsulated.
3. Try not to feel guilty every time I sit down to code that I'm not doing something more productive like look for a job, or something.
4. Find the motivation to continue working on it, even though I might be the only one who plays it.
Yeah, that looks about right for now.
Thursday, December 22, 2011
Intermission
Alright, I realised the other night that I was totally lost in my own code. I was writing code and just waiting for the error messages to see if I was doing it right. Bad, bad, bad. So, I decided to just do a rewrite, with a mind toward consistency, readability, and ... yeah, just kind of a rethink. For one thing, I'm going to be a little more lenient with my self about what's an entity and what isn't. I mean, I tried when I first started, making the screen an entity. It was a pain. Recently I tried to make the map an entity. I mean... will the map ever have an image of it's own, or get turned into a shoe or something like that? No? Then it really shouldn't be an entity.
Oh, another important lesson I learned the other night. If you're going to load an image into memory for every entity, don't make a 1024x1024 map filled with unique floor entities. Yeah... didn't think that one through.
So.. different topic for once. Just for fun. I
Crap... Gotta pick up my son from school. Until next time... :-)
Tuesday, December 20, 2011
Fragmentation blues
For instance, I set up my ghetto laptop (the old Dell that had water mysteriously spilled on it. Still works, but needs a usb keyboard hooked up to it) at a friends house the other night and got to work for about 4 hours straight. It was nice. One thing that came from that though, is that I found one major instance where I was working on two different solutions to the same problem in different parts of code. Ugh. I think every time I would sit down to code for 20 minutes, one or the other solution would come to mind and I would chip away at it. Never realised what I was doing until I had enough time to work the problem all the way through and ran into the other solution.
Anyway, a good friend of mine, and professional project manager, suggested at least I use a project outline with items I check off as in progress or completed, etc. He spent some time with me yesterday fleshing out an outline.
Another problem with not having any type of project management, as well as having unpredictable obligations with family, is getting interrupted in the middle of big rewrites or major changes. I feel like a surgeon, covered in blood holding a patients guts in his hand, who is just told he needs to stop immediately and do something else. Meh.
There's nothing useful in this post. Just venting.
Oh, I'm back on map crap. I think I finally found a solution that will work. I forgot to think about what will make it easy for the render function to quickly get all the items that need to be drawn, and in what order. Plus the ordered list for what's in a tile location is gone. I'm going with three layers. Background has only one item, foreground has only one item, and midground has a list ordered by eid (arbitrary, doesn't matter but shouldn't change). Background and midground are always passable and foreground always blocks movement and line of sight.
And.. I should be coding instead of yakking.
Saturday, December 17, 2011
Not dead yet
So here's what I've got so far, and this is what I'm gonna try to implement:
Dictionary of Maps -> Dictionary of Areas -> Dictionary of tiles -> lists of objects.
Map keys are tuples, (name, level).
Area keys are tuples of grid coordinates (area_x, area_y)
Tile keys are tuples as well (tile_x, tile_y)
Friday, December 16, 2011
Sick of maps yet? Yes I am.
Alright, enough exposition. What's my problem?
K, we've got entities, lots of em. The walls, the monsters, the items, maybe even the floors. They're all in this massive dictionary at the moment. Which.. now that I think about it.. probably isn't going to work once we're talking about a couple million entities.. Hunh. Dangit. Well, no, wait, hold that thought. What will solve the map problem should solve the problem with the rest of the entities. For one thing, getting the map to work should let us break our massive lists of items into small chunks. Though.. how will that work. They're all in a big dictionary right now. Even if we're not looping through every item in the dictionary, looking up items by name in a million entry dictionary is still time consuming.
And now that I think about it, if we're talking about a million items, and they have memberships in many multiple dictionaries, then we've got multimillions of stuff in ram.. :P
Alright alright.. stop that. I have no way of knowing what is and what isn't a misuse of resources or whatever. I wouldn't know because I've never finished writing a game. So,back on point.
We have, entities. We need, simple boolean grids for line of sight, for light fall, for collision.
Okay random thought.. (darn you add) so, I'm trying to see how we're going to deal with AIs that are off screen. Unless we're simulating the entire world, then we need to break it down. So here's a thought. We run the ai for all entities within one screen of the player, so nine total, but then also run it for all the screens he's visited for a certain amount of time. That way you can't piss something off, run away three screens, and when you come back it's forgotten about you. Plus it would be cool if it's computationally economical to run the ais for more than just one screen around the player. We'll see.
---
man... I've got dora the explorer playing on a tv that's about ... well it's about one foot away from my head. Plus I was asked to rip an avi of Elmo's Potty time. My thought process is totally screwed. I guess I'll be back for episode 24 of maps in hell...
Thursday, December 15, 2011
Maps maps maps...
Alright, so one of the problems I'm having I think is that.. I don't so much need a traditional map, with or without layers.. I need a world space for things to exist. I mean, everything has coordinates, so why would some things be in a special map grid, and some things not. Still not totally sure how the map is going to work, because for some things like LOS calculation or pathfinding, we're going to want a simple 2bit array of walkable/visible space. But I think it'll probably be some type of BSP tree, or other hierarchical structure. The entire world being the first node, then somewhere along the line there will be a screen sized node, then a square tile sized node, then ... what else. Need to keep reading, both for education and inspiration.
Map hell
Of course, the problem is how could I possibly know what the "right" way is. Maybe it helps that I get fixated on ideas sometimes. Or that's the cause, not the cure. Eh. No matter... I have to take the fam to the grocery store right now anyway.
Wednesday, December 14, 2011
Alright, so, more map brain storming...
Alright.. I'm liking the map scrolling system from the last post well enough. Well enough to test it out at least. Now, as far as storing map data.. how are we going to do that. If I'm using something like libtcod for line of sight and pathfinding, then I'll need to pass it an array, not a list of entities. I can have a system that creates that and passes it to the lib.. though I feel like that would be really computationally intensive...
Having a little trouble keeping a solid train of thought.. At my mother's house at the moment. One kid is playing 10 feet to my left, one is playing 5 feet to my right, and my wife is talking about something. Not to me. I suppose I'm being a little rude by doing this rather than participating in various activities. Eh, oh well.
Ugh, plus I've got to do something incredibly stressful in a couple hours. :-P This guy that I worked with before I was laid off a couple months ago needs help with some computer stuff, and for some reason wants me to come down and help him. He's paying me some unknown amount, rather than ask the IT staff that still work there, probably because the guys that are still there are jerks. ;-P Well, no, really, they are.
Alright, totally sidetracked at this point. Not going on a rant ... :P Can either stop writing... oh dear, my 2 year old is pounding on the piano now... or try to muster my concentration and see what I can do. I really am interested in finishing this game, so I'm going to try and keep working.
It would be cool if I had a laptop or something. I could be programming right now instead of just blogging.. or journalling, or blathering, or whatever..
Anyway.. okay.. so the problem is, how do we deal with the map. If the map tiles are going to be just another entity, then they shouldn't have a special map aspect since there will be a lot of things drawn besides map tiles. They might need a weight, or layer property somewhere. Maybe in the form aspect, like they already have an x and a y, so maybe they need a z. The problem there is.. keeping track of what's on top of what. Somewhere there has to be a list of what's in a tile so that we don't end up with two things with the same z.
Argh... interruptions every two seconds... gah... I need a hole in the ground, or a tree house, or a log cabin on the side of a mountain, or something. :-B
wtf.. where was I. The ground is immutable, since it's a 2d game, so you could just have this massive grid and everything is assigned a unique id for what square in the world it exists. That seems to go against the whole entity system though... I guess it makes sense though. The alternative would be what.. you have each entity know what is above, below and beside it, and you draw the world relative to the player. This massive linked list.. sort of.
Ugh... this is obviously not a good time to be working on this. My wife just asked if she left some persimmons in the trunk of the car and I nearly lost it. Wtf?!? Go look! I have no idea what you did with the persimmons you bought. Are you telling me we have fruit rotting in the car? I suppose if they are in the car, you need me to go get them, yes? :P
Eh.. better vent here than cause problems. Gah...
Map brain storming..
Or should I say, thinking out loud. Or.. thinking.. while/through typing.. or whatever.
I'm trying to visualise the movement system. I don't want to do zelda style because that kind of breaks with line of sight. If you're going to have connected maps you can't walk off the screen and be right next to some terrible danger or off a cliff or something. Since we're doing fluid, connected maps..
Well, even that.. why think of the world as a series of connected maps? I guess for one reason, so the game doesn't have to think about the entire world just to show the small area the player is in. But back to screen movement.. I don't want to ahve the player be a fixed point on the screen and have the world move when you walk. Then again, that's how world of warcraft does it.. and how all fps games do it. Heck, that's how real life is. Seems like it would be "cinematically" disorienting though. Kind of like watching a movie in first person view. Hmm.. maybe it's only disorienting when you're not in direct control. Like, do the player in the center version when you're tap, tap, tapping your movements, but hold the world still and move the player when you're doing walk to point movement, then reorient when you stop. ? eh.. gotta go pick up my son from school.. think about this more later.
Maps...
In the past, when I've needed a map for a tile game, I just create a 2d array, and there you go. Fill the array with tile objects. Now though, with this entity system, things are different. For one, all entities already have coordinates, so there's no need for a map array. Although having one could make looping through just the map tiles easier. Plus if map tiles are just another entity... and this is a 2d game, I've got to separate layers.. like what's passable and what's not, what gets drawn on top. I don't want to necessarily say that just because something is terrain it's on the bottom layer. There will be other entities laying about, and they all need layer information too. No reason to create a special case just for terrain.
Another thought I had was... what is the coordinate system even based off of? Is the whole world just the size of the screen? Should it be infinite? If so, how do you work out the offset for coordinates. Maybe the game should run old school zelda style, where if you walk off the edge of the screen, another map slides into view.
Ah.... interesting thought. So, what if... You have a map aspect/entity that represents one screen full of information. Then tiles, monsters, whatever can have their x,y grid relative to the map they are associated with. Then the map has the names or ids of the four other maps that are adjacent to it. Then you can have infinite maps without coordinates. Oh six maps, I guess. For above and below as well. Hmm.. another thought. This wouldn't even have to be screen sized maps either. They could be anything. 256x256, 16x16, whatever. It would just be a way of chunking up the map.
Alright, so, big question. Are we doing the Zelda style maps that flip when you reach the edge, or smooth scrolling to infinite distance...
You know, it would be a lot easier to do the zelda style.. but more fun to have the infinite scrolling style. But much harder..
Tuesday, December 13, 2011
Wierdness..
Alright, so... The weird thing isn't that blogging has helped me work through problems, the weird thing is that now I just imagine blogging and the solution comes to me...
meta entity.. possible misuse of the word meta...
So.. I want to have an aspect that designates who is controlling the entity. The idea being that the player might at some point be in control of a monster, or something. Plus the AI systems would have lists of who they were controlling.
Well, I guess that answers my question.. sort of.. maybe it's more of a trailhead than a finish line. Anyway, the problem is, if the player entity needs the id of the controlling entity, would it be itself? Or can I assign an entity id to someone sitting at home playing this game on their computer? I think the answer will come when I decide how the AI system will work. I'm assuming it will be sending a stream of goals for the action system to chew on, just like the player input system does. So, however I decide to identify the AIs of the game will be the same way I identify the player.
Latest issue
Now, the issue is, I want a "blockable" or "blocking" flag for my high-tech tile based collision system. So, do I create a new aspect called "blocking" or do I tack that on to appearance. But now appearance isn't just about what the item looks like, so as long as we're doing that, maybe we should roll the "position" aspect into appearance and call it "form" instead. It would let me pass just one thing to the render system, though how many things I pass is really inconsequential. I dunno. I want to avoid lumping too many things together, though how granular do I really want to get. I can't think of too many things that have a position that don't have an appearance, eh... screw it, I'm doing it. Lets see if I can keep from breaking everything as I roll everything into a "form" aspect.
Why am I doing this instead of coding
Edit: decided to go for 16x16 sprites. For good or bad, it'll let me draw the whole map on the screen at once and not worry about scrolling, at least for now.
Oh, and how hard was it to change from 32x32 tiles to 16x16? Just had to change the number 32 to 16 in one spot. Neat!
Too fun
So why am I still writing? Eh.. I dunno.. it's like having someone to talk to I guess. No one else is awake, and if they were, they probably wouldn't want to talk about this stuff.
Eh.. good night internet.
Okay, timed it..
import timeit setup = ''' y = [] for x in range(80): y.append(x*32) ''' t = timeit.Timer(stmt="a = 80*33", setup=setup) print t.timeit() t = timeit.Timer(stmt="a = 80<<5", setup=setup) print t.timeit() t = timeit.Timer(stmt="a = y[79]", setup=setup) print t.timeit()
So yeah, that gives me the result:
0.0310996928381
0.03094031504
0.049108406236
Some miniscule advantage with bit shifting (I multiplied by 33 on purpose so it wouldn't bit shift behind the scenes.. though maybe it does then adds 1... :-/ who knows.) but yeah, there we have it.
New questions...
The problem: Since the game is grid based, when a player moves he goes from space 1,2 to space 1,3 for example. But, depending on the size of the sprite, say a 32x32, he moves 32 pixels each time he moves. Now, do I have the rendering system look at a the single spaced grid and just multiply coordinates by 32 for every single thing it needs to draw? Seems like a lot of calculations. Maybe the compiler knows enough to just bit shift a few spaces over so the multiplication is trivial. Dunno. Maybe I should keep track of two coordinates for everything, and only do the multiplication when something moves. Maybe I should make a lookup table where all the multiplication is precomputed. I dunno. Crud. Hate stuff like this. I guess I could time it, see what's fastest. Then again, this is a turn based game, there's not really any FPS target to worry about. Maybe I should be worrying about just making something that works and not so much on the best way to do it. :P Ugh..
Movement..
It's 12:37 at night, but I just sat down a few minutes ago and I'm drinking a Coke, so I may as well use this time alone to see what other damage I can do...
Monday, December 12, 2011
More lessons
It's kind of interesting, with this 'entity system' I've been fooling with.. For one, it's definitely taking me to new places with Python. Well, and in programming in general. For example: something a little different than a giant list of if, elif conditionals. Puting a list of functions in a dictionary. Of course, this hasn't worked out quite as smoothly as I was originally hoping, but still, a learning experience. Once it was all said and done though... I'm still not sure if it's better than a bunch of if, elifs... Ah well. We'll have to see if I can get back on my computer some time this evening to fool around with it some more.
It's kind of sad... I'm still at the pre-player movement phase of the game. I can't even walk around yet. Lame. So, yeah, that'll be my next milestone.
So, it must be said... I'm typing this with a little bluetooth keyboard into my phone, running a Blogger app. I should probably submit soon to see if this all even works. Well, the Blogger app part at least. I'm also sitting in my car in front of my son's school, waiting for him to get out of class for the day.
What else... Oh, my wife noticed my last blog post and wanted to know what the heck this cult was that I'm joining. I explained the name to her. She seemed happy to hear that I was working on making a video game. She immediately asked me if I'd applied for any new jobs as soon as I was done telling her about it. Yeah, I'm unemployed. Go me. Anyway, I just can't imagine sitting around feeling crappy that I don't have a job 24/7, so yeah, sometimes I work on fun projects like trying to make a video game instead.
Looking forward to hanging out with a friend this evening. Usually we watch movies together, but there hasn't been anything out lately that we've wanted to see. I'd like to just hang out at his place and continue programming, but I don't really have a portable development setup. Ah well.. we'll see what happens.
The Grid
I like pixel art, and I can do a lot with 16x16. The problem is when you're at 1280x1024, those 16x16 sprites are like, half a centimeter square or something. You've also got the added problem that, now that you're not using abstract representations for the various creatures and objects, your images aren't going to be to scale. Dragons are the same size as potion bottles for instance. You could escape the tile size vertically, by having tiles that overlap the tiles "behind" them. In that case though, you might want to make your tiles rectangular instead of square, to imply an angular view on the play map. Ugh.. endless possibilities. One problem when you're not working with a team is you get to flip all the coins, make all the decisions... meh.
Now my wife is looking over my shoulder and I'm feeling self conscious about what I'm writing, so that's it for now.
The name of the blog...
The "Cult of the" part comes from my love of the Cthulhu mythos. I was thinking it would be neat to take celtic mythology and treat it with the same horror noir that Lovecraft usually gets. I'm not sure yet if I'm going to set the game in the early 1900s yet, or what. Kind of playing with the idea of maybe making the player be a member of some organisation like the BPRD, or a supernatural hunter, or something like that. We'll see.
Do I really need a title for another ramble?
So... yeah, I'm not doing that. If I'm the only one who ever reads this, that's good. Well, I guess the fact that I'm writing this says otherwise. But basically I'm just writing this so that if someone stumbles across this blog.. I don't know... They'll know, that I know, that this isn't a "well written" blog.. It's just some random crap. An attempt to add some continuity to my thought process.
Sunday, December 11, 2011
More yada yada
I hate this time of the evening.. I finally have free time to work, but my brain is starting to shut down and I'm really worthless trying to get any programming done.
Back to the thing... So yeah. It was supposed to be a simple Roguelike, but not only did I decide to use graphics, but I also decided to roll my own entity component system for the game engine. At this point, thinking about how stupid that was is moot because it's pretty much done. It's done to the point where all I'm doing with it now is trying to figure out how to do little things like player movement with it, and philosophical things like is the player an entity, meta entities, etc.
I kind of ran into a chicken and egg problem where I wanted a player that I could walk around the screen, but I would need a world, character generator, etc.etc. So I just faked it and created a "test" system that gets called by the system manager during init that just creates a player entity and slaps him on the screen. Doesn't work 100% yet. Trying to decide how player control should go. The obvious method would be to read input, check for collisions, and update player position. Basically. With our shiny new entity system, it's going to be something more like, Control System looks at game events and sends keystrokes to a dictionary of methods. The methods decide what game components need to be updated, then various world systems check the components for new information and execute the changes required.
Ugh. I don't even want to think about this right now without a clear head. Gonna watch Neverland or something and fall asleep. :P
Whatever,,,
I've already started working on the game, and immediately I've fallen into one of my classic traps. I picked something simple to do, because I knew I should pick something simple if there was any chance of me finishing it. But.. then I immediately made it complicated.
So, I decided to make a Roguelike game. They're fun to play, although I haven't played one in ages. Rogue, on an actual Altair, was one of the first video games I ever played. This was back in the... early 80s.. probably. I dunno, I was a kid, so, hadn't really started keeping track of dates.
Interesting.. That last paragraph is a good example of how I take something seemingly simple and somehow decide it needs to be more complicated.
So yeah, decided to do a roguelike. Simple enough. Good points, from an actually finishing something standpoint, are: no graphics other than text, no animation, no sound, no physics, no FPS (it's turn based) so your loops can take a lot longer, and... yeah.
So then I decide, I should give it graphics, at least. Not animated of course, that would be crazy. I like doing pixel art, though it seems like everyone is doing that lately. Especially with dungeon crawl type games. I'm thinking right now of either doing 64x64 sprites in a 1280x1024 screen (grid would be 20x16) or maybe 32x32 on a 1024x768 screen (32x24 grid)
Alright, have to stop typing now. My 6yo son is guilt tripping me into playing battleship with him.