Jump to content

DOWNLOAD MODS

Are you looking for something shiny for your load order? We have many exclusive mods and resources you won't find anywhere else. Start your search now...

LEARN MODDING

Ready to try your hand at making your own mod creations? Visit the Enclave, the original ES/FO modding school, and learn the tricks of the trade from veteran modders...

JOIN THE ALLIANCE

Membership is free and registering unlocks image galleries, project hosting, live chat, unlimited downloads, & more...

Mage makes a Game


DaMage
 Share

Recommended Posts

DMEval (Dev Title)

Last year I had A LOT of spare time and I spent some of planning out what I could do if I was to create a game. I've played around with creating a game engine a few times, but never really got far past loading a single level and moving around in it. But it's all valuable experience, and so this time I am making a game proper, and doing it all myself.

I enjoy systems, figuring out and solving tasks within a game engine is way more interesting then actually creating game content. Not that I can’t make content, I have a reasonable understanding of Photoshop and Blender, but when it comes down to it, I prefer to write the code to sample animations, then to create the animations. For that reason, I’m not using a game engine like Unity or Unreal, I’m creating an SDL2 Window and drawing my game into it. 

Now about the game itself.

I have a vague idea what the ‘world’ my game takes place in, but nothing in concrete yet. What I do know is I am creating a 90’s style RPG, think early Elder Scrolls, but with more modern mechanics. In order to make the project possible, I need to make content creation as quick as possible, so that has a huge impact on how the game is structured.

The world will revolve around a central hub town/city/place from which you can travel (through menus) to dungeons. A dungeon is laid out using a bitmap, then within a level file other objects such as lights and furniture can be added. 

I like to talk things out when developing, in order to understand what I’m doing and to improve on it, so I’ll use this thread for that. Most likely reflecting on aspects once they are completed.

13th July 2016:
For the past few days I’ve been working on the AI, previously I had written pathfinding code to allow an NPC to move around the level, but now I need to make them go into combat and do more complex movements. I have a special “AIHandler” class that makes all the decisions and sets all the AI variables depending on what happens. Then when the NPC is updated in the game cycle, it reads all the AI variables and applies the correct animations.

The reason I need this is to get a final animation list of creatures in the game. I was creating my ‘wolf’ enemy and found that since there was no combat, I didn’t have a complete list of animations that the wolf needed. Like everything, the less animations I have to create the better, so if I make the combat I can determine the bare minimum.

My AI is now able to go into combat mode (and out of if they lose sight of you), then will path toward the target and once in range attack. At the moment attacking doesn’t do anything, so that might be the next task, but it’s taking shape. In order to determine who to attack, the AI is assigned into factions, so the wolf is in the Wolf faction, which has a dislike for anyone not in the wolf faction. The system still needs work, but it’s good enough for testing right now.

At the time of writing, here is a picture of what it looks like. FPS: 1400 (which for sanity, game logic is capped at 1000FPS)
DMEval 2016-07-13 10-30-50-52.jpg

  • Upvote 2
Link to comment
Share on other sites

1 minute ago, ladyonthemoon said:

Ha ha! Good to have company here! :)

What language do you use?

I'm using C++ for the programming, basically because I already had a bunch of boilerplate code for setting up windows/opengl for C++ from other projects. I also like the raw memory manipulation you can do with it. More recently, I was able to take an existing (from a university project I did) A* star search class and plug it straight in, which was nice. I'm using the Collada file format for 3D models, exported from Blender. Using PNG files for textures and photoshop to edit them. Other than that, I currently just have various handwritten text files that provide additional information. Such as level data, animation information that isn't stored by the collada format etc.

Link to comment
Share on other sites

Good to hear you're fit again Mage :pubsong:

Everything I want to say about your project involves cursing :lmao:  Mainly because it's such a huge huge undertaking but so far it looks as if you're on top of things. And the screenshot's very cool. Looking forward to more updates. :cool: 

Link to comment
Share on other sites

On 7/14/2016 at 0:06 AM, grond said:

Good to hear you're fit again Mage :pubsong:

Everything I want to say about your project involves cursing :lmao:  Mainly because it's such a huge huge undertaking but so far it looks as if you're on top of things. And the screenshot's very cool. Looking forward to more updates. :cool: 

It's big, but I'm taking every shortcut and design choice I can to make it smaller. And really, the content is what takes the longest to make, engine programming can be tricky, but it's much faster than modelling, texturing and animating a single object in the game. It's also why I'm going with a pixel style of art, since that is quickest to make without it looking 'terrible', nothing worse then going to 'realistic' and missing the mark badly.

 

