Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (AndrewAMD, degenerate_762, ozgur), 1,311 guests, and 0 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Need Help Calling a Function / Help with multiple Actions? #220077
08/06/08 00:16
08/06/08 00:16
Joined: Jul 2007
Posts: 48
M
MattyTheG Offline OP
Newbie
MattyTheG  Offline OP
Newbie
M

Joined: Jul 2007
Posts: 48
Hello everyone, I am working on this game where you shoot an airplane with a missile. Yea its pretty generic right now but I'm working on it haha. Let me put in my code before I go any further.

#include <acknex.h>
#include <default.c>

var earthgravity[3]= 0,0, -386;
var launch_angle= 45;

function missile_flying()
{
while (1)
{
my.roll = my.roll + 3;
wait(1);
}
}

function main()
{
level_load ("PhysicsTest.wmb");
wait (2);
while (1)
{
launch_angle += key_cuu * .05;
launch_angle -= key_cud * .05;
wait(1);
}
}

action ball_drop()
{
while (key_space == 0) {wait (1);}
phent_settype(my, PH_Rigid, PH_box);
phent_setmass (my, 2, PH_box);
ph_setgravity (earthgravity);
phent_addvelcentral(my, vector(0, -472 * cos(launch_angle) , 472 * sin(launch_angle) ) );
function missile_flying();
wait(1);
}

action plane_fly()
{
while (key_space == 0) {wait (1);}
phent_settype(my, PH_Rigid, PH_Box);
phent_addvelcentral (my, vector(0, -472*cos(45), 0) );

}

Ok I have the code set up so that while the user is not pressing space, the action waits. Then when the spacebar is pressed the missile launches, as well as the plane.

The problem is that I want the missile to rotate, but if I put the my.roll = my.roll + 3; into the action ball_drop, it does not work. So I made it into a function and tried to call it when the missile launches.

I get an error saying empty function. I also want to work around the tilt modifier and what not, but it seems to be that I either have an action where the missile rolls, or one where it launches and can't get them to work simultaneously.

Re: Need Help Calling a Function / Help with multiple Actions? [Re: MattyTheG] #220079
08/06/08 00:21
08/06/08 00:21
Joined: Jul 2008
Posts: 1,178
England
M
MrGuest Offline
Serious User
MrGuest  Offline
Serious User
M

Joined: Jul 2008
Posts: 1,178
England
in
Code:
action ball_drop()
{
while (key_space == 0) {wait (1);}
phent_settype(my, PH_Rigid, PH_box);
phent_setmass (my, 2, PH_box);
ph_setgravity (earthgravity);
phent_addvelcentral(my, vector(0, -472 * cos(launch_angle) , 472 * sin(launch_angle) ) );
function missile_flying();
wait(1);
}


delete the
Code:
function missile_flying();


and replace it with just
Code:
missile_flying();


Hope this helps!

Re: Need Help Calling a Function / Help with multiple Actions? [Re: MrGuest] #220081
08/06/08 00:31
08/06/08 00:31
Joined: Jul 2007
Posts: 48
M
MattyTheG Offline OP
Newbie
MattyTheG  Offline OP
Newbie
M

Joined: Jul 2007
Posts: 48
Well that fixed the error, I no longer have an empty function, so thank you for that. The missile launches now, which is known as ball_drop because I forgot to change the name haha.

When I press space now, it launches like it should, I get no errors, but my missile still doesn't roll, any suggestions?

Re: Need Help Calling a Function / Help with multiple Actions? [Re: MattyTheG] #220086
08/06/08 00:45
08/06/08 00:45
Joined: Jul 2008
Posts: 1,178
England
M
MrGuest Offline
Serious User
MrGuest  Offline
Serious User
M

Joined: Jul 2008
Posts: 1,178
England
unfortunately... the bits in game studio i use

aren't A7
aren't physics
and aren't planes and missiles :P

couple of ideas though,

when you call a new function you should really pass things through it in the parameters to make sure it's still calling the right entity, i'm not sure if A7 does/doesn't return errors for this,

