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.

2D All the way! / [Need help] Numeric type to char and printing

Author
Message
Em3rgency
12
Years of Service
User Offline
Joined: 10th Jun 2011
Location:
Posted: 10th Jun 2011 08:33
Just got Dark GDK, skimmed the documentation, everything looks great! Created a new 2D game project, fiddled around with the example and ran into a snag.

If you're not aware of the example, its just a bunch of falling animated, randomly placed, sprites.

Now, what I'm trying to do is add a counter on screen that shows how many rocks have fallen. Here's the code inside the main loop.



The screen prints "0 rocks have fallen!". Also it crashes upon exiting. What am I doing wrong?
Em3rgency
12
Years of Service
User Offline
Joined: 10th Jun 2011
Location:
Posted: 10th Jun 2011 12:05
It works! Almost... It now counts correctly, and even displays the text. But it crashes each time on exit. What am I missing? Something I have to delete before closing?



The small change I made was move the rocks++ counter into the loop that resets them once they fall down the bottom of the screen. This shouldn't have changed anything except WHAT the counter counts.

HOWEVER, before it would always say 0, now it counts correctly. I changed the code back to its original state, and it continued to count the loops correctly. I have no idea why the EXACT same code would give me 0 before.

Any ideas about the crashing problem?
Em3rgency
12
Years of Service
User Offline
Joined: 10th Jun 2011
Location:
Posted: 10th Jun 2011 12:10
PROBLEM SOLVED!

Sorry for the triple post. There is no "Edit" button. Weird forum.

My idiotic mistake was I commented out the code that creates the backdrop image so that I could see the text I create behind it. I did not, however, comment out the deleting of that image.

My program would crash because upon exit it would try to delete a non-existent image.

Thanks everyone for potentially helping me solve this
Grog Grueslayer
Valued Member
18
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 11th Jun 2011 09:53
Quote: "Sorry for the triple post. There is no "Edit" button. Weird forum."


It's because you're still on post approval since you've just joined. Most of us call it a "Newbie Slap". Eventually you'll get out of it and you'll be able to edit your messages.

By the way it's great that you solved your own problem and welcome to the Darkbasic forums.

Login to post a reply

Server time is: 2024-02-29 09:41:23
Your offset time is: 2024-02-29 09:41:23