On 7/14/2016 at 2:13 AM, ladyonthemoon said:

Me too. I'm really curious about making one's own game engine. I found this; maybe it's worth digging?

Making a game engine is really a case of problem solving and copying. You look at a system from a game, think about how you would program that, then try it out. In my case I am interpreting Bethesda's engine as shown in the Construction set, then fine tuning it to suit my needs. When making a new type of object, I frequently will open up one of the modding tools to see what sort of data they stored in order to give me ideas on what I might need.

That guy is taking the easy way doing 2D graphics, I prefer 3D, it makes the problems harder :P But in all seriousness, 3D is only harder because all the maths becomes three dimensional, I've taken a (very hard) course at university that taught me a bunch of the 3D stuff, it is certainly not where a beginning should be. To that end though, simplifying to 2D is really useful, for example my collision model uses a 2D map so that I didn't have to do 3D planer stuff or 3D line checking, same with the AI pathfinding all based on 2D. Whenever I can I try to move a system into 2D.

  • Upvote 2
Link to comment
Share on other sites

  • 2 weeks later...

So geez, what it's been about 12 days since the last post. Let's see what's been happening. Ignoring about a week when I was too sick to work again, I've done a heap of stuff.

Last time I was working on AI, but with a working basic AI, I needed some more content. If you want things to fight, they need the animations to do so etc etc. Realising I didn't want to go make more animations right then, I moved onto something else.

First I wanted to create a new tileset, I was getting sick of the stone wall dungeon, and wanted to experiment with an outdoor tileset. The idea behind this one was the walls would be tall grass and open to some sort of skybox.  It’s built with all the same pieces as before, so I can seamlessly swap a dungeon to it.

Picture:

DMEval 2016-07-25 23-04-57-74.jpg
But in creating this new tileset another long standing problem was starting to become worse, the fact that most the content is hardcoded into the engine right now, or in very basic text files. Essentially what I need is some dev tools to build the content with, so onto that!

If you’ve seen my past projects I have actually started one of these before, so it was time to open up that project and copy a bunch of the low-level guff that I needed to create windows and draw stuff. And after a sortish while I have something that is starting to look like a level editor. At the moment it’s still loading all the content from within the code, but that’s fine, once I have everything loaded in and editable I will start building the saving system. I can currently load the only level and move stuff around. Next I need to build the object lists so I can added and remove items from the level.

Picture:

Editor.PNG

  • Upvote 3
Link to comment
Share on other sites

  • 2 weeks later...

Okay, time to talk about what I've been up to.

I've got a bunch done on the editor, object lists, and modifying the level. I need more game done though before i continue as some objects have not had all their attributes listed yet, so it's no worth creating editing forms for them. Here is what it looks like now.

Editor.PNG

So it's back to the game, and I feel like doing some graphics stuff again....so it's time to write a water shader. In my levels all these pits are supposed to be filled with water (or not, I can set a water level in the editor). These pits:

DMEval 2016-08-09 17-18-43-17.jpg

So shaders are used to colour in all the pixels on the screen once all the complex graphics stuff has happened....but a water shader is different again. Water reflects light, so if you view it at an angle you'll ofetn see a distorted reflection of the other side. Water also distorts your view underneath it, warping the shapes of things below the surface. Lastly it often has a colour to it (if not perfectly clean), so that also has to be added.

So first I need to make a reflection, this is actually a common thing in complex graphics, so OpenGL has a thing specially built for this called a framebuffer. It allows me to render an image, then use that image as a texture on a future render. So we move the camera to the reflected position relative to the water, take a picture, then when we draw the scene, use that picture to draw the reflection. There is a tons of maths involved in that, but that's the simple version. Here is how it looks:

DMEval 2016-08-09 17-18-17-42.jpg

That's a bit boring though, and unrealistic. Water tends to move (and in games it looks bad if it's not moving), so I need to find a way to move the water. The water itself is a single huge flat plane, so what we need to do is 'fake' some waves on it. The technique I eventually decided on, was to use pseudo-random points (not random, so they look random, but will always generate the same) and build a heatmap with them. The closer a pixel is to a point, the more it distorts the image. Without the texture, this is how the heatmap looks:

DMEval 2016-08-09 17-27-50-97.jpg

Would you believe that those points are actually in a simple square grid, just a bit of cool maths to 'randomise' them, without it being random. Then when it is applied to the reflection picture:

DMEval 2016-08-09 17-29-08-49.jpg

