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 / Using floating point variables for arrays seems to crash the program.

Author
Message
Yakkers
13
Years of Service
User Offline
Joined: 15th Jul 2011
Location:
Posted: 16th Jul 2011 03:51
Hello folks, I've been using a tool called TNT Basic for a pretty long time now, and upon switching to Windows I've recently started using DBP. TNT was a lot simpler than this, so I've hit a few roadblocks.

My main issue is that when I try to make an array use real numbers, my program runs when I compile and run but it crashes as soon as I exit and tells me "(project name) has stopped working." Here's a snippet of the code in question:
initialization:

And in use:


Initializing the arrays with the # causes no problems, but as soon as I try to use them anywhere else in the program the crashes start.

I'm sorry if I'm overlooking something stupid, I tried researching the problem but didn't find anything. I had thought that maybe the syntax should be "dim eX#(Enum)" but doing that only causes the program to not run, without even highlighting the line.

Also while I'm here, is there any way I can check if a sprite is colliding with a box from a given set of coordinates? I'm practicing with a simple shmup and I like to set it up so the player's ship has a small hitbox in the center rather than bullets being able to hit the entire sprite.
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 16th Jul 2011 12:58
Looks like you've hit a compiler bug - the # should be placed directly against the array name, not after the brackets, and the compiler should have rejected your DIM commands.



Yakkers
13
Years of Service
User Offline
Joined: 15th Jul 2011
Location:
Posted: 17th Jul 2011 03:36
Well I had to save, quit and reopen the project to get it to compile, but that seemed to do it, so thank you. I'm not sure what was wrong with my compiler, but I'll keep it in mind that I should relaunch if it happens again.

Also another quick question, what is the effective difference between "sprite hit" and "sprite collision?" I first tried "sprite hit" and my shots were going though enemies from up close, and with sprite collision it worked as expected; so there must be a difference that's worth understanding.

And to answer my second question, I'm planning to just use a separate smaller sprite that's drawn under the player sprite for bullet collisions, and then keep using the main sprite's collision for picking up powerups and such.
Hodgey
15
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 17th Jul 2011 10:12
Quote: "Also another quick question, what is the effective difference between "sprite hit" and "sprite collision?""

Grog gave a pretty good description of this, read this thread and try out his code.

Yakkers
13
Years of Service
User Offline
Joined: 15th Jul 2011
Location:
Posted: 28th Jul 2011 01:02
Thank you, that makes a lot more sense now.
Another stupid question, how would I build and compile the project to be a standalone .exe? The one it makes when you do a standard run and compile needs all the media in the same folder, is there another way to build it into its own exe, or would I need to keep the finished project in a folder with all my graphics?
enderleit
17
Years of Service
User Offline
Joined: 30th May 2007
Location: Denmark
Posted: 29th Jul 2011 16:51 Edited at: 29th Jul 2011 16:52
You can set the project to be a MEDIA executable in the ProjectSettings tab (left side of screen, check the icons at the bottom). Then add all your media in the Media tab.

Here's a screenie:


PS. Sorry for the big pic!

Attachments

Login to view attachments

Login to post a reply

Server time is: 2024-11-24 02:35:32
Your offset time is: 2024-11-24 02:35:32