Posted By: mschoenhals
Jump Action Crash - 01/03/14 14:50
Hi,
I'm working with AUM #103 Shooter Template. I've got my game almost complete but I get a crash when I publish it (works fine from WED though).
I've isolated it to one line of code:
vertical_speed.z = t_jump * 0.25;
If I change the code to this, it works fine:
vertical_speed.z = tshooter_jump * time_step;
However, the player jumps way too high for my game.
Anyone have a suggestion on how to rewrite this line of code?
Posted By: Dooley
Re: Jump Action Crash - 01/28/14 04:44
Can you multiply the tshooter_jump variable by 0.25 before this line of code?
tshooter_jump = tshooter_jump * 0.25;//add this line first
vertical_speed.z = tshooter_jump * time_step;
Posted By: mschoenhals
Re: Jump Action Crash - 06/05/15 18:02
Unfortunately, this still doesn't work. It works fine with the Commercial version but my students have the student version. I've changed the line to exclude time_step thinking that was causing the error:
vertical_speed.z = t_jump * 0.35;
Works fine on the Commercial but causes a crash for the student version. Is there another way to write code for jump?
Posted By: Wjbender
Re: Jump Action Crash - 06/05/15 20:00
okay looks like you found what "appears" to me like a coding mistake in the template script .
I quickly looked it over and saw that the jump_handle was localy defined inside the t_player action but never assigned to a sound wich was called in another function t_player_jump .
to fix this (don't know if we are allowed but I fixed mine) :
open up t_player.c file in SED , the file is located inside of your gamestudio installation folder \include sub folder .
once opened inside SED , scroll down to the "action t_player() " function , then change :
var current_height = 0, jump_handle;
to
then go to line 40 and add this as a global variable:
now scroll down to "function t_player_jump ()"
then change from :
snd_play(shooter_jump,70,0);
to :
jump_handle=snd_play (shooter_jump,70,0);
save t_player.c , now publish your project and test
enjoy.
Posted By: mschoenhals
Re: Jump Action Crash - 06/05/15 22:50
Wow! That works! Thank you programming god!
How is it that you went about figuring it out? Any tips for a beginning coder?
Thanks again.
Posted By: Anonymous
Re: Jump Action Crash - 06/06/15 01:08
Wow! That works! Thank you programming god!
high praise indeed
Posted By: Wjbender
Re: Jump Action Crash - 06/06/15 07:39
like they say "follow the money trail" , so you follow the program flow and trace the problem. .
yeah I am no programming god , I am sure I wil require your help one day.
but..
to legitimately answer your question , and I am sure you went about it the same manner as I , since it happens when pressing space ,we simply jump to where space is handled , if the problem is not easy to spot and you do not understand the problem then , you can resort to trial and error like : start commenting code out piece by piece and publish everytime until you figure out which code area holds the mistake , then you simply can trace whatever is used in that area (variables/functions/pointers) to find the cause , if things get really hairy you can always use printf or DEBUG_VAR to help out , the point being to always check any values / pointers / functions / variables in the area you have traced .
if however you understand the language and engine better , you can approach the problem more methodical , I basically just jumped to the space handled code and looked at everything used there , then I quickly spotted that the sound handle was an uninitialised variable , since it needed to be assigned to something I traced to where the sound was to be used and connected the dots ..
other than that , all I can really advice you on is ,that every mistake is an opportunity to learn , mistakes wil teach you more than anyone can ever teach you , why ? Because one's you have gone through hell to find out what went wrong , you won't forget it because you actually learned to understand the mistake .
there wil come a time when bug hunting becomes fun , but all of us go through this mistakes even after years of coding , the simplest of mistakes have at times given me headaches like adding 2 ";;" at the end of a line ,almost impossible to spot at times .
with SED my advice is to do as my signature states , compile often (publish often) after code additions / changes , and as always check values/pointers before using them with "if clauses" or functions/macros you have written to do it for you.
Posted By: Wjbender
Re: Jump Action Crash - 06/06/15 10:51
and another heads up : in that same file "pragma_path" is used , and that statement is not supported in the published version .
Posted By: mschoenhals
Re: Jump Action Crash - 06/06/15 15:34
Thanks Wjbender!
A great response. Yeah, I was trying to comment out the code and could isolate the issue. I need more work on my programming; it's taking some time.
Thanks again for your help.
Posted By: rayp
Re: Jump Action Crash - 06/06/15 19:37
headaches like adding 2 ";;"
I had yesterday...but luckily found it quick
Posted By: Wjbender
Re: Jump Action Crash - 06/06/15 20:49
I did that like 2 times somewhere in a iteration loop in c# , I could barely find it ..doh