Each of the points move around in an ellipse and can overlap to give an interesting visual. However there is a big problem, water doesn't act like a perfect mirror, we need to see the bottom. Water refracts light however, so we also need to distort what we see. Another frame buffer to get a picture of everything under the water, and then we apply the same heatmap to distort that and tada! We have something that looks decent:

DMEval 2016-08-09 17-17-30-27.jpg

I'm not happy though, I've done a good job at faking the water movement, but my technique is just distorting texture sampling and not doing proper transformations. For that I need to calculate normals, and if I'm going to do that, I might as well make the water plane itself move. Instead of a single huge plane, now the water is made up of many small squares, I can then apply that same heatmap to those points to physically move the vertices.

DMEval 2016-08-09 17-19-16-40.jpg

That's where I'm up to, I'm going to go do that and see how it goes.

  • Upvote 3
Link to comment
Share on other sites

20 minutes ago, DaMage said:

Okay, time to talk about what I've been up to.

I've got a bunch done on the editor, object lists, and modifying the level. I need more game done though before i continue as some objects have not had all their attributes listed yet, so it's no worth creating editing forms for them. Here is what it looks like now. So it's back to the game, and I feel like doing some graphics stuff again....so it's time to write a water shader.

Great job! :good:

How and where do we learn how to write an editor and graphics stuff like shaders?

Link to comment
Share on other sites

25 minutes ago, ladyonthemoon said:

Great job! :good:

How and where do we learn how to write an editor and graphics stuff like shaders?

I was actually lucky enough to do a course on the graphics at university, which is known as the hardest programming course at my university. I'm not quite sure how you'd learn to write shaders without a really in depth lessons like that. It's all matrix/vector based maths, with some trigonometry thrown in. If you were just learning shaders you can start at the bottom, translate vertices into the right places, then sample pixels from a texture. But in OpenGL 3.0 onwards even that requires knowledge of the different screen spaces and how to build a projection matrix. There are of course tutorials, but I can't really point you to any and say 'this one's good', since i never learnt from them. In fact, I'd say most people are better off using what shader system a more advanced engine has, things like Unity and Unreal have very good tutorials for writing shaders.

In terms of an editor, that's all just several years worth of software engineering knowledge, I've copied things from other game engines, like Bethesda's modding tools, and Unity.....but other than that it's just making whatever I think I need. This was my second attempt at an editor, so I was able to copy paste of the bits from my old one, but it suffered from a lack of planning as it was my first attempt at such a program. The editor itself is just Windows CLR C++ program, but for someone new, they would be better off working in C# for such a thing.

  • Upvote 3
Link to comment
Share on other sites

There is a rule in games graphics that near enough is good enough, perfect simulation is great, but you have to make a trade off with performance to achieve it. For example, if you want realistic lighting you would use ray tracing, but that's too expensive for games, so a variation on the Phong model(ambient, diffuse, specular) is used instead.

Now I was going to calculate the normals for the waves, then use them to figure out how have the reflection would bend off the water....and I realised....that's too much. My technique of just moving the sampling position around does a fair enough job of bending the texture, who cares if that's not how real water would look.

I did still need the normals though, and I wanted the water to look a bit more 3D, so I moved the heatmaping to the vertex calculations (which also makes it faster, since it is expensive and doing it per-vertex is better than per-pixel). Here is a trippy picture of the normals applied to the waves as calculated on the per-pixel basis.

DMEval 2016-08-09 21-19-35-61.jpg

On a tangent, unlike regular programming, you cannot 'print' out values to debug shader code, and you can't stop it during execution to see what is happening. This is because everything is happening in massive parallel on the GPU, so your only choice in debugging is to display out colours and try to figure out what is happening. This can be very frustrating if all you are getting is a black screen though.

Now with 3D water, I needed to add lighting effects to it. This was a bit hard, but long story short, this is how it works. I need to blend together the reflection, the refraction, the colour of the water and the lighting values. The refraction and reflection already have the lighting applied to it's colour from rendering the picture, so it only needs to be applied to the water colour. In order to blend the water colour, the colour based on reflections is calcuated, then the water colour with lighting is added to that value. As long as the water colour isn't too bright this works well. 

However there was a problem, when it was fairly dark, the water looked bad, it was mostly black so you couldn't make out the movement. To fix this, I added an extra small light coming from the player's view that only applies to water. This then adds a small, but important, specular highlight to the waves so you can see them.

Here is the finished product:

DMEval 2016-08-11 12-03-56-80.jpg

  • Upvote 3