Code:
action ball_drop()
{
while (key_space == 0) {wait (1);}
phent_settype(my, PH_Rigid, PH_box);
phent_setmass (my, 2, PH_box);
ph_setgravity (earthgravity);
phent_addvelcentral(my, vector(0, -472 * cos(launch_angle) , 472 * sin(launch_angle) ) );
missile_flying(me);
wait(1);
}


Code:
function missile_flying(localEnt)
{
me = localEnt;
while (1)
{
my.roll = my.roll + 3;
wait(1);
}
}

try that?

2ndly, i don't know if playing with physics prevents you doing any other object manipulation? maybe someone else could answer that

3rdly, if your missile is symetrical all the way around, then you wouldn't necessarily see if .roll is working? try it's .tilt see if that makes it obvious

just some suggestions but doubt they matter? smile

Re: Need Help Calling a Function / Help with multiple Actions? [Re: MrGuest] #220119
08/06/08 00:56
08/06/08 00:56
Joined: Sep 2007
Posts: 761
Hrvatska (Croatia ), Slavonski...
cro_games Offline
User
cro_games  Offline
User

Joined: Sep 2007
Posts: 761
Hrvatska (Croatia ), Slavonski...
Bone animation..
Add bone in the center of the model,name it "bone1",attach whole model to the bone and use this code:

ent_bonerotate(my,"bone1",vector(0,0,5));


Hello everyone my name is Ivan Mandic from "Frozen pixel studio". wink
-----------------------------------
Homepage: www.fpx-studio.com
e-mail: emu_hunter_1990@hotmail.com
(working on a game engine)
Re: Need Help Calling a Function / Help with multiple Actions? [Re: cro_games] #220120
08/06/08 01:01
08/06/08 01:01
Joined: Jul 2007
Posts: 48
M
MattyTheG Offline OP
Newbie
MattyTheG  Offline OP
Newbie
M

Joined: Jul 2007
Posts: 48
Yikes, now I can't even get the vertices to attach to a model. Mr Guest your suggestions did not help, but thank you very much for trying.

Ok I have my model, I selected bones mode, clicked create bone, and placed one in the middle of my missile. Next I selected vertices mode, selected all the vertices, and clicked attach, but none of them attached, they all stayed yellow.

Should I post this in MED help forum now?

BTW, should that ent_bonerotate go in the action right after the ball launches, or my new function that I am calling?

Thanks for the effort guys.

Re: Need Help Calling a Function / Help with multiple Actions? [Re: MattyTheG] #220121
08/06/08 01:15
08/06/08 01:15
Joined: Sep 2007
Posts: 761
Hrvatska (Croatia ), Slavonski...
cro_games Offline
User
cro_games  Offline
User

Joined: Sep 2007
Posts: 761
Hrvatska (Croatia ), Slavonski...
Send the model and the whole code in "zip/rar" to my e-mail: emu_hunter_1990@hotmail.com..

Last edited by cro_games; 08/06/08 01:16.

Hello everyone my name is Ivan Mandic from "Frozen pixel studio". wink
-----------------------------------
Homepage: www.fpx-studio.com
e-mail: emu_hunter_1990@hotmail.com
(working on a game engine)
Re: Need Help Calling a Function / Help with multiple Actions? [Re: cro_games] #220127
08/06/08 02:00
08/06/08 02:00
Joined: Jul 2007
Posts: 48
M
MattyTheG Offline OP
Newbie
MattyTheG  Offline OP
Newbie
M

Joined: Jul 2007
Posts: 48
That works perfectly, thank you very much Cro.

Re: Need Help Calling a Function / Help with multiple Actions? [Re: MattyTheG] #220128
08/06/08 02:02
08/06/08 02:02
Joined: Sep 2007
Posts: 761
Hrvatska (Croatia ), Slavonski...
cro_games Offline
User
cro_games  Offline
User

Joined: Sep 2007
Posts: 761
Hrvatska (Croatia ), Slavonski...
Np man,np..
Any time..


Hello everyone my name is Ivan Mandic from "Frozen pixel studio". wink
-----------------------------------
Homepage: www.fpx-studio.com
e-mail: emu_hunter_1990@hotmail.com
(working on a game engine)

Gamestudio download | chip programmers | 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