Chunky by FelipeFS
Chunky by FelipeFS
GPWiki.org
It is currently Sat Nov 01, 2014 8:48 am

All times are UTC




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: What I need to start?
PostPosted: Sat Feb 22, 2014 3:17 pm 
Rookie

Joined: Sat Feb 22, 2014 3:00 pm
Posts: 2
Hi all,
is my first post on this forum. I take this opportunity to say hello to all the users!

I want to start a game programming, nothing for commercial, I want only learn.
I know how to program with C, C++ and C# but is only a study programming. I know how to draw line, cube and other shape with OpenGL, OpenCV and other library but I'm NEVER was able to load an image (bmp, gif or other) and put an image character that walk on it.

For starting, I've thinked about a very very short adventure game (like old Monkey Island, Day of the tentacle, ...) with few static 2D background and a man that walk on it.
For doing that, what I need? What kind of library I need? I prefer a totally open source library or tools.

Thanks, and sorry for my english.


Top
 Profile  
 
PostPosted: Sat Feb 22, 2014 3:42 pm 
Grand Optimizer

Joined: Sun Oct 16, 2011 3:09 pm
Posts: 366
Location: Here (where else?)
Welcome here,

For the actual window with graphics on it, you need some graphical library. I use SDL (libsdl.org), but there are also others (SFML is one iirc).
A game roughly has the following (highly simplified) structure:

Code:
set_initial_state()
while(true) {
    time = get_current_time();
    get_and_process_input_from_user_if_available()
    sleep N - (get_current_time() - time)
    move_world_in_time(N)
    draw_new_world()
}
Basically it's a loop where you have a world with state (eg position and direction of the person, place of all objects, etc)
First you check whether the user did anything, and you update the world state (eg change direction to "up" if he pushed the 'up' arrow key).
Then you wait until the next frame-time arrives (N is about 20-30msec, for example, but ymmv).
After waiting, the time has increased, so the world needs to be updated, man moved a bit, amount of candle light decreased a bit, etc.
If any of the update is also visible for the user, you need to draw the world again at the display.

Graphics are drawn in layers, back layers first, and then the sprites further to the front are drawn over them.
Walking, etc is mostly just an illusion. You draw a slightly different sprite (legs position moved a bit) at a slightly different position in the world, making it look like he made a step.

_________________
My project: Messing about in FreeRCT, dev blog, and IRC #freerct at oftc.net


Top
 Profile  
 
PostPosted: Sat Feb 22, 2014 4:57 pm 
Rookie

Joined: Sat Feb 22, 2014 3:00 pm
Posts: 2
Thanks for the hints. Then I will try to understand what kind of library is more useful for my idea.
I haven't understand well what you mean for "just an illusion" about walking. Is not possible to do a simple animation like Flash or something similar?

Thanks


Top
 Profile  
 
PostPosted: Sat Feb 22, 2014 6:40 pm 
Grand Optimizer

Joined: Sun Oct 16, 2011 3:09 pm
Posts: 366
Location: Here (where else?)
My point was that nothing really walks, it's just a serie of images that are slightly different, eg wrt the position of the legs, that are plotted at slightly different positions. If you plot those at a rate > 10-15 per second, it looks to us like walking.

Don't understand what you mean with the flash reference. I never programmed flash. If you mean a system where you can start an animation, and it runs by itself, I guess such libraries exist as well. Obviously, they just do what I described above, the only difference is that you don't have to program it yourself.
Since I prefer the more low-level libraries that give you full control, I am afraid I cannot help you there.

_________________
My project: Messing about in FreeRCT, dev blog, and IRC #freerct at oftc.net


Top
 Profile  
 
PostPosted: Sat Feb 22, 2014 8:11 pm 
Bytewise
User avatar

Joined: Sun Aug 05, 2012 9:32 pm
Posts: 268
Welcome and have a good day sir.

Quote:
Is not possible to do a simple animation like Flash or something similar?


Let me make things clear here, programming a 2D animation can be done in two ways (which one you chose is all upon you and your desired outcome)

1. A frame based 2D animation which works exactly the same as flash animations, you have a bunch of frames and you simply move along the timeline (or spritesheet in programming) and by doing this at the speed of about 10 frames per second (10fps) you get the illusion of something moving fluently (what Alberth said)
SpriteSheet example from google
as you can see in the example I linked above, spritesheet are rows of sprite frames. If you worked with flash you probably understand what i am talking about right now. But since in programming you are not able to store different animations in "objects" like in Flash, we need to store these in plain image format in a spritesheet and tell the game (program) which frames to read for different actions, for example frame 0 - 21 in the example image is Idle animation and all those other sprites are Running animation. So in your game you would do something like If (Player is not doing anything){playCharacterAnimation(From frame 0 to frame 21)} else if (Player is pressing a movement key) {playCharacterAnimation(From frame 22 to End)}.
Thats the basic idea behind spriteSheet animations anyway.

Of course you would first need to write a function for playCharacterAnimation(x,y); because that is usually not a standard function of libraries like OpenGL/DirectX. basicaly you will tell OpenGl to load a rectangular portion of the SpriteSheet and draw it on the screen -> Frame+1 -> Repeat for all the frames you need to draw for the animation

anyway, i hope i didn't confuse you too much, so ask if you need me to explain something again or if you need an pseudo code example of something


Aynway, i mentioned two ways of drawing animations so just to end this, you can also create images for different limbs of the character (leftHand,rightHand,Body,head,LeftLeg,RightLef... or whatever else you need to animation) and connect all of those with a code. Then all movement is managed from the game itself, so when the player is going to move, you might want to do a small rotation of both arms left and right, and so on...

Ragnarok Battle Offline (RBO) is a good example of such character creation:Here
You can look it up on youtube if you want to see the system in action. it basically gives you more controll over different moves and animations, and theres less work on graphics, but much more programming work

I apologize for all mistakes I made in the above text as my little sister kept talking to me about MLP and Pokemons and stuff and I just could not concentrate on this post at all X_x geez...

_________________
Did you ever wonder, how time works?


Top
 Profile  
 
PostPosted: Sun Feb 23, 2014 4:46 pm 
Grand Optimizer

Joined: Sun Oct 16, 2011 3:09 pm
Posts: 366
Location: Here (where else?)
http://lazyfoo.net/tutorials/SDL/14_ani ... /index.php shows it quite nicely.

_________________
My project: Messing about in FreeRCT, dev blog, and IRC #freerct at oftc.net


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

Powered by phpBB® Forum Software © phpBB Group