cant make my player fire in the direction the is aiming

Talk about making games.

cant make my player fire in the direction the is aiming

Postby saabian » Sat May 19, 2007 1:47 pm

Hi i have a problem with my new game.
This game is created for the gp2x. The game reminds of GTA 1.

On the bad picture, the blue parts is suppose to be the players shoulder, the orange part is the players head and the black part is his gun.

You will steer the player with the arrow keys. It wont mather if you press the "up arrow key" or the "Left arrow key", the animation (exampel .1 ) will still be the same witch will make it look like the player is sidesteping wile pressing the left arrow key. The script for the player to move is the same as on of the basic GE example (x = x - 5; etc...).

To "aim" (exampel .2) you use the 7,8,9,4,5,6,1,2,3 buttons to the right of your table. If you press the number 6 button the animation will change so it looks like the player is looking to the right/aim to the right, if you press number 2 the animation will change so it looks like the player looks down etc.

When you press fire (ctrl) a bullet will be created (the yellow spot) . (Draw actor/script y = y - 5; ).
The problem is just that the bullet always moves the same way because of the script. if the player look to the right the bullet will still fly "up".

A bad alternativ is Key down/ "6" "ctrl" (keys must be pressed in order) script x = x + 5;.

But then i have to press a number everytime before open fire and i cant press fire more than one time before i have to press a number witch make it very hard to control.

Hope you understand. any ideas how to make the player fire at the way he is looking/aiming???

thanks!
Attachments
ge exampel.GIF
User avatar
saabian
 
Posts: 25
Joined: Sat Dec 09, 2006 1:27 pm
Location: Gothenburg => Sweden
Score: 0 Give a positive score

Postby saabian » Sat May 19, 2007 1:58 pm

something that would be very handy would be if i just somehow could rotate my "playeractor" in two ways. on the the left and on to the right. so on the gp2x i only would need to press "up" for rotate the player to the right, and press down to rotate the player to the left. is it posible to do that i GE? if so, the i wouldnt need all does difrent animations and difrent scripts etc. =)
User avatar
saabian
 
Posts: 25
Joined: Sat Dec 09, 2006 1:27 pm
Location: Gothenburg => Sweden
Score: 0 Give a positive score

re:

Postby Tytan McAnguns-PL » Sat May 19, 2007 6:39 pm

create in the "global code" and "varibles" "dir" and in the "draw actor event" draw this :

char*key=GetKeyState();
if(key[KEY_LEFT] == 1)dir = 0;
if(key[KEY_RIGHT] == 1)dir = 1;
if(key[KEY_UP] == 1)dir = 2;
if(key[KEY_DOWN] == 1)dir = 3;

and "button down" button this :

if(DIR == 0)your event ;
if(DIR == 1)your event ;
if(DIR == 2)your event ;
if(DIR == 3)your event ;
Project: Ninja Fighter (full) for tekdino
Shadow mask warrior (full) 100 % IIIIIIIIIII download :
http://www.esnips.com/doc/ff4b58fa-600b ... sk-warrior
POLISH FORUM GE:
http://www.ge.4.pl
User avatar
Tytan McAnguns-PL
 
Posts: 67
Joined: Sat Mar 31, 2007 9:38 am
Location: POLAND
Score: 16 Give a positive score

Postby pavel329 » Sun May 20, 2007 6:35 am

yall get all technical with it.
I just made a shooting animation.
The did animation finish/create actor.

And it looks very realistic. :)
Drugs r bad.
Mgaay?

Image
User avatar
pavel329
 
Posts: 269
Joined: Thu May 25, 2006 2:05 pm
Location: Behind you
Score: 5 Give a positive score

Re: re:

Postby Sgt. Sparky » Sun May 20, 2007 1:52 pm

Tytan McAnguns-PL wrote:create in the "global code" and "varibles" "dir" and in the "draw actor event" draw this :

char*key=GetKeyState();
if(key[KEY_LEFT] == 1)dir = 0;
if(key[KEY_RIGHT] == 1)dir = 1;
if(key[KEY_UP] == 1)dir = 2;
if(key[KEY_DOWN] == 1)dir = 3;

and "button down" button this :

if(DIR == 0)your event ;
if(DIR == 1)your event ;
if(DIR == 2)your event ;
if(DIR == 3)your event ;

:D Yay! that is the code I showed you(and a few others)
glad to see it in use! :D:D:D
Image
Random Links:
viewtopic.php?p=19474#19474
Right now (10/14/2009) I'm working on some C++ projects, but I might be able to help if you have some Game Editor questions. :)
User avatar
Sgt. Sparky
 
Posts: 1850
Joined: Sat Oct 07, 2006 5:28 pm
Location: Somewhere out there, beneath the pale blue sky...
Score: 236 Give a positive score

Postby saabian » Thu May 24, 2007 11:33 am

Thanks!
But i actually doesnt understand anything at all.... :D

what does this mean?

" create in the "global code" and "varibles" "dir" and in the "draw actor event" draw this "

what is "global code" and "varibles" and "dir"?



"and "button down" button this :

