Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / A little help needed

Author
Message
Soulstealer
15
Years of Service
User Offline
Joined: 5th Nov 2009
Location: Ireland
Posted: 5th Nov 2009 14:44
Hi Guys, Im totally new to programming in any language so please dont flame me. Im trying to make a very basic 2d platform game ive made a simple sprite in ms paint i can get it to load onto the screen but i was wondering would someone show me a piece of code that i can learn form, all i want is to be able to move the sprite left and right.
cleonjones
15
Years of Service
User Offline
Joined: 24th Oct 2009
Location:
Posted: 5th Nov 2009 15:59 Edited at: 5th Nov 2009 16:01
Well, you can use the dbSprite() function. Put it in the while(LoopGDK()) section of your code. To move the sprite left and right on the screen you need to change the X value, and to move the sprite up and down you have to change the Y value.

The best way to do that is to make an int value to hold the X and Y coordinates of the sprite, this needs to go inside the void DarkGDK(void) section:


After that you need to actually update the sprites position, if not it would draw the sprite at the same area on the screen. So just use dbSprite():


Then you would have to subtract the X value to move left and add to it to move right. Subtract from the Y value to move up, add to go down. So you need a keypress function to actually do that. It should also go in the while(loopGDK()) section.


?
Soulstealer
15
Years of Service
User Offline
Joined: 5th Nov 2009
Location: Ireland
Posted: 5th Nov 2009 23:54
Thanks very much cleonjones. Now i just need to figure out how to stop the sprite when it moves into a wall. Im sorry but im totally new to programming
Ovan35
15
Years of Service
User Offline
Joined: 25th Sep 2009
Location:
Posted: 6th Nov 2009 17:13 Edited at: 6th Nov 2009 17:16
I could give you code for this one but I'm going to point you to a site that helped out alot.. At least with the basics anyway.

http://www.youtube.com/helpfullprogrammer

has plenty of how tos there specifically centering around what it seems you want to do make a platformer.And he explains it pretty well for the beginner.

Good Luck on your project

It was such a small seed... I needed to find out what was growing inside. And there was only one way to find out. So I decided to raise it.

Soulstealer
15
Years of Service
User Offline
Joined: 5th Nov 2009
Location: Ireland
Posted: 6th Nov 2009 18:53
Wow this is exactly what im looking for. Thanks for your help Ovan35

Login to post a reply

Server time is: 2024-11-20 11:32:14
Your offset time is: 2024-11-20 11:32:14