Link to comment
Share on other sites

Cool pic, great work, and your writing has improved immeasurably over the years. :trophy:

Water in pitch dark will look black, only catching whatever light is nearby, so I think you've got it right (not to mention the cool pic :) ) I'd suggest working your magic on some warm ambient light or torches and kill that player light and see what you get.

Again, great work!

  • Upvote 1
Link to comment
Share on other sites

2 hours ago, grond said:

Cool pic, great work, and your writing has improved immeasurably over the years. :trophy:

Water in pitch dark will look black, only catching whatever light is nearby, so I think you've got it right (not to mention the cool pic :) ) I'd suggest working your magic on some warm ambient light or torches and kill that player light and see what you get.

Again, great work!

I suppose you can't see it, but in the picture above that light is being generated by a wall torch, that is not a player light. :)

Water is a tricky beast when it comes to light. For example, normally you work with Ambient, Diffuse and Specular.....but Diffuse doesn't make sense on water since the surface doesn't block light, and ambient tends to be applied as a constant. The reason I've added the player light is just to give a little definition to the water shape when there is no direct light source to generate specular. I guess you could think of it like applying the level ambient light, just as specular.

Thanks :)

  • Upvote 1
Link to comment
Share on other sites

39 minutes ago, donnato said:

Awsome add Mage. I scares me that I actually understood what you were describing and the lighting stuff.  For instance, Ray Tracing, and Phong... I`ve messed with those and others in blender.  :coolup:

Phong actually has a bit of a sad story. He defined Phong Shading and the Phong Lighting model in his PHD thesis in 1973, models that are used to this day....while he was suffering terminal leukemia and died only 2 years later.

It really was a case of someone who had so much potential dying way too young.

  • Upvote 1
Link to comment
Share on other sites

  • 3 weeks later...

Had a uni report that was taking up all my time over the last few weeks, but that's finished now, so it's back to some game dev.

I will come back to my water shaders later, I need to work on the refraction a little bit to make it look better, but for now I want to do the next thing on my checklist. A day night cycle.

First off I need to make a skybox, this is where the texture for the sky goes. I started with a cube and just grabbed a skybox texture off the internet to see how it looked....not bad but a long way from what it should be. I've decided to separate the gradient of the sky from the clouds, that way I can have a static sky and move clouds around to make it more 'dynamic'. I've talked about the gradient of the sky before on here in an old topic, but here is the basics. On a clear sky you have almost white at the horizon, and a deep blue straight up, with a gradient in-between. Using a skybox, I can have a radial gradient on my top square, then have a vertical gradient going up the side squares.

Night time is also easy, since you can apply an almost black colour across the whole thing....no worries. But dawn and dusk are much harder. Now you need a variety of colours on one side of the sky, with it fading to a solid colour on the other side. I ended up using Illustrator instead of Photoshop to make these since it's gradient tools are a bit more advanced. With a bit of playing around, I ended up with a dawn texture that looks like this:

dawn.png

 

Now to the implementation in the game engine. The skybox is actually quite interesting, as it is implemented differently than you'd expect. It is actually a small box placed over the head of the player, and through some graphics tricky by making everything else render in front of it, it appears as it it's far away. The reason I do this is so the horizon moves with the player, I could have made it just really huge, but then you run into depth precision problems from making your view distance too big. The cube is then rendered, and depending on the time of day, it can transition between the different sky textures to give the appearance of it changing. The other important object in the sky is the sun and moon, so that was next. The sun and moon are simply two billboards that rotate around the player's head in a similar way to the skybox. The sun is simply a white sphere with a yellow glowing edge, and the moon was just some grey smudges and lines with a smaller glowing white edge. Basing their rotation around the player's head on the time of day in the game I could simulate them moving across the sky.

Then I simply applied the time of day to effect the ambient light in the level and And Ta-Da! I have a very simple day/night cycle. Here is a video I made of it:

 

 

  • Upvote 3
Link to comment
Share on other sites

6 hours ago, donnato said:

Ok...mind blown... I`d never have thought of having the skybox on the player`s head. What a cool solution.... except, now when I play, I`ll feel like there`s an invisible box on my head. :rofl:

That's the trick; why do you think it's called "skybox"? Skyboxes normally have six sides, six textures then, but it seems that four can make the trick since DaMage's has only four. :)

Link to comment
Share on other sites

22 minutes ago, ladyonthemoon said:

That's the trick; why do you think it's called "skybox"? Skyboxes normally have six sides, six textures then, but it seems that four can make the trick since DaMage's has only four. :)

Sooooo....I'm really lazy. The North and South look at the same, just mirrored, so I can used the same picture for them and just flip the UV map. Then the east and west each have their own image, and then the upward plane has it's own texture. There is no sky downwards...so I just cut off that part of the box and therefore it doesn't need an image. 

I tended to have some 'seams' along the edges of the box, so I added some more vertices to each side and pressed the 'smooth vertex' button a few times to deform it into a sphereish shape which helps hide the seams a bit cause they are now bent instead of straight lines.

I make things up as I go along, I have no idea if that the 'proper' way games do a skybox, but it works well enough for me.

  • Upvote 2
Link to comment
Share on other sites

2 minutes ago, DaMage said:

I make things up as I go along, I have no idea if that the 'proper' way games do a skybox, but it works well enough for me.

That's how things should go. :)

I'm just surprised that, with all the technology we have today, skyboxes are not actual spheres divided in four or six quadrants, according to the developer's needs; each quadrant getting it's own texture. I'm pretty sure that bending textures is easy to do with the current images software. ;)

  • Upvote 1
Link to comment
Share on other sites

1 minute ago, ladyonthemoon said:

That's how things should go. :)

I'm just surprised that, with all the technology we have today, skyboxes are not actual spheres divided in four or six quadrants, according to the developer's needs; each quadrant getting it's own texture. I'm pretty sure that bending textures is easy to do with the current images software. ;)

If you really wanted to make a 'true' sky, you could make a sphere, then use a bunch of maths to calculate what colour the sky would be based on time, sun location etc...but it's really overkill, I did a little of that in a previous project, but it's more hassle than it's worth. What makes spheres so hard to texture is that it is just difficult to map a 2D image over a 3D sphere without getting seams (think trying to put a piece of paper around a ball).....a good artist can do it, but it's definitely not easy. I think you'll find in a big AAA game, how you described is exactly how they would do it, as it gives a good artist lots of control over how things look, but I'm not a good artist, so I do a simpler technique.

If you do a quick look around online for skybox textures they are normally cubes with 6 textures, one for each side, which is why I think a bigger game would be like that. This works fine if you just need a static sky, but if you want moving clouds and weather effects (like I want to do eventually) that system doesn't work. 

Also, the main reason I wanted to only have 4 images is because of powers of 2. For mipmapping, it helps to have textures with sizes that are a power of two (so they can be divided down easily), which is fine if you want 1, 2, or 4 images in a texture....but if you want 5? well you'l have 3 empty spaces in your texture. I hate wasting space like that, especially in a texture that is going to be big already like a skybox.

  • Upvote 2
Link to comment
Share on other sites

I figure I should outline what I'm doing next and why exactly it's the next feature to work on. At the moment I am doing a course at university on human computer interaction and am doing a project based around disability accessibility. The first part of the project was a written report on one handed gamers, but now for the second part I'm doing a more practical task. Using what I learnt writing that report, and my own experiences, I'm going to attempt to design a controls system for my game that would allow it to be played with one hand. The reason this is a worthwhile task is that I've made my game using the standard, movement keys and mouse look, which is actually really hard to control with one hand....just try playing Skyrim using just one hand....it's possible, but not easy.

So that's the task, but what do I need to do? Well I need to add some 'game' onto my game, such as the ability to do many different actions, and some gameplay (such as killing enemies) so actually test the control on. Here is my list:

1. Finalise the character model.

At the moment I have a character model, but it only has a few animations because I was unsure how many more bones I needed to add to it for animations. Hell I wasn't even sure on the visual style I wanted. But to move on I need to make a decision there.

2. Create animations
Once the character model is complete, I need to create a bunch of animations. Attacking, running, jumping, blocking and stagger.

3. Program interactions.
At the moment my wolf creature will load in, path to the player, and attack non-stop. I need to improve this AI a little, then allow for some simple combat. The wolf needs to attack, then pause (either moving or not) then attack again. For the combat, I need to be able to attack and do damage, block attacks and take damage.

4. Once this is all done, I can look at designing some controls systems for my project.

Ideally I want this to be designing controls by the 19th, I feel if I buckle down I can achieve all this by then. The hardest part will be the programming, but it'll be the most fun aswell, so here hoping that is smooth.

PS: All this animating I have to do, I hate animating. I'm a programmer damnit, not an artist.

PPS: Here is a picture.

DMEval 2016-09-08 20-53-41-75.jpg

  • Upvote 2
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...