if(DIR == 0)your event ;
if(DIR == 1)your event ;
if(DIR == 2)your event ;
if(DIR == 3)your event ; "


What is my event in this case? do you mean that i should choose key down/script and then write something?

I did like this.
Draw actor/ script editor. then i wrote:

char*key=GetKeyState();
if(key[KEY_LEFT] == 1)dir = 0;
if(key[KEY_RIGHT] == 1)dir = 1;
if(key[KEY_UP] == 1)dir = 2;
if(key[KEY_DOWN] == 1)dir = 3;

and a big error message pop up when i pressed "ok".

i havent created so many games in GE because my work takes a lot of my holiday time so can you please explain as if you were explaining for a child haha :P.
User avatar
saabian
 
Posts: 25
Joined: Sat Dec 09, 2006 1:27 pm
Location: Gothenburg => Sweden
Score: 0 Give a positive score

Postby foody » Thu May 24, 2007 1:34 pm

* slaps forehead * Oh my dear saabian you really are ignorant in the world of programming huh?

Ok let me see if I can help here:

Quote, "what is "global code" and "varibles" and "dir""

Global Code: Code is a set of instructions that tells the computer to do a task. Global: pertaining to the whole world; worldwide; universal: the dream of global peace.

Variable: a quantity or function that may assume any given value or set of values. An example of a variable is " X = 0" You have assigned the value of X to be equal to zero. Another example would be "Dir = 3" you have assigned the variable Dir to equal three. So if you want to prompt the value of Dir it will equal to three. Dir is a variable the represents it's function which is Direction.

Erm...I hope I did not make a fool of myself.
foody
 
Posts: 8
Joined: Thu May 24, 2007 12:21 am
Score: 0 Give a positive score

Postby Sgt. Sparky » Thu May 24, 2007 2:17 pm

that does not tell him how to make a variabl,
or how to put somthing in global code.
but that tells him what it does! :D
(you did not make a fool of yourself,
you should have seen stupid stuff I used to post/ask :lol: [I think I still do!])

to put somthing in global code click on the scripts button and a slide will appear with all the events with code, click in global code and another menu will appear.
[size = 15]now to create a variabe:[/size]
on any script window(including global code.) click on the varaible button(not the variables/functions.) and it will open a windowi,
click on Add.(in the window that pooped up.) and it will have another window pop up. type in the variable name you want at the top of this window, integer is just a whole number real is a float(whole and decimals.)
and string is text. global is for every body, actor is for an actor variable.
an array is a set of variables of one type, more on that another time.
(these are just a list of the options.)
now once you have selected everything click on add.
:D
that is how you declare a variable. if you still need help, let me know! :)
Image
Random Links:
viewtopic.php?p=19474#19474
Right now (10/14/2009) I'm working on some C++ projects, but I might be able to help if you have some Game Editor questions. :)
User avatar
Sgt. Sparky
 
Posts: 1850
Joined: Sat Oct 07, 2006 5:28 pm
Location: Somewhere out there, beneath the pale blue sky...
Score: 236 Give a positive score

Postby saabian » Thu May 24, 2007 7:19 pm

thanks but i still dont understand how to make my players bullet fly in the direction my player is looking at. thats the question.

You just told me how to open the global code window, and i did, but were to write witch script? and the rest of the script you gave me? im sorry but i really doesnt understand how to make this work.

I think you understand my problem. like i told you (picture) you move my player with the arrows and you aim in diffrent direction with the number keys to the right of the table (but that only change animation, not the actor). when i press the key for aim to the right and fire the bullet still goes the same way as it always does because my script for the bullet is x = x - 5;.

so would you please tell me witch window i should open and exactly what to write in each window to get my problem solved.

otherwise i might could upload my game or something so you could help me with the scripts? but i dont know how to do that eather....

is there now whey to make the actor rotate 360* in two directions by just pressing two buttons?

like i said, im new here :shock:


Thanks!
User avatar
saabian
 
Posts: 25
Joined: Sat Dec 09, 2006 1:27 pm
Location: Gothenburg => Sweden
Score: 0 Give a positive score

Postby foody » Thu May 24, 2007 7:52 pm

But the funny thing is :shock: we DID exactly provide you the answer you need. In fact, the details we provided right now is enough to teach a first year class in computer science in university. In fact, thanks to the information here I am able to use this skeleton code to DO SO MUCH it is not even funny. For example, I can use this code to make the animation go correctly according to the direction of the user. I can take this exact code and direct the bullet depending on the direction of the user, I can take this very code, couple of revisions of course and I can turn it in to AI of a monster that can see you from a distance and charge at you and change the animation according. HAHA! I can do so much with this little skeletal code right here. I tell you what. Why not print the information here, sit comfortable in your favorit rest-room area turn on the lights and read it over and over again. I find that if I do read on the monitor I don't grasp the information or my eyes skip information, etc. However, if I print the document out and sit comfortable in my favorit seating area I can easily read slowly the information and my mind will race with answers.
foody
 
Posts: 8
Joined: Thu May 24, 2007 12:21 am
Score: 0 Give a positive score

