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 / Adding Functions

Author
Message
badkneecap
14
Years of Service
User Offline
Joined: 21st Jun 2010
Location:
Posted: 3rd Aug 2010 05:50
My game started getting a little big with all the code, so I started creating functions. Now nothing works. Specifically, it seems that my objects are not displaying. How can I get them up so that I can create them in 1 function and reference them in another? I don't get errors now, but they just don't display.
Hodgey
15
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 3rd Aug 2010 08:06
Hi, please post code when you come across a problem like this, it makes it a lot easier for anyone trying to help you.

A clever person solves a problem, a wise person avoids it - Albert Einstein
Neuro Fuzzy
17
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 3rd Aug 2010 08:11
you coded wrong


Is't life, I ask, is't even prudence, to bore thyself and bore thy students?
HowDo
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 3rd Aug 2010 12:31
try adding a sync when your model have been made or loaded.

Dark Physics makes any hot drink go cold.
Rich Dersheimer
AGK Developer
15
Years of Service
User Offline
Joined: 1st Jul 2009
Location: Inside the box
Posted: 3rd Aug 2010 23:52
Yes, let's see some of your code.

One thing to remember about functions is that any variables used in them are local, unless you've declared them as global.

badkneecap
14
Years of Service
User Offline
Joined: 21st Jun 2010
Location:
Posted: 4th Aug 2010 04:16
Ok, I put all the functions in the main program and I get the exact same results. I was having problems with the variable like you said, so I started passing them in as parameters.

Here's what I have:



I'm building a dungeon off of the tutorial, so a lot of the code might look familiar.
Rich Dersheimer
AGK Developer
15
Years of Service
User Offline
Joined: 1st Jul 2009
Location: Inside the box
Posted: 4th Aug 2010 07:24
No joystick here, so I can't test your code, sorry.

badkneecap
14
Years of Service
User Offline
Joined: 21st Jun 2010
Location:
Posted: 5th Aug 2010 02:50
I dont' think it should matter if you have a joystick or not. If you don't, you just won't be able to move, but you should still see the walls, ceiling and floor.

You mention making the variables global. How do you do that? How do you make objects global?
badkneecap
14
Years of Service
User Offline
Joined: 21st Jun 2010
Location:
Posted: 6th Aug 2010 05:54
I figured it out. It turns out that I needed to make some variables global to get it to work.
cloudy
14
Years of Service
User Offline
Joined: 30th Jun 2010
Location:
Posted: 6th Aug 2010 10:08
Send your code to look.

Login to post a reply

Server time is: 2024-11-16 15:46:35
Your offset time is: 2024-11-16 15:46:35