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 / Sudden strange crash from pressing keys!!!

Author
Message
CDragon
14
Years of Service
User Offline
Joined: 16th Sep 2011
Location:
Posted: 26th Feb 2013 23:05
So, first of all. This is my first project. I have gotten pretty far putting together a decent action RPG engine but suddenly and inexplicably, pressing "UP","RIGHT"(Move UP/RIGHT), or "Z" (LOCK ON NEAREST ENEMY SPRITE) results in a crash with an error message displayed as if I messed up a DXS command ("Blah has stopped working unexpectedly..."). Then funny thing is, the program ran (relatively!) flawlessly until recently, actually right when I first tried loading User32.dll. Removing the code didn't solve the problem but that is the only change I can think of that I made right before this bug showed up. I am curious if this bug shows up when compiled on other peoples computers... Any ideas are more than welcome and thanks for any input on this!!!

To compile the code you need to at least have the AdvancedSprites Plugin and eXtends installed.

RAWWWR
luskos
19
Years of Service
User Offline
Joined: 28th Jun 2007
Location:
Posted: 27th Feb 2013 08:27
For me when i ran the game it was like this: Right and Up crash the game everytime unless i move somewhere Down,Left and press "z" then controls are good again, until something happend again when "z" is pressed and it crashes.

Coding is My Kung Fu!
And My Kung Fu is better than Yours!
CDragon
14
Years of Service
User Offline
Joined: 16th Sep 2011
Location:
Posted: 2nd Mar 2013 07:16
Well, I fixed the crash by reworking my depth scale and depth parameters while rendering. Mod sent me a response that outlined the details for handling sprite depth and their sprite depth scale attribute! He allowed me to post his response for the benefit of all, so enjoy

Quote: "
About the depth. I easily understand that the documentation I wrote was not really the clearest possible.

The depth scale allows you to set a number of usable layers for sprite renders. For example, if you need 3 layers, set the depth scale to 2 (zero based "index"), and use a depth of 0, 1 or 2 with any of the DXS DRAW command to determine what is rendered first. The use of any other depth than those 3 numbers won't display the sprite (a behavior that can be exploited in many ways).

The way to determine what is rendered first is quite easy : juste divide the depth by the scale. Zero is rendered first, one is rendered last. This is why two sprites with a same render depth but a different depth scale won't be rendered at the same time . Example : my first sprite has a depth scale of 5, the second one of 10. If I render the two sprites with the same depth of 1, the second sprite will be rendered first, 1 / 10 < 1 / 5.


In my opinion, the best way to deal with depth scale is to use constants (whose cpu cost is near zero), then work in a relative way.
Let's say you need for an RPG type game 3 layers for the map display (floor, objects under characters (bottom of walls, flowers...) and objects above characters (top of trees, houses, birds...), you can define something like this :

#constant LAYER_TOP 0
#constant LAYER_MIDDLE 1
#constant LAYER_BOTTOM 2

Use a constant to set the depth scale for all sprites :

#constant LAYERS 2

Then use these constants for renders :

dxs draw sprite spr, x, y, LAYER_XXX

If you realize you're needing more layers for interface, no problem, just change the constants and add one, you won't have to refactor the code :

#constant LAYER_INTERFACE 0

#constant LAYER_TOP 1
#constant LAYER_MIDDLE 2
#constant LAYER_BOTTOM 3

#constant LAYERS 3

Then, if you want to do something like a rotating menu, just adjust a bit the vales:

#constant LAYER_INTERFACE 0

// no use of layers 1 and 2

#constant LAYER_TOP 3
#constant LAYER_MIDDLE 4
#constant LAYER_BOTTOM 5

#constant LAYERS 5


And work relatively to draw your interface :

dxs draw sprite spr, x, y, LAYER_INTERFACE // layer 0 of interface
dxs draw sprite spr, x, y, LAYER_INTERFACE + 1 // layer 1 of interface
dxs draw sprite spr, x, y, LAYER_INTERFACE + 2 // layer 2 of interface

That way, you can add countless number of layers without needing to refactor your code.
"


Also, the current build of my engine is attached. There are a few bugs yet, but its coming along well I think... Everything is just a placeholder sprite more or less, but demonstrates some (really) basic ai and attack routines. Everything is experimental but I'm hopeful this will become an epic action rpg... Think Dark Souls/Legend of Zelda/Final Fantasy 7/X/Suikoden/32bit RPG style...

W,S,D,Shift,Ctrl,Space, and DKeys all do fun things!

RAWWWR

Login to post a reply

Server time is: 2026-07-07 02:39:17
Your offset time is: 2026-07-07 02:39:17