Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
1 registered members (TipmyPip), 18,618 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
function question #289686
09/14/09 20:44
09/14/09 20:44
Joined: Sep 2009
Posts: 10
C
Cool_Flow Offline OP
Newbie
Cool_Flow  Offline OP
Newbie
C

Joined: Sep 2009
Posts: 10
if you create a function, say for example an explosion function, can you call that function ever time there is an explosion in your game or do you have to code it ever time?

Sorry, for the dumb questions, but I'm new and just wanna learn.

Re: function question [Re: Cool_Flow] #289688
09/14/09 21:02
09/14/09 21:02
Joined: Jul 2008
Posts: 1,178
England
M
MrGuest Offline
Serious User
MrGuest  Offline
Serious User
M

Joined: Jul 2008
Posts: 1,178
England
yeah, you should just create the explosion in a seperate function

Code:
function explosion(){
   //do special stuff here
}

function player_crash(){
   explosion();
}
function ai_crash(){
   explosion();
}



you could also pass parameters to the function to let it know where it occurs, or who to etc...

Code:
function explosion(VECTOR* temp_vec, ANGLE* temp_ang){
   //do explosion
}
function player_crash(){
   explosion(my.x, my.pan);
}



this really should be void function as nothing is being returned,
Code:
void explosion(){



hope this helps

Re: function question [Re: MrGuest] #289689
09/14/09 21:08
09/14/09 21:08
Joined: Sep 2009
Posts: 10
C
Cool_Flow Offline OP
Newbie
Cool_Flow  Offline OP
Newbie
C

Joined: Sep 2009
Posts: 10
that does help. I thought I was gonna have to keep coding it in every part of the game. lol, that would take forever. laugh

Re: function question [Re: Cool_Flow] #289695
09/14/09 22:08
09/14/09 22:08
Joined: Nov 2007
Posts: 1,143
United Kingdom
DJBMASTER Offline
Serious User
DJBMASTER  Offline
Serious User

Joined: Nov 2007
Posts: 1,143
United Kingdom
lol, thats the whole point of a function. It allows you to break your code into "modules" and then use them when you want.


Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1