SFML community forums

General => SFML projects => Topic started by: GameBear on July 21, 2016, 04:02:02 pm

Title: First real game project - task: clean up / multiple attack types and levels
Post by: GameBear on July 21, 2016, 04:02:02 pm
Hello SFML folks.

So, I've recently got a lot of extra time on my hands and my hands on some sfml books.
So, ive decided i wanted to give it a go at a game from scratch. my first major project on my own.

my background - an outdated webintegrator education from 2005, some Pacal, Turbo pacal, html, AS, AS2, java and java script, all at a low level mostly by hobby and free time.

gone trough all "making games with Ben" tutorials on youtube. (check thm out, you'll be glad you did)
read all of "SFML game devolopment by example" by R. Pupius (awesome book btw, can recommend, especial if a v. 2 comes out)

and this will be my devolopment log.

A demo can be downloaded here from my google drive:
https://drive.google.com/folderview?id=0B0wU233V6VHRZms3eGY4Y19acjA&usp=sharing (https://drive.google.com/folderview?id=0B0wU233V6VHRZms3eGY4Y19acjA&usp=sharing)
Latest update - Pre-Alpha : 28/7-16



About the game:
(click to show/hide)
The worksheet
(click to show/hide)

First video in spoiler:
(click to show/hide)


here is a video of my current progress
- 27/7-16 -

http://youtu.be/B-mRCY-JCYQ
Title: Re: First real game project - current: menu template
Post by: Hapax on July 21, 2016, 06:59:50 pm
What do the colours represent in your list?
Title: Re: First real game project - current: menu template
Post by: GameBear on July 21, 2016, 07:20:41 pm
@Hapax

Oh, forgot to mention that. :)
Green = done
Red = ongoing
Black = to come.

:)
Title: Re: First real game project - current: menu template
Post by: Hapax on July 21, 2016, 10:45:14 pm
If the first three (which includes the menu) are done, maybe you could change the subject (of the original post) to reflect the current task  :)
Title: Re: First real game project - current task: load/render level template
Post by: GameBear on July 21, 2016, 11:18:50 pm
not 100% sure but what you mean, but I've done what I think you say...
Title: Re: First real game project - current task: load/render level template
Post by: Mortal on July 22, 2016, 01:20:31 am
cool

it would be nice also, if you add description about your game, like  storyline and game category and ...etc as much as you could.
Title: Re: First real game project - current task: load/render level template
Post by: GameBear on July 22, 2016, 11:38:56 am
Not a bad idea, I added a muck-up and a style description, sadly there is no story right now, as for me its more the challenge of actually making it...
Title: Re: First real game project - current task: load/render level template
Post by: GameBear on July 22, 2016, 04:08:34 pm
So, current progress since last video:

Added a basic GUI.
Added a life/mana counter that dynamicaly updates (but no real data in it for now) to the gui.
Created a levelData class to handle level loading, collision testing and rendering.
Set bounds for the view and GUI so that if the player travels to the top/bottom/left/right we wont look outside the world.

for now a lot of values are hard coded and needs to be more dynamic. Level data still needs to be encapsulated in a level handler so as to also handle other things than terrain.

here is the video of it:
(notes awesome GUI ;) )

http://youtu.be/JAIgRUFieXY


Title: Re: First real game project - current task: load/render level template
Post by: Hapax on July 22, 2016, 04:12:22 pm
Your current step is 4: "add a level handler - render a level from a png - render as RectangeShapes".
Rendering many rectangles to display a level of tiles can be highly ineffecient. You will almost certainly benefit from using a vertex array (http://www.sfml-dev.org/tutorials/2.3/graphics-vertex-array.php) (or equivalent) for the display of the level. If the level is a strict grid formation, the vertex array tutorial has an example of drawing a simple tilemap (http://www.sfml-dev.org/tutorials/2.3/graphics-vertex-array.php#example-tile-map). However, maybe Selba Ward's Tile Map (https://github.com/Hapaxia/SelbaWard/wiki/Tile-Map) could be useful ;)

p.s. As if you posted while I replying. Still, I think my post is relevant. Are you still drawing multiple rectangle shapes?
Title: Re: First real game project - current task: load/render level template
Post by: GameBear on July 22, 2016, 04:24:44 pm
-Snip- 1:
Rendering many rectangles to display a level of tiles can be highly ineffecient.
-Snip- 2:
You will almost certainly benefit from using a vertex array (or equivalent)
-Snip- 3:
Are you still drawing multiple rectangle shapes?
1: indeed, this is only the solution until Texture and sprites are added later, it is simply because it is faster to set up :)

2: true, currently i use a grid system based on the image (more in 3)

3: yes, or that is, i use 1 rect that are moved to the needed position and then drawn. I use a (flat) 3d int array [width][hight][2]
where 2 is set as 1 or 0 in the first space to indicate if anything is there, and the second is used to determine what type.

I know this is overkill, but it is set up to later support multiple different tiles of each type (so that all grass is not the same, but with some variation to it :)

