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 / Collisions

Author
Message
Nathan C
14
Years of Service
User Offline
Joined: 26th Jan 2010
Location:
Posted: 1st Jun 2010 08:18
ok, i am making a zelda game right now. My problem is Collisions. I've looked through the forums and i can't find anything that works.

Ok, what i want is to have link walk into a tree an be pushed back. I have tried several methods to do this and still no success. What usually happens is link walks through half of the tree and then gets pushed back.

Can anyone show me exactly how to do this?


haliop
User Banned
Posted: 1st Jun 2010 09:14 Edited at: 1st Jun 2010 09:15
where is your current coliision or did you delete it?
ok , for a 2D top view like Zelda game collision isnt that hard.
check this out


so you can create up ,down,right the same way just turning the + to a - on the left and up , down will be about the same.

beside that , why dont you use one Animated Sprite that holds all of link Movement? you use a lot of uneded code which will just make your cpu or gpu work harder , you probably wont see it cause its a small aplication but it will run slower then it should.
Nathan C
14
Years of Service
User Offline
Joined: 26th Jan 2010
Location:
Posted: 2nd Jun 2010 00:53 Edited at: 2nd Jun 2010 00:53
i am getting errors with the code you supplied me.

Poof Master
14
Years of Service
User Offline
Joined: 14th Jan 2010
Location:
Posted: 2nd Jun 2010 01:15 Edited at: 2nd Jun 2010 01:20
from what I see it's because you are missing two parenthesis should be this:



just remember when you get an error like this check the parenthesis especially with such a big if check.

Hope that helps.

Edit:

Also for your game you might want to check out a simple physics engine. For me I am using box 2d to do all of my collision. I could help you get a simple static box that collides with a rigid box if you want.
Nathan C
14
Years of Service
User Offline
Joined: 26th Jan 2010
Location:
Posted: 2nd Jun 2010 02:45
thank you, but im still able to walk through the tree until i let go of the 'D' key.

where can i find the box 2d engine?
Poof Master
14
Years of Service
User Offline
Joined: 14th Jan 2010
Location:
Posted: 2nd Jun 2010 03:11
This is the site:

http://www.box2d.org/

If you read some of the documentation and decide that you want to try it let me know and I can help you set up some basic collision.
Nathan C
14
Years of Service
User Offline
Joined: 26th Jan 2010
Location:
Posted: 2nd Jun 2010 03:38
How do you install it, i get a folder with a bunch of samples
Poof Master
14
Years of Service
User Offline
Joined: 14th Jan 2010
Location:
Posted: 2nd Jun 2010 03:59 Edited at: 2nd Jun 2010 04:03
Okay well I am still using the older box2d and really there isn't to much different so if you don't mind using the older one these are the directions for setting up the old one.

I tried implementing this a few months ago and I think Techlord explained it pretty well here is his directions if you get stuck let me know and I can try and help you


1. Download the Box2D zip.

2. Build the library in Release mode to generate box2d.lib. If you build in Debug mode you may get linker errors looking for missing debug libs when you build your project.

3. After successfully building the lib, You add the box2d.lib and box2d.h to your Project:
Project Properties -> Linker -> Input -> Additional Dependencies -> box2d.lib
Project Properties -> C/C++ -> General -> Additional Include Directories -> {Where you placed the Box2D Include and Source Folders & Files}

Now to test if it worked in your main.cpp or wherever your adding all your include files add

#include "Box2D.h"

If you don't get errors with this then you are ready to start putting in the physics objects and when you get to this point let me know so I can show you how to setup some objects to collide with.
Nathan C
14
Years of Service
User Offline
Joined: 26th Jan 2010
Location:
Posted: 2nd Jun 2010 04:23
I ran the the file and it overwrote my game. I try to recover it and it is giving me a bunch errors on lines that dont exist.
Poof Master
14
Years of Service
User Offline
Joined: 14th Jan 2010
Location:
Posted: 2nd Jun 2010 04:31
Well first off did you press Rebuild or did you try and run box2d?

All you want to do is rebuild it so you can get the box2D.lib file so you can put that in your project. If you run it you will get linker errors. Just try rebuilding it.
Nathan C
14
Years of Service
User Offline
Joined: 26th Jan 2010
Location:
Posted: 2nd Jun 2010 04:34
Ill just create a new project with the source and media files
Poof Master
14
Years of Service
User Offline
Joined: 14th Jan 2010
Location:
Posted: 2nd Jun 2010 04:41
Yeah try it with a new project I am going to try it to because I am still trying to remember how I got it to work with my project
Nathan C
14
Years of Service
User Offline
Joined: 26th Jan 2010
Location:
Posted: 2nd Jun 2010 04:58
i cant get this to work.. i try to build the box2d thing and get an access denied error
Poof Master
14
Years of Service
User Offline
Joined: 14th Jan 2010
Location:
Posted: 2nd Jun 2010 05:02 Edited at: 2nd Jun 2010 05:03
Okay I am going to start this from scratch and then I will post a quick tutorial a little later. I am at school right now so just give me a little bit of time.
Poof Master
14
Years of Service
User Offline
Joined: 14th Jan 2010
Location:
Posted: 2nd Jun 2010 05:28
Also what compiler are you using. Visual studio 2008,2005, Express edition?
Nathan C
14
Years of Service
User Offline
Joined: 26th Jan 2010
Location:
Posted: 2nd Jun 2010 05:37 Edited at: 2nd Jun 2010 05:39
Visual studio 2008 Express Edition
Poof Master
14
Years of Service
User Offline
Joined: 14th Jan 2010
Location:
Posted: 2nd Jun 2010 05:56
Cool then what I am writing up right now should work fine but I will test it with the express edition before I post it.
Poof Master
14
Years of Service
User Offline
Joined: 14th Jan 2010
Location:
Posted: 2nd Jun 2010 06:46
Okay here is how I got it to setup I would suggest just starting a new project like how I do in this tutorial and then put it into your project from there.

