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.

DarkBASIC Professional Discussion / More bugs with CarbonAde

Author
Message
Arivias2294
12
Years of Service
User Offline
Joined: 4th Nov 2013
Location:
Posted: 8th Nov 2013 19:13
In my custom CarbonAde game, the player rolls along collecting fruits and dodging cars

The game is suppose to end when the can's pressure goes over 100%

RED cubes(cars) on line 60 increase pressure
GREEN cubes(fruits) on line 61 increase points
BLUE cubes(power-ups) on line 62 decrease pressure and add points

The bug
When collecting a GREEN cube, it usually will cause the pressure to increase by up to 200%

After a bit of debugging, I've found that the bug might be in collision detection area(possibly on the RED cube part)
on line 60

Here's the main game-play loop


If you know what's wrong or have a solution please let me know.
Sasuke
20
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 8th Nov 2013 22:08
First things first, when programming always document and comment so that people looking at it will know what things are. When you have variable names like "tf_c" to us it's meaningless without proper documentation.

Secondly you have some function here which we don't know what they do or what results they produces, if you could let us know that would be a great help.

"Get in the Van!" - Van B
SamKM
17
Years of Service
User Offline
Joined: 25th May 2009
Location:
Posted: 9th Nov 2013 00:13
Hey,
I did have a look at the code... It'd be great if you could post us the g_cubetype() function, thanks! I'd say at first guess it might be a problem with the cube being identified as green (if g_cubetype(g_icount-10)=1 then g_score=g_score + 100) but then being accidentally recognized by the line under it as blue as well... I'm not sure what the function does, so I can't say for sure
Arivias2294
12
Years of Service
User Offline
Joined: 4th Nov 2013
Location:
Posted: 12th Nov 2013 18:04
hm... I guess I left some stuff out of the post

tf_c is the time counter variable(sync rate 60 : tf_c=tf_c+1 : print str$(tf_c/60+1))

g_cubetype() is actually an array(dim g_cubetype(19))
it is set for individual cubes in the cube creation loop

The game is based around the player switching between two lanes, and these two loops create cubes for their lane

g_l1t and g_l2t are the delay timers between possible cube spawns.
I didn't feel like multiplying the minimum time to get the exact value, so I added the lanetimer() function


Let me know if you need any more information on the game.
Derek Darkly
14
Years of Service
User Offline
Joined: 22nd Sep 2011
Location: Whats Our Vector, Victor?
Posted: 13th Nov 2013 17:13
Can you just post the whole code so we can run it?
Much easier to debug that way!


Also, you can use the INC/DEC commands to save you a bit of typing.

Instead of g_score=g_score + 100....
INC g_score,100

D.D.
Arivias2294
12
Years of Service
User Offline
Joined: 4th Nov 2013
Location:
Posted: 13th Nov 2013 18:00
Quote: "Can you just post the whole code so we can run it?
Much easier to debug that way!


Also, you can use the INC/DEC commands to save you a bit of typing.

Instead of g_score=g_score + 100....
INC g_score,100"


Sounds good to me.

IMPORTANT: I've found that this bug doesn't happen at random, but on all cubes in lane 2 - This bug appears to also increase g_score(I went from 0 to 1200)

I've also been adding a leader-board system to keep track of scores(this works fine, the only bug is still the lane-2 idontknowwhattocallit)

several possible bug locations are the hit detection(line 137) and the lane 2 cube creation(line 118)


Let me know if I've forgotten anything
Arivias2294
12
Years of Service
User Offline
Joined: 4th Nov 2013
Location:
Posted: 13th Nov 2013 19:06
Anyone here tired of answering silly carbonade questions? Good news and bad news.

The good news: The game template we're editing is due in a week, so just hang in there and it will be another year before the carbonade junk comes back.

The bad news: after we're done editing the carbonade game, we'll be starting to make games from scratch. I'm not worried about starting from nothing. I'm worried about the rest of the class.

For your sake, I hope that the teacher will limit questions on the forum
Libervurto
20
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 13th Nov 2013 20:50 Edited at: 13th Nov 2013 22:07
Please change all your variable names, they are meaningless.
It's good that you indent, and you do it correctly (apart from the "move to lane" parts that didn't need indenting), but why do you indent three spaces? Is this what your text editor does for a tab? It's not a real problem but just odd to me as the standard is usually four or two spaces.

Don't be afraid to use lots of whitespace, it really helps improve readability:


I've tidied up your code a bit. Nothing major changed.

What's up with this "g_" naming convention? I removed it because it's ugly and unnecessary. As personal preference I never use underscores as they don't always display clearly, I use camelCase instead, but that's a personal style choice.

A FOR loop declares the count variable at the starting value, you don't need to set it beforehand. A count variable is one time that you don't need a descriptive name, "i" will do just fine on its own.

In conditions you don't need to specify a truth value, conditions always test for truth. IE if spacekey()=1 ... is the same as if spacekey() ... Truth is any non-zero value, not just one.

Every program is divided into INPUT >> PROCESS >> OUTPUT sections, it helps to label these, as I've done, when you're learning. Obeying this structure keeps the logical order of your program easy to follow, ie you will get fewer bugs and unexpected behaviours.


Formerly OBese87.
Arivias2294
12
Years of Service
User Offline
Joined: 4th Nov 2013
Location:
Posted: 14th Nov 2013 19:24
Aha! Fixed!
I forgot to add an exit function into the second cube creation area

Login to post a reply

Server time is: 2026-07-07 07:35:02
Your offset time is: 2026-07-07 07:35:02