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.

Newcomers DBPro Corner / Asteroids movement

Author
Message
SamVickery
13
Years of Service
User Offline
Joined: 13th Oct 2011
Location:
Posted: 11th Nov 2011 19:09
I am in the proccess of making a space game and im trying to sort out the movement of the spaceship

This is what I have so far. As you can see it works but is slightly glitchy and I was just wandering if there is an easier way to do this that is more effective.

Any help would be great and I know how good you guys are usually are

Sam Vickery

Hodgey
15
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 12th Nov 2011 05:44
I wrote this up a while ago but I think it's what you're after or something similar. You should be able to adjust it to achieve the effects you want.

Ok, it doesn't want to upload so here's the code:


and the sprite image is attached.

Attachments

Login to view attachments
Darkzombies
13
Years of Service
User Offline
Joined: 25th Dec 2010
Location: In multiple tabs, most likely youtube.
Posted: 12th Nov 2011 06:40
Its nice and all, but if you plan on using it for something big, variables are a waste of time, use types.

EG.



-------------------------------------------------------------
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 12th Nov 2011 11:38
Quote: "variables are a waste of time, use types."


Technically the way you wrote it "player" is still a variable. We usually refer to them as a User Defined Type or UDT for short.

Darkzombies
13
Years of Service
User Offline
Joined: 25th Dec 2010
Location: In multiple tabs, most likely youtube.
Posted: 12th Nov 2011 18:30
True, but I was just making a point, keeping track of all those individual variables is much harder.

-------------------------------------------------------------
Hodgey
15
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 12th Nov 2011 23:16
Quote: "True, but I was just making a point, keeping track of all those individual variables is much harder."

Why? If you create and use a type for only 1 object then the only difference is that you've got a . instead of a _. But I understand the point you're trying to get across. Using UDTs for the asteroids would be a smart choice however.

SamVickery
13
Years of Service
User Offline
Joined: 13th Oct 2011
Location:
Posted: 13th Nov 2011 12:38
Hey guys thanks for the help.
I managed to get it working the way I wanted to.

Just so people know and if people want to use it here is the code I got to in the end.

SamVickery
13
Years of Service
User Offline
Joined: 13th Oct 2011
Location:
Posted: 13th Nov 2011 12:49
A quick question, with the types that you showed me how do I declare an array in that type?
nonZero
13
Years of Service
User Offline
Joined: 10th Jul 2011
Location: Dark Empire HQ, Otherworld, Silent Hill
Posted: 13th Nov 2011 20:21
Quote: " A quick question, with the types that you showed me how do I declare an array in that type? "


Are you meaning this?



Darkzombies
13
Years of Service
User Offline
Joined: 25th Dec 2010
Location: In multiple tabs, most likely youtube.
Posted: 14th Nov 2011 01:15
well if you mean



or something, it won't work, types don't allow arrays in them. They're are ways around it though.

-------------------------------------------------------------
Hodgey
15
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 14th Nov 2011 02:35
Like DarkZombies said, you can't declare arrays inside a type but I have a work around. I create an external array and then have a 'reference' variable inside the type. This thread explains it pretty well. You'll have to scroll down a bit and it is AppGameKit but the concept is portable to DBPro.

Login to post a reply

Server time is: 2024-11-22 11:41:35
Your offset time is: 2024-11-22 11:41:35