School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become an Expert!

Join 307,137 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,813 people online right now. Registration is fast and FREE... Join Now!




Dark GDK help

 

Dark GDK help, Collison

ZOMBIE!!!

31 Oct, 2009 - 07:24 AM
Post #1

New D.I.C Head
*

Joined: 28 Oct, 2009
Posts: 3

Hey this is my first post so bear with me. I downloaded Dark GDK a while ago and I have been making some "games". I put that into quotes because they are really just get the key, unlock a door, get the treasure. Anyway in these "games" for collision I do something like this:

CODE
  

//lets say 2 is my sprite and 3 is a wall. I move at a speed of 3

if(dbSpriteCollision(2,3) == 1)
          
  {
     dbRotateSprite(2,90);
     dbMoveSprite(2,-3);
     dbRotateSprite(2,0);
  }



Now there are a lot of problems with this. 1. Its time consuming. 2. When you do it this way you can only make the sprite collide with one side because all your doing is countering the movement of the sprite. So when you go to collide with the other side it will drag you through it. So to fix this problem I've had to make a left side, right side, top side, and bottom of each object I want to collide with. Is there a more efficient way of collision in Dark GDK?

thanks,
ZOMBIE!!!


User is offlineProfile CardPM
+Quote Post


TyVeryMuch

RE: Dark GDK Help

31 Oct, 2009 - 09:56 AM
Post #2

New D.I.C Head
Group Icon

Joined: 24 Mar, 2007
Posts: 33



Thanked: 2 times
Dream Kudos: 50
My Contributions
What about checking collision before doing the actual movement so you dont have to move the sprite back?
User is offlineProfile CardPM
+Quote Post

SixOfEleven

RE: Dark GDK Help

31 Oct, 2009 - 10:00 AM
Post #3

lives.ToCode();
Group Icon

Joined: 18 Oct, 2008
Posts: 3,066



Thanked: 171 times
Dream Kudos: 775
Expert In: C, C#, XNA, Game Programming, Programming Concepts

My Contributions
Off to Game Programming.
User is offlineProfile CardPM
+Quote Post

stayscrisp

RE: Dark GDK Help

31 Oct, 2009 - 11:59 AM
Post #4

Mouth->Insert(Foot);
Group Icon

Joined: 14 Feb, 2008
Posts: 1,404



Thanked: 53 times
Dream Kudos: 300
My Contributions
You should try to use some kind of bounding box checking collision, maybe dark GDK has this built in, if not it is not to hard to implement.

Here is an SDL C++ example, you could use it as a place to start and get the idea

http://lazyfoo.net/SDL_tutorials/lesson17/index.php

smile.gif
User is offlineProfile CardPM
+Quote Post

AGRAC393

RE: Dark GDK Help

31 Oct, 2009 - 12:05 PM
Post #5

D.I.C Head
**

Joined: 13 May, 2009
Posts: 234



Thanked: 2 times
My Contributions
Do you need help in 2d or 3d? I have the 3d code, but I haven't done anything in 2d with collision...
User is offlineProfile CardPM
+Quote Post

ZOMBIE!!!

RE: Dark GDK Help

1 Nov, 2009 - 04:32 PM
Post #6

New D.I.C Head
*

Joined: 28 Oct, 2009
Posts: 3

QUOTE(AGRAC393 @ 31 Oct, 2009 - 12:05 PM) *

Do you need help in 2d or 3d? I have the 3d code, but I haven't done anything in 2d with collision...


2d. Not quite good enough to do 3d yet.
User is offlineProfile CardPM
+Quote Post

hawksprite

RE: Dark GDK Help

1 Nov, 2009 - 07:18 PM
Post #7

New D.I.C Head
*

Joined: 11 Sep, 2009
Posts: 16

I'd recommend looking into Sparky's Collision System. It's really easy to use and powerful for Dark GDK Games.

http://forum.thegamecreators.com/?m=forum_...t=74762&b=5
User is offlineProfile CardPM
+Quote Post

ZOMBIE!!!

RE: Dark GDK Help

2 Nov, 2009 - 02:25 PM
Post #8

New D.I.C Head
*

Joined: 28 Oct, 2009
Posts: 3

A couple of new questions:

1. How do you scroll through a map in a 2d game? Like a side scroller.

2. Ive seen people who make 2d maps for games by using characters on the keyboard that the game exchanges for sprites. How do you do that?


thanks for the help,
ZOMBIE!!!
User is offlineProfile CardPM
+Quote Post

hawksprite

RE: Dark GDK Help

2 Nov, 2009 - 02:56 PM
Post #9

New D.I.C Head
*

Joined: 11 Sep, 2009
Posts: 16

QUOTE(ZOMBIE!!! @ 2 Nov, 2009 - 02:25 PM) *

A couple of new questions:

1. How do you scroll through a map in a 2d game? Like a side scroller.

2. Ive seen people who make 2d maps for games by using characters on the keyboard that the game exchanges for sprites. How do you do that?


thanks for the help,
ZOMBIE!!!


I use a system where the object moves depending on what button is pressed. I dont have my project files with me so i'll try to give an example by memory.

CODE

void userinput ()
{
char* szKey = dbInKey ( );

if ( strcmp(dbInKey(), "v") == 0 && vtimer < dbTimer() )
        {
                     //1 is the person
                    //2 is where it needs to go
                     dbPointObject(1,dbObjectPositionX(2),dbObjectPositionY(2));  // my memory is a little iffy on this line, it may not point it correctly
                     dbMoveObject(1,1f);
}

This should, when V is pressed, point your sprite 1 towards it's destination 2 and move it there.
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/21/09 03:11PM

Live Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month