I also intent to implement it so that the level handler will not render any tiles outside the level :)
//Edit: done - in the spoiler is a sample of what i mean...
(click to show/hide)

but thanks for the link, ill give it a look :)
Title: Re: First real game project - task: add a controllable character (and clean up)
Post by: Hapax on July 22, 2016, 04:53:16 pm
3D array? You can store these sorts of levels in a 1D array and it's still as (probably more so) simple to use. You only need to know the width of the level to use it: level[y * widthOfLevel + x]
As for that third dimension, you can use a single integer value to represent if something exists and which type if it does by using a single value (maybe zero?) for 'nothing' and the other values for which type.
As a bonus, map editors like Tiled (http://www.mapeditor.org/) and Mappy (http://tilemap.co.uk/mappy.php) store the tile maps in this way so it's simple to use the maps directly :)
Title: Re: First real game project - task: add a controllable character (and clean up)
Post by: GameBear on July 22, 2016, 05:02:25 pm
-Snip- 1:
3D array? You can store these sorts of levels in a 1D array

-Snip- 2:
As for that third dimension, you can use a single integer value to represent if something exists and which type if it does by using a single value (maybe zero?)
1: yes, i know, and do.. that was what i meant by (flat) 3d array. not sure what else to call it? my arrow looks like so:
Quote
   _xSize = _levelImg.getSize().x;
   _ySize = _levelImg.getSize().y;
   int size = _xSize * _ySize * _depth;
   _tiles = new int[size];
   for (int i = 0; i < _ySize; i++) {
      for (int k = 0; k < _xSize; k++) {
         int Tile = 0;
         if (_levelImg.getPixel(k, i) == sf::Color(0, 0, 0)) Tile = 1;
         
         //Tile can later be 2,3... for sloops, edges... and so one
         _tiles[(k * _depth) + (i * _xSize * 2) + 0] = Tile;
         //the tile set i've drawn have 3 versions of each tile, so determining a random number to make it more seemless
         _tiles[(k * _depth) + (i * _xSize * 2) + 1] = rand() % 3;
      }
   }

2: yes, i could use 0 = nothing, 1,2,3 = ground, 4,5,6 = slope left and so on, I'll consider it :)

*Thanks for all the interest and suggestions, that is awesome and motivating :) :)

*added a video to my previous update, that explains a bit of it :)
Title: Re: First real game project - task: add a controllable character (and clean up)
Post by: GameBear on July 22, 2016, 11:35:08 pm
Aaand last update of the day..

phew.. I've got a lot of things done.
I cleaned up a lot of code (broke it into functions, deleted unneeded double code, rearranged stuff) but i still need some cleaning of all those hard coded values...

please note that the game is not this laggy, but the cam recorder and other stuff is killing my laptop cpu...

I've added colored blocks to show the "randomization" of the ground tiles
I've added Agents that can interact with the ground
added spatial partitioning so that agents only check the closest ground tiles for collision
added jump ability and move
added the ability to shift between 3 different Agents (This is really important for the game-play)

now, a lot of cleaning up to do.. and i have to figure out why my hit test misses the ground at specific places... maybe i need to convert from float to int :S hmm...

any how.. here is the latest video:

http://youtu.be/Nc9zOoV9v2s
Title: Re: First real game project - task: clean up hitTest code
Post by: Mortal on July 23, 2016, 12:41:24 am
wow, that's really impressive all those updates done in one day!.

keep up the good work.  :)
Title: Re: First real game project - task: clean up hitTest code
Post by: GameBear on July 24, 2016, 11:35:21 pm
@Mortal
Thank you, i do what i can, when i can. Mostly i don't work much on code, but that day i had a lot of time, so a lot was done :)

