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 / Key press activating and deactivating functions (2 problems)

Author
Message
mofo09
15
Years of Service
User Offline
Joined: 5th Mar 2009
Location:
Posted: 13th Mar 2009 23:20
I have this problem with my if statements trying to implement these 2 camera functions i have.

Any help would be appreciated

I have 2 problems with these functions,

1.
Ive tried many different combinations of if and while statements but I cant get cameramode to start when keystate 33 is pressed AND STAY in that camera mode until the key is pressed AGAIN.

if picturetime = 0 then Actionmode()
If keystate(33) =1 Then picturetime =1
if picturetime=1 Then cameramode()

the program goes to cameramode but i dont know how to get back to actionmode!

2.
My actionmode isnt working properly as a function. When its in the main loop it works perfectly, but not when i make it a function and put it in the main loop. I think it might be a problem with question 1. but im not sure.








Here is all my code to look at.






please help with anything you can.
Pillarofire
20
Years of Service
User Offline
Joined: 31st Dec 2003
Location: Good Question, <looks around.>
Posted: 14th Mar 2009 08:58
Try this:

Pillarofire
20
Years of Service
User Offline
Joined: 31st Dec 2003
Location: Good Question, <looks around.>
Posted: 14th Mar 2009 09:41
I just tried to figure out what you were trying to do with your actionmode function. I don't want to be impolite but, I cant stand reading it, the indentation doesn't match the logic and there are several if-then's that I am surprised even compiled, as well I can make ends of where one if-endif block ends and another one begins.

If I haven't scared you away, and you are willing to accept my advice, you should rewrite that function, starting out by writing comments on exactly what you want to achieve. Then work your way through it and try to visualize what exactly you are telling the computer to do. Then make sure when you use indentation, that you indent blocks of code that are nested in other blocks. for example:



I realize you recently joined these forums, so I really don't want to scare you away, but If you want others to help you out, it helps to have readable code for them to work with.
HowDo
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 14th Mar 2009 12:27
The link below should show a few ways of doing stay on/off, just pick one that works for you.

http://forum.thegamecreators.com/?m=forum_view&t=52373&b=7

Dark Physics makes any hot drink go cold.
mofo09
15
Years of Service
User Offline
Joined: 5th Mar 2009
Location:
Posted: 15th Mar 2009 03:43
thanks guys, you definitely didn't scare me away, I realize the code is messed up and i want to fix this. I'm also quite new to programming so I need all the help i can get.

its driving me crazy

I tried what u said
how do, and i came up with the same thing. I cant get back out of the camera mode.. let me show you..
mofo09
15
Years of Service
User Offline
Joined: 5th Mar 2009
Location:
Posted: 17th Mar 2009 05:01
Ok, ive been looking over all this code I have. I've organized it a bit, ive tried other codes with it, ive adjusted it in many ways. I always get the same outcome,
I dont know what to do anymore!

its like my collision wont work with this code either. But I really like the controls in that code. I dont think im experienced enough to know whats wrong with this.



then try this



Do you see any difference?
please any help would be nice
Pillarofire
20
Years of Service
User Offline
Joined: 31st Dec 2003
Location: Good Question, <looks around.>
Posted: 21st Mar 2009 13:07
Hmm, well if the code works for you in the main loop, but suddenly stops working in a function, then the most probable error is that you are using variables that are not declared global, and thus are used as local variables for the function. Obviously, the way to fix this is figure out which variables you need for the function and declare them global, or figure out how which to pass through the function parameters.
mofo09
15
Years of Service
User Offline
Joined: 5th Mar 2009
Location:
Posted: 23rd Mar 2009 16:32
wow, thank you. thats what i needed to hear.
I'll try it out!!

Login to post a reply

Server time is: 2024-11-25 10:38:19
Your offset time is: 2024-11-25 10:38:19