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 / Help - 2D GDK Programming Help

Author
Message
Xraysoapsuds
15
Years of Service
User Offline
Joined: 24th May 2009
Location:
Posted: 24th May 2009 22:13
Hey, i just wanted to see some answers to a few questions i have.

Just as a spare time hobby i do some casual programming, and i picked up the GDK a few days ago. I started a 2D game with it, but have some issues;

- How do i get the window to be centered on a sprite (player image) as it moves around a map (also a sprite)in a pokemon style fasion?

- Is there any easy way to display variables such as Health and such on screen without using number/latter png's ? **(Note this is important for x/y co-ords)**

- To keep the player contained within certain regions of a map, i assumed that creating a PNG of the map with the allowed areas as transparent, this way i could use the dbSpriteCollision function to disallow players access to mountains / trees and such, but have had no success. Any info or tips greatly appreciated.

Any help is very much appreciated, still working on the game but these are a few key issues i seem to be having trouble with.

On a final note, does anyone have a good tutorial for dbTimer ? I wanted to use an AI style wait timer, so the NPC waits in a location for a dbRnd(int) amount of time... Couldn't quite figure it out.

Cheers again,

Xray.
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 27th May 2009 20:23
Quote: "How do i get the window to be centered on a sprite"

You don't. If using sprites, then you need to reposition everything around your central sprite - if you want to move left by 'x' units, you'd move everything else right instead.

Alternatively, you can use the 3D commands with planes instead of sprites and move the camera.

Quote: "Is there any easy way to display variables such as Health and such on screen"

dbPrint - there are several versions of this function. Take a look at the core header file for specifics.

Quote: "To keep the player contained within certain regions of a map, i assumed that creating a PNG of the map with the allowed areas as transparent"

I'm sorry to say that won't work. DBPro sprites do not use transparency to determine collision - it basically uses a box the size of your images and checks to see if they overlap. I'd use a simple 2D array to hold details of which areas can be moved over (probably at a much lower resolution than the image you'd use).

Xraysoapsuds
15
Years of Service
User Offline
Joined: 24th May 2009
Location:
Posted: 28th May 2009 00:42
Thanks for tehe help, i thought about moving everything else just wanted to make sure, and cheers for the heads up on dbPrint.

However i would like to query what you meant by a 2D array? I guessed transparancy didnt work as it took an overall image size, but im not too sure on 2D arrays :S

Thanks again for all the help,

xray

Login to post a reply

Server time is: 2024-11-25 10:28:17
Your offset time is: 2024-11-25 10:28:17