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 Discussion / The game hangs up

Author
Message
CheatCat
18
Years of Service
User Offline
Joined: 7th Mar 2007
Location: Sweden
Posted: 7th Mar 2007 18:41
What is wrong with this code?:



The game stopped when I try to run this code, but if I remove the repeat loop, the game works.

Please help me!
Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 8th Mar 2007 01:50
Hello CC,

It's hard to tell what you are going for, but I'm guessing a function to move a sprite.

A couple things are wrong. You need to include a SYNC within the repeat or the screen will never get redrawn and appear to hang.

When you call the DRAW_BALL(BALL) function, you are never defining what the variable BALL is so you are initially passin a zero to the function.

Once inside the function, you also don't do anything with the variable BALL. And at the end of the function, you have boll which I'm guessing is a typo, but that doesn't matter because it's value is never defined so it would be zero also. Here's a bit of a rewrite of what I though you might be going for. I left your array alone even though I don't use ball(3) or ball(4):



Enjoy your day.
Quisco DaLuse
18
Years of Service
User Offline
Joined: 3rd Feb 2007
Location: USA
Posted: 8th Mar 2007 06:08
The variables inside the function are local variables (they are not the same as those outside of the function). You could pass the variables to the function like this:


Since the arrays in the main program and in the function are not the same, I changed the names slightly to avoid confusion. If you wanted to, you could re-dimension the arrays within the function.

In your code, you really are not passing a variable to the function, nor are you returning one. i.e. you're not really taking advantage of the function capabilities. I would recommend until you get further along in understanding global versus local variables that you consider just using a subroutine instead of the function. Something like this:


I would suggest putting the sprite drawing at the end of your routine, instead of at the beginning, that way if you make changes to the variables it will show up in the drawn sprite.

The code really does not do anything with the ball, but I assume you'll put that in later.

Also, you need to declare a sync rate.

You idiots! You've captured their stunt doubles!
CheatCat
18
Years of Service
User Offline
Joined: 7th Mar 2007
Location: Sweden
Posted: 14th Mar 2007 21:29
Thanks for the answers! The game works when I place sync i the code!

Login to post a reply

Server time is: 2025-05-29 07:15:46
Your offset time is: 2025-05-29 07:15:46