Gamestudio Links
Zorro Links
Newest Posts
Alpaca Plugin v1.5.2 Release
by kzhao. 01/11/26 13:42
Alpaca Plugin v1.4.0
by kzhao. 01/11/26 13:38
separating groups of 3 digits by a comma
by joe_kane. 01/11/26 00:01
MRC.c and WFO
by joe_kane. 01/10/26 23:58
BarOffset (default = 940 for daily bars?
by joe_kane. 01/10/26 23:46
NOMAX undeclared identifier.
by Petra. 01/09/26 21:12
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
0 registered members (), 23,562 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
joe_kane, Namitha_NN, Syndrela, agasior, mosfet
19189 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