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 / Centering camera on sprite?

Author
Message
xbandages
14
Years of Service
User Offline
Joined: 30th Mar 2010
Location: Michigan
Posted: 7th Apr 2010 06:21
I'm going through the darkGDK library and can't seem to figure this out....my goal is to follow the sprite around (sprite will be at center of screen the whole time).
Mireben
16
Years of Service
User Offline
Joined: 5th Aug 2008
Location:
Posted: 7th Apr 2010 08:49
Please have a look at my answer in this thread:

http://forum.thegamecreators.com/?m=forum_view&t=167422&b=22
xbandages
14
Years of Service
User Offline
Joined: 30th Mar 2010
Location: Michigan
Posted: 7th Apr 2010 17:10 Edited at: 7th Apr 2010 18:01
EDIT: I think I understand now. So I store the level as an array, and depending on where my characters x and y position is, I would draw the level around that location. And if there is more than one player, its like saying player 1 is at 2dArray[x,y] and player 2 is at 2dArrya[x+20][y-35]. That way you can see each other in game because their sprite is kinda like a pointer to that location in an array.

Well, i will not have time to do this for about a month then....finals are coming up
Serial Velocity
16
Years of Service
User Offline
Joined: 24th Aug 2008
Location:
Posted: 7th Apr 2010 19:01 Edited at: 7th Apr 2010 19:02
One way you could do it is simply create a std::list of every sprite currently active in your game. Then whenever you want to render while tracking the sprite, iterate through your list and subtract the position of your sprite your tracking and add the dimensions of the screen divided by 2 to each sprites position, then it will centre on the sprite you're tracking. Make sure you reset the position of each sprite by doing the inverse after rendering otherwise it will screw up after 1 frame.

Login to post a reply

Server time is: 2024-10-02 03:23:59
Your offset time is: 2024-10-02 03:23:59