ps. does anyone have a good suggestion for a screen capture program, the one i use lag even at 8% cpu usage (3% for the game, 3% for the cam program 2% for mics others), so not wort much :S (frame rate set between 30 and 60, all lag :S

Next update is here:

1: I've added ladders to the terrain, as i figured their use is heavily tied to my terrain hitTest.
2: Fixed the fall down bug, so items no longer gets embedded into the ground or the walls.
3: added a "head" hitTest, so that you cannot jump up trough the ceiling.
4: added a "auto center" function to ladder
5: again removed a lot of double code
6: added a "focus rectangle" to the character image area on the left, showing what character is active
7: added individual mana and hp to each character (randomized for now)

I think that is is.. next up, textures :D

http://youtu.be/acLkdVyLRKc
Title: Re: First real game project - task: texture handler and terrain sprites
Post by: Mortal on July 25, 2016, 01:24:28 am
@Mortal
Thank you,

you most welcome

@Mortal
i do what i can, when i can. Mostly i don't work much on code, but that day i had a lot of time, so a lot was done :)

likewise, i had a chance to finish a game in two days only, i was happy about myself when i did it, but yeah, gotta admit, it was silly puzzle game, no physic, no collision   ;D

ps. does anyone have a good suggestion for a screen capture program, the one i use lag even at 8% cpu usage (3% for the game, 3% for the cam program 2% for mics others), so not wort much :S (frame rate set between 30 and 60, all lag :S

personally, i have tried almost all free screen captures and all of them are suffered same problems, the one worth mentioned, is OBS (Open Broadcaster Software). it is quite popular in streams.

 
Next update is here:

1: I've added ladders to the terrain, as i figured their use is heavily tied to my terrain hitTest.
2: Fixed the fall down bug, so items no longer gets embedded into the ground or the walls.
3: added a "head" hitTest, so that you cannot jump up trough the ceiling.
4: added a "auto center" function to ladder
5: again removed a lot of double code
6: added a "focus rectangle" to the character image area on the left, showing what character is active
7: added individual mana and hp to each character (randomized for now)

I think that is is.. next up, textures :D

i believe ladders is essential in this game as original (Think lost vikings) implemented. for ladders functionality looks perfect.

out of curiosity, did you make pixel arts for this game?
Title: Re: First real game project - task: texture handler and terrain sprites
Post by: GameBear on July 25, 2016, 07:12:38 am
Thank you, I'll look into OBS.

About art, yes I do have some.

I've once tried making a webcomic and some forum based games, called meandmypixels I have a lot of art from it I can use... As a start...

Sample:
(click to show/hide)
Title: Re: First real game project - task: texture handler and terrain sprites
Post by: GameBear on July 26, 2016, 12:49:56 am
This will be a short update:

Got the Texture handler to work, it now takes care of all terrain rendering, and is ready for character rendering when that comes, it allows for one type of tiles (eg level 1 tiles) to use only 1 sf::sprite and one sf::texture to render each and every tile on screen ยด
things with other dimensions would need to have their own sprite (and texture to make it easy to use) but ot can handle it.
it allows each "item" to inform what it is, what animation it is currently using. and what "frame" it is
eg. all the tiles seen here (dirt with grass, dirt and ladders) are of the Type "lvl1" dirt is animation 1, dirt with grass is animation 0, and ladders are animation 14. all set on frame 1, 2 or 3 without looping.


The sample is here: 
http://youtu.be/oraDHy4iu20
Title: Re: First real game project - task: clean up hitTest code
Post by: eXpl0it3r on July 26, 2016, 10:30:50 am
It's nice seeing your progress! :)

ps. does anyone have a good suggestion for a screen capture program, the one i use lag even at 8% cpu usage (3% for the game, 3% for the cam program 2% for mics others), so not wort much :S (frame rate set between 30 and 60, all lag :S
I suggest to use OBS Studio and switch to FFMPEG recording. When you use the standard x264 recording, your CPU will encode the video material in real-time which is quite demanding. When you use ffmpeg to record, you can switch to ffv1 or lagarith codec (make sure to switch to YVU mode), which will have very little impact on the CPU, but since they are lossless formats, will generate huge files.

If you have a newer Nvidia card, you may also look into Shadowplay, which provides the video data directly from the GPU.
Title: Re: First real game project - task: texture handler and terrain sprites
Post by: GameBear on July 26, 2016, 11:40:57 pm
Thank you to you both,
just downloaded it, will play around with it later. but first, an update.

So a lot happened since last video (but not as much as i wanted there to happen.)

-Added character sprites

-added zombies sprites

-did so the levelData calculates what type of ground we have, based on its surroundings.

-added a "walk trough" type of ground (not featured in video)

-added simple AI (walk left for 3-6 sec, tunr around do same)

-added animations

-added "classes" (the 3 characters has different speed, health, mana , jump power and sprites based on their class (currently sprites are just changing belt color, gray = warrior, red= ranger, blue = mage, simple stuff)

-made animation speed scale to walking speed (still need tuning)

-found out that i cannot for the life of me add textures to a vector, so i had to use an array instead :S

and here is the video:

http://youtu.be/vaEALOq09Ss
Title: Re: First real game project - task: attacking/deal damage
Post by: GameBear on July 28, 2016, 04:37:49 am
another update.. I'll write the details tomorrow.. night night for now!!!

http://youtu.be/B-mRCY-JCYQ
Title: Re: First real game project - task: attacking/deal damage
Post by: GameBear on July 28, 2016, 09:30:55 pm
Okay, description for post above this one:

I've done a lot so far, and for the next time ill simply do rearrangement and clean up of the code, not adding anything before it is done. but here is what I've done so far.

//the level handler can read monsters into the level
-each monster is represented by a color of 255,0,X where X corresponds to a ,monster type.

//zombies now do damage

//playing characters now do damage

//playing characters can die,
-when they do you cannot re select that character
-the engine skips updates for death characters
-if all 3 characters dies, the level starts over.

//zombies can die
-the engine skips updates for death zombies.

//cooperation
- if the active player character stands close to another player character and jumps, said character will give a boost to jumpPower.

//manual reset
-going out to the main menu from the pause screen will result in level reset!

//more animations
--climb up/slide down stairs
--give a lift! (for cooperation getting over obstacles)
--Multiple attack animation possibilities