Message Board
Message Board > Fenix / Bennu / Gemix / DIV > game randomly exits |
August 27, 2006, 17:58 | |
yonni
None 420 posts |
Ive been pondering this problem for a couple of days and just cant work it out, short of a fenix bug. (I'm using 0.84a btw). Here's the code with the problem, If you uncomment what I've commented, then it exits as soon as it is run (occasionally a couple of frames after). I've tried to cut down on what I've commented out and if you uncomment any of it, then it just exits. Code: process player() private int jump=0; string jumpdir; int n; string fulljump; begin arms(); //feet(); x=400; y=300; graph=1; movetype="run"; loop if(key(_s)) movetype="crawl"; end; if(key(_control)) movetype="prone"; end; if(mouse.x>x) flags=0; end; if(mouse.x<x) flags=1; end; /*switch(movetype) case "jump": if(jump>0 and fulljump!="reached") if(jump==jumpheight) fulljump="reached"; end; graph=1; movetype="run"; y--; jump++; switch (jumpdir) case "left": x--; end; case "right": x++; end; end; end; if(jump>0 and fulljump=="reached") y++; jump--; switch (jumpdir) case "left": x--; end; case "right": x++; end; end; jumpdir="none"; fulljump="none"; end; end; case "prone": y=y+15; if(graph<26) graph=27; end; switch(scan_code) case _d: n++; if(n==2) graph++; n=0; end; x=x+pronespeed; end; case _a: n++; if(n==2) graph++; n=0; end; x=x-pronespeed; end; default: graph=27; end; end; if(graph>40) graph=27; end; end; case "crawl": if(graph<17 OR graph>26) graph=17; end; switch(scan_code) case _d: n++; if(n==2) graph++; n=0; end; x=x+crawlspeed; end; case _a: n++; if(n==2) graph++; n=0; end; x=x-crawlspeed; end; default: graph=17; end; end; if(graph>26) graph=17; end; end; case "run": switch(scan_code) case _d: graph++; x=x+runspeed; end; case _a: graph++; x=x-runspeed; end; default: graph=1; end; end; if(graph>16) graph=1; end; end; end; if(x>=850) x=-25; end; if(x<=-50) x=825; end; if(key(_w)) if(jump==0) movetype="jump"; if(key(_a)) jumpdir="left"; end; if(key(_d)) jumpdir="right"; end; end; end; */ frame; /*if(movetype=="jump" and jump==0) movetype="run"; end; if(movetype=="prone") movetype="run"; y=y-15; else if(movetype=="crouch") movetype="run"; end; end;*/ end; end; process arms() private begin gun(0); graph=arms; loop x=father.x; y=father.y; flags=father.flags; /*if(father.movetype=="crawl") y=y+4; if(father.flags==1) x--; else x++; end; end; if(father.movetype=="prone") y=y+9; if(father.flags==1) x=x-10; else x=x+10; end; end;*/ frame; end; end; runspeed, crawlspeed, pronespeed and jumpheight are constants. the "arms" variable simply contains the graphic of the characters arms. ____________ |
# |
August 29, 2006, 21:53 | |
yonni
None 420 posts |
Right, I've descovered the problem. It doesnt like me using the local variable "movetype" that I defined. If I use a switch or an if statement on that, then it exits. It works fine if I change movetype from a local to a private, well, it almost works fine. In the "arms()" process, I use father.movetype, which doesnt work if movetype is a private variable. So I'm a bit stuck. Still, I'm not sure why it doesnt like local variable, but that's just fenix I suppose.
____________ |
# |
August 30, 2006, 16:22 | |
Rincewind
programmer 1546 posts |
I think you've stumbled onto your first fenix bug. The first Local variable should be called something like "Trash" and not used, as the first never works. And if that isn't what's wrong, could you please post your local/global definitions? ____________ Personal website: http://www.loijson.com |
# |
August 30, 2006, 21:49 | |
yonni
None 420 posts |
thanks, that works swell. Come to think of it, I think I've heard of that before, damn me for not remembering.
____________ |
# |
August 30, 2006, 22:13 | |
Rhovanion
Exterminated 666 posts |
damn fenix instead. :s I'm being serious about someone creating a new language like Fenix (one that works) :p ____________ |
# |
August 30, 2006, 23:49 | |
Sandman
F3n!x0r 1194 posts |
Also, don't use strings in switch()es, bound to fail. Don't ask why.
____________ BennuWiki Yes, my avatar has grey borders in IE (so get a decent browser) ROOFLEZ ROOFLEZ |
# |
August 31, 2006, 19:02 | |
yonni
None 420 posts |
@Sandman: I'll chanege that if/when it becomes a problem @Rhovanion: I've found an extention to the python programming language called pygame, which has lots of similarities to fenix and a lot less (if any) bugs. The syntax is completely different (but incredibly simple), any many of the functions seem like more complicated examples of the fenix ones. Might be worth checking out: www.pygame.org python homepage: www.python.org ____________ |
# |
August 31, 2006, 20:53 | |
PEader
お前はもう死んでいる 1486 posts |
Quoting Sandman: Also, don't use strings in switch()es, bound to fail. Don't ask why. That is normal. ____________ I see 57,005 people. |
# |
Message Board > Fenix / Bennu / Gemix / DIV > game randomly exits