Postby saabian » Thu May 24, 2007 8:42 pm

no you did NOT told me how to do, if you did then i wouldnt stand here like xxxxxxx freak with a guy named foody laughing at me!

This it what the information has told me.
You gave me a lot of diffrent scripts wich i dont know how/were to put.
Then you also told me how to open the global script code window and enter varibels. thats all. so now im standing here with 20 lines of script codes and a "global script code window". and i dont know were to put each part of the script.

i never done this before like i told you.
User avatar
saabian
 
Posts: 25
Joined: Sat Dec 09, 2006 1:27 pm
Location: Gothenburg => Sweden
Score: 0 Give a positive score

Postby pavel329 » Thu May 24, 2007 11:22 pm

Really read thething i posted up there.
Its sooo much easier than these stupid codes.
Drugs r bad.
Mgaay?

Image
User avatar
pavel329
 
Posts: 269
Joined: Thu May 25, 2006 2:05 pm
Location: Behind you
Score: 5 Give a positive score

Re: re:

Postby d-soldier » Fri May 25, 2007 12:21 am

Tytan McAnguns-PL wrote:create in the "global code" and "varibles" "dir" and in the "draw actor event" draw this :

char*key=GetKeyState();
if(key[KEY_LEFT] == 1)dir = 0;
if(key[KEY_RIGHT] == 1)dir = 1;
if(key[KEY_UP] == 1)dir = 2;
if(key[KEY_DOWN] == 1)dir = 3;

and "button down" button this :
if(DIR == 0)your event ;
if(DIR == 1)your event ;
if(DIR == 2)your event ;
if(DIR == 3)your event ;


This is it, right here. Your confused on where to put stuff, because your new.. thats all. Dont worry about it... Seems the top section would go in your player's draw actor script(?), and the bottom section would go in the create actor script for your bullet (replacing your current script).. The "your event " section would have the "yvelocity = -10;" type stuff for the bullet, each differing on the direction... DIR 0 is facing left, DIR 1n is right, DIR 2 is up, and DIR 3 is down.
Regarding the variable, all you need to do is click up on the SCRIPT button in GE, select GLOBAL CODE, click down on the "VARIABLES" button (not the variables/functions one), CLICK ADD, type in DIR as the name (use all caps) and change it to actor variable by click on the button that currently says global... then click down on the add button, and your done!
User avatar
d-soldier
 
Posts: 703
Joined: Sun Apr 08, 2007 2:13 am
Score: 61 Give a positive score

Postby saabian » Fri May 25, 2007 1:16 pm

Alright. it still doesnt work. so i will tell you guys exactly what i have done!

I open the player event "draw actor/ script editor" were i wrote:

char*key=GetKeyState();
if(key[KEY_LEFT] == 1)dir = 0;
if(key[KEY_RIGHT] == 1)dir = 1;
if(key[KEY_UP] == 1)dir = 2;
if(key[KEY_DOWN] == 1)dir = 3;


And got the message:

error line 2: incompatible types: cannot convert from ´const int´ to índentifier´
error line 3: incompatible types: cannot convert from ´const int´ to índentifier´
error line 4: incompatible types: cannot convert from ´const int´ to índentifier´
error line 5: incompatible types: cannot convert from ´const int´ to índentifier´

there are script code errors, proced any way? (yes/no) - i press the yes button / imidiate action.


then i open the bullet event "draw actor/ script editor" and write:

if(DIR == 0)yvelocity = - 10;
if(DIR == 1)yvelocity = + 10;
if(DIR == 2)xvelocity = - 10;
if(DIR == 3)xvelocity = + 10;

then i press "ok".

then i GE i press on the script button, press global code, press on the variables button, press add. in name i ONLY write DIR (dont understand "use all caps" what is a cap?).

change it to actor variable. then i click on the add button.

Now in GE i press "game mode" and get the message:

"there is errors in some scripts, fix the errors and try again.

player -> draw actor -> script editor "







thats what happens!!!
User avatar
saabian
 
Posts: 25
Joined: Sat Dec 09, 2006 1:27 pm
Location: Gothenburg => Sweden
Score: 0 Give a positive score

Postby Caaz Games » Fri May 25, 2007 1:57 pm

saabian wrote:(dont understand "use all caps" what is a cap?).

xD Caps, Like Caps Lock On The Side Of The Keyboard. Capitals ABCDEFGHIJKLMNOPQRSTUVWXYZ

And I Think It Says That Error Because The dir = 1; Needs To Be Caps (DIR =1;)

EDIT: I Think Everybody Got Confused Because I Think That You Forgot To Caps Some dir's.


- CAAZ
You are welcome to join my forum. 4 active members lol but it's a cool place. active... much talking :D it's fun!
http://caaz.freeforums.org/
User avatar
Caaz Games
 
Posts: 729
Joined: Wed Feb 14, 2007 9:09 am
Location: California....knows how to party!
Score: 25 Give a positive score

Next

Return to Game Development

Who is online

Users browsing this forum: No registered users and 1 guest

cron