also I'm not at home right now so I couldn't test it with express edition but it shouldn't matter anyway.

Let me know if something doesn't make since or if it doesn't work

Good luck

1. First download box2d here http://code.google.com/p/box2d/downloads/list
2. Now for this example I am using Visual Studio 2008 so go into File->Open->Projects and solution
3. Now where ever you have the box2d file go to Box2D->Build->VC8 Now you want to select the Box2D project solution.

4. Now that you have the project open you will see all those projects that were in that folder. Now right below “Window” and “Help” you will see a Green arrow and to the right of that there is a Drop box that has the word “Debug”. Change that so it say’s “Release” . After you do that go to Build->Rebuild Solution. Now it should build with no errors and if this works then now we have made our box2d.lib file that we need for our Dark GDK project.
5. Just to make sure it compiled right go into Box2D->Library in there there should be a file called box2d.lib if that is in there then we are ready to move on to the next step
6. Now we are going to leave the box2d file alone for right now and go make a project for Dark GDK and set that up so we can use box2d. So what I did to make a quick new project for dark GDK is I went C:\Program Files \The Game Creators\Dark GDK\Tutorials In there there’s a folder called Getting Started. Copy that into C:\Documents and Settings\ My Documents\Visual Studio 2008\Projects. Now you don’t have to do this but I would recommend it just so you understand how to set everything up and then go and setup your files correctly for your current project. Now I went and made sure that I took everything out of that project so it looks like this


7. Okay so the first thing you are going to do is make sure that your project is using the right directories. So go to Tools->Options That will bring up an options menu. Extend the “Project and Solutions” and go to VC++ Directories. On the right side under “Show Directories For” Click the Drop down arrow and go to “Include Files” Now you want to click the folder right below that and browse to C:\Program Files\The Game Creators\Dark GDK\Include Now this is all in the manual for Dark GDk but it is important to make sure that your project is setup like this to. Anyway you need to do this for DirectX as well so click the folder again and browse to C:\Program Files (x86)\Microsoft DirectX SDK (August 2007)\Include. Now when you are done wiuth this you need to change the “Show Directories For” to Libaray files. Do exactly the same the thing you did for the include files but instead of adding the include files do the library files that are in there so they should look like this C:\Program Files (x86)\The Game Creators\Dark GDK\Lib\vs9 and for DirectXC:\Program Files (x86)\Microsoft DirectX SDK (August 2007)\Lib\x86.
8. Okay so now we are going to add box2d to our project. So first we are going to add the lib file that we created when we compiled box2d. So go back into the box2d folder and in Box2D->Library grab the lib file. And copy that to where your project is for its My Documents\Visual Studio 2008\Projects\Getting Started\Getting Started
9. Now go back into the box2d file and grab these two folders “Include” “Source” copy those two folders into your project.

10. Now go back into your project and go to Project Properties -> Linker -> Input -> Additional Dependencies Now type in box2d.lib

11.Now go to Project Properties -> C/C++ -> General -> Additional Include Now just add two new folder paths to where we copied those two folders looks like this for me My Documents\Visual Studio 2008\Projects\Getting Started\Getting Started\Source and then for the other one My Documents\Visual Studio 2008\Projects\Getting Started\Getting Started\Include

11. Now click OK and at the top of your project add #include "Box2D.h" Re build the solution and if it rebuilds without errors then you are ready to start adding physics objects to your game
Nathan C
14
Years of Service
User Offline
Joined: 26th Jan 2010
Location:
Posted: 2nd Jun 2010 08:14 Edited at: 2nd Jun 2010 08:15
0 errors, thanks!
Poof Master
14
Years of Service
User Offline
Joined: 14th Jan 2010
Location:
Posted: 2nd Jun 2010 08:59
Awesome! a good start to learning how box2d works is here:
http://www.box2d.org/manual.html

Now if you read through Chapter 2 Hello Box2D It kind of explains how it works line by line. If you respond back to this tonight I could give you a quick example of a static box and rigid box colliding if not I will probably have time tomorrow at like 12 or 1 pacific time. If anything I am going to post another tutorial on how to do it. I have been meaning to write these for awhile so any feed back on them will greatly be appreciated
helpfull programmer
15
Years of Service
User Offline
Joined: 30th Jul 2009
Location:
Posted: 18th Sep 2010 15:15
You Legend!
I have never called anyone that on the internet so far but I thought that comment was worthy of it. Thank you very much for taking the time to write that all out!

Happy-programming
from Helpfullprogrammer.

Login to post a reply

Server time is: 2024-11-19 18:24:53
Your offset time is: 2024-11-19 18:24:53