Crashing, what did I do?
-
I started work on a new game, I'm mainly doing the graphics/tileset right now (even though I have the artistic talent of a blind mongoose)
The only code I have right now is very basic, it just loads a couple of sprites and my map then the only real code is just to move the player up/down/left right.Nothing else, no functions, no arrays, nothing much at all (see image)
But after leaving it running for 2 or so mins it crashes with the following message: "Stack overflow. Too many functions called, maximum memory for variables exceeded." (the error line number given is 26 which looks fine to me)
I'm puzzled by this. functions? I have none currently.
It kept doing this, so I quit fuze totally and reloaded it and tried again. Since then I'm not getting this message any more, what I am getting is fuze crashing and me getting a "software closed... blah blah" error as it drops me out of fuze.
My question (and I know I'm going to feel a fool when it's pointed out to me but) what have I done wrong exactly to make these crashes?
-
@SteveZX81 may not be much help but usually I put the sprite scales ect above main loop looks like I use a different method tbh
-
Me too normally but I'm being a cheat and using it to point the player in the right direction when they move left/right. Rather than having a left and right sprite.
-
@SteveZX81 iv been using daves trick for that
Think iv got that in my tails project, should be shared to friends -
I feel like I've had this problem before and it was fixed by having the c = controls(0) line before the loop as well. But it's a bit of a stab in the dark (my main method of coding, hahah!). Might be worth trying, but if it doesn't work I'm sure someone else will post the answer soon
-
I've not touched sprites myself yet, but it doesn't look like you're doing anything wrong. I've read some posts about memory leaks in Fuze that looked related to the
+=
and-=
operators (and then using the same variable again in the next line).This might lead nowhere (I've not run the code myself), but could you try changing the -= and += operators respectively to
helib.x = helib.x - 8
,helib.x = helib.x + 8
,helib.y = helib.y - 8
,helib.y = helib.y + 8
. Just a wild idea, that might omit triggering a memory leak -
Thanks @PB____ just changed it, lets see how it goes.
Edit: Sadly it just crashed again with the stack overflow error. was worth a try though!
I'm cutting out various things to try and find out exactly which bit is causing it. first I commented out the setspritescale commands and it still crashed, then I commented out all the lines where I set the position of the bomb sprite and it still crashed.now I've commented out where I load and display my map (tileset). will see how it goes.
Edit2: I just tried commenting out all the movement if statements ..still crashed
commented out the map ..still crashed
commented out the bg graphic ..still crashed. -
I thought I was confused before but I'm 10x more confused now.
I tried commenting out everything in that simple listing last night and no matter what I removed it still crashed.This morning I run it as-is and that was 27 mins ago.. it's still working. So I'm utterly baffled as to what's going on.
-
@SteveZX81 Excellent. This is all intended, we just want to watch people struggle. evil laugh
No but this is a confusing one for sure. I'm sorry you're having that experience with the program. Out of interest, referencing @Kat 's previous comment, is your
c
variable global? This has certainly sorted the problem out for me before.Sometimes if a crash is happening, commenting out lines can only get you so far. I remember once during testing before release I had a huge program which crashed, I commented out literally every single line of code and it still crashed, haha. We fixed it, of course, but I'm saying that there is scope for things not to make sense on the surface.
-
Thanks Dave and yes, right at the top, before the main loop I have c = controls(0) (which I believe makes it global?)
-
@SteveZX81 I see, well that rules that one out! Apologies Steve.
-
You have nothing to apologise for, not your fault.
-
Sorry, the dump question, but did I understand this correctly? how does controls() read the controller input during every main loop iteration, when its outside of it? Or do just put a c=[] outside of the main loop?
-
it doesn't. (well, it didn't when I tried it)
-
Ahh.You are right @SteveZX81 I understood @Kat wrong: "c = controls(0) line before the loop as well" This is the trick, this means it does not create a new instance every loop. It just re-uses the existing variable. nice! I have to try this.
-
Mmm I just tried this putting c =controls(0) at the top of pogo Jo as I have called that function repeatedly throughout my program. It only got to the second control input and completely locked up had to turn switch off and I've had no issues at all with using c=controls(0) whenever I've needed to.