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 / Strange Runtime Error

Author
Message
Panther
20
Years of Service
User Offline
Joined: 15th May 2004
Location:
Posted: 20th May 2004 05:00 Edited at: 20th May 2004 05:04
Okay, I've been programming for about a year now in C++, and some of the .NET languages. I recently heard of DBPro, and downloaded the trial. I thought that a basic FPS was right at my skill level, so I began to write it, but before the skeleton code for the game was complete, I already encountered some strange error. As far as I know my code is fine, but I'm obviously doing something wrong. I have no idea what's going on, but immediately when line 86 (Sprite SPRITE_SPLASH, 0, 0, IMAGE_SPLASH) is executed, the program exits and a message box says "Runtime Error 301 - Sprite number must be greater than 0 at line 86". When I step through the program, it latches itself to that line and will never move past it. Can somebody please tell me what I'm doing wrong?

- "And the Word was made flesh, and dwelt among us, (and we beheld his glory, the glory as of the only begotten of the Father,) full of grace and truth." John 1:14 (KJV)
DeepBlue
21
Years of Service
User Offline
Joined: 17th May 2003
Location: A little box in the UK
Posted: 20th May 2004 09:14
The function is treating the variables SPRITE_SPLASH & IMAGE SPLASH as local to the function and therefore have values of 0.

You need to specifically declare the variables with the 'global' command i.e.

global SPRITE_SPLASH = 1

Alternatively pass the values to the function, or use a subroutine instead of a function.

Tested & all the rest works



Twynklet
Panther
20
Years of Service
User Offline
Joined: 15th May 2004
Location:
Posted: 21st May 2004 02:07
Thanks, Twynklet! I never thought of declaring the variables with a "global" modifier (I guess because I'm used to C++).

- "And the Word was made flesh, and dwelt among us, (and we beheld his glory, the glory as of the only begotten of the Father,) full of grace and truth." John 1:14 (KJV)

Login to post a reply

Server time is: 2024-11-26 18:35:07
Your offset time is: 2024-11-26 18:35:07