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 / Help with just about the most basic thing you can imagine.. Trying to make a simple (first) game and I have ideas..

Author
Message
Robbee101
18
Years of Service
User Offline
Joined: 28th Jun 2006
Location: England
Posted: 15th Jun 2007 22:32
Hi there,

Well I'll start by pointing out I am totally new to all this, if you check my post history (if that's possible?) you might notice I posted one a while back asking about the Darkbasic Language as a whole and what it's good for.

However, it has taken all this time to actually get going with it, but I assure you I truly am doing it now, me and my mate Will; and having a mate doing it obviously helps.

----------------

Why I am making this post:

We have got to the stage of understanding the basic concept of things like Print and Text, Strings and variables and a few other random things from looking around.

We have put this basic knowledge into hopefully making a game where by you move a player around the screen and it collects rings (like sonic type thing)

We have the player moving and we worked out how to texture it and a background, the next thing is having an object it collects and add the number of objects collected to a variable- correct?
Only problem I can see with doing that is how to get it to understand that when the player collides with an object then the object dissapears and add + 1 to the variable, any ideas?

Note: we haven't included the textures for the background and the player but the commands for texturing are still there to show we understand it.

Obviously we'd like to make the game more elaborate than that and any simple ideas and methods of doing so would be greatly appreciated!

We have been reading through some of the stickies on tutorials and such and continue to do so but I think making this is a good way of learning too!

Thanks for any help and try not to laugh too much at our source code!

Rob.

Attachments

Login to view attachments
chafari
Valued Member
18
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 15th Jun 2007 23:49
at start....you could first send your dba ...

oh my god
qwe
21
Years of Service
User Offline
Joined: 3rd Sep 2003
Location: place
Posted: 16th Jun 2007 10:14 Edited at: 16th Jun 2007 10:17
treat the player as a circle on the screen (posX posY Radius) and each ring as a circle on the screen (with pos X&Y and Radius)

write a function to call to return a value of 1 if two specified circles are colliding



should be easy enough to implement. you have to keep each ring to grab in an array, and do multiple such checks per loop. thus to optimize speed, you'd want to square 'both sides of the equation' so that you don't need to use SQRT()

the following function would perform the same way yet be faster:
Robbee101
18
Years of Service
User Offline
Joined: 28th Jun 2006
Location: England
Posted: 16th Jun 2007 17:31
Ok I think I attached the file

Attachments

Login to view attachments
Robbee101
18
Years of Service
User Offline
Joined: 28th Jun 2006
Location: England
Posted: 17th Jun 2007 01:45


Heres the code, from this you can probably tell just how new I am to all of this and anything new I learn now is just great!
Robbee101
18
Years of Service
User Offline
Joined: 28th Jun 2006
Location: England
Posted: 17th Jun 2007 23:13
Thanks "Qwe"
I truly appreciate your help, but I don't think I put emphasis on just how much of a newb I am!

Maybe I was jumping ahead a bit by having a collision.

Thing is I am used to using "The Games factory" and "Multimedia fusion" that is my only experience of game design and with that tool a collision was a pretty basic thing.

"If X object collides with Y object then STOP X object"
I guess with DarkBASIC you have to tell it WHAT a collision is affectively?


Is there any way to make things stop when they hit into something or that sort of thing?



Thanks again.
Rob
HeavyAmp
17
Years of Service
User Offline
Joined: 25th Oct 2006
Location: Castle in the Sky!
Posted: 18th Jun 2007 02:03 Edited at: 18th Jun 2007 02:08
Try this. I left you a bit of coding to do in the part where it collides.



Edit: To add 1 to a variable you can either use Variable=variable+1
or you can use inc variable

In theory, there is no difference between theory and practice. But, in practice, there is.
Robbee101
18
Years of Service
User Offline
Joined: 28th Jun 2006
Location: England
Posted: 18th Jun 2007 18:15
Hi there,

We gave it a go and came up with the following:




It messes up presumably because the Delete object command is in the loop and keeps trying to delete it when it's already deleted.
However, that doesn't mean I know how to fix it!

Thanks for your help so far, I've learnt something already.
Cheers,
Rob.
HeavyAmp
17
Years of Service
User Offline
Joined: 25th Oct 2006
Location: Castle in the Sky!
Posted: 19th Jun 2007 00:36 Edited at: 19th Jun 2007 00:40
The bit about it deleting objects continuously was my bad. I should have put something in there to avoid it. Anyway here is the code which now only deletes the object once.



You might want to look up arrays so you can easily create multiple rings to collect. If you don't understand any of the code ive added just ask.

In theory, there is no difference between theory and practice. But, in practice, there is.
Robbee101
18
Years of Service
User Offline
Joined: 28th Jun 2006
Location: England
Posted: 19th Jun 2007 17:12
Hey there,

Well we would first like to say thanks for your help so far!

What we don't understand about the code are a couple of commands and such but we've read up about "#Constant" and can just about figure that out.

What would be good is if you could explain briefly step by step what the code is doing

particularly this bit:



Thanks,
Rob.
HeavyAmp
17
Years of Service
User Offline
Joined: 25th Oct 2006
Location: Castle in the Sky!
Posted: 19th Jun 2007 19:48 Edited at: 19th Jun 2007 19:52
Dont be too stumped by the word boolean. It is just a data type like an Integer or a String. A boolean can only have two modes. 0 being False and 1 Being True. So if you need a variable that tells you if something is there or not there, Is correct or not correct etc try using a boolean.

In this example we needed a Boolean to tell us If object 1 would collide with object 3. And we also needed a Boolean called Object3 to tell us if the object has been deleted or If it hasn't.

So what is happening In the code is as soon as the
Collide = OBJECT COLLISION(1,3) command detects that object 1 has collided with object 3 then it will make Collide=1 which sets it to True.

Now that we know our objects have collided we want to do delete our ring. So we go and do that and we are all happy. But come the next running of our loop we check If object 1 and 3 have collided again. ERROR: there is no object 3! Thats what was happening In the first lot of code that we done.

With the addition of our Object3 boolean Its set to NotDeleted until it detects our first collision. Then when we go to the code
where we delete the object 3 we also set our object3 boolean to deleted. So when we come the next loop it wont run our check collision command or our delete object command again because they only work if Object3=NotDeleted.

I did the best I could explaining this. But If you are still stuck keep on asking and ill try my best to answer you.

In theory, there is no difference between theory and practice. But, in practice, there is.

Login to post a reply

Server time is: 2024-09-27 01:20:40
Your offset time is: 2024-09-27 01:20:40