Moving Projectile

Talk about making games.

Moving Projectile

Postby ALK3_Steph » Sat Sep 10, 2005 3:03 am

I have a character that fires a projectile. I can make it move across the screen, and collide with something, I can make it go as fast as I want, but I cant make it go in the direction I want it to go.

The problem is my guy can face right or left. I can write a script to make it shoot right, or left, but not either or depending on the char's position. How would I do this? Ive tried using
Code: Select all
if ((animindex = 0));
(xvelocity = xvelocity+3);
if ((animindex = 1));
(xvelocity = xvelocity-3);
;


But it doesnt make the projectile move. There is a keydown command for the spacebar, which then makes the projectile actor. From there Im stuck. Any help or suggestions? -ALK3_Steph
"Take your wings outside, you cant fly in here, besides purple skies are betting soaring for you my angel, you're an angel, you little devil. As for me I'll be just fine as I stay inside and watch from the window" -Alkaline Trio (Goodbye Forever)
ALK3_Steph
 
Posts: 27
Joined: Sat Sep 10, 2005 2:40 am
Location: Norfolk, VA
Score: 0 Give a positive score

Postby Game A Gogo » Sat Sep 10, 2005 11:22 am

Here maybe what you can do:

do a variable callad:"pos" then on Keydown event of left:
Code: Select all
pos=1;
and on right:
Code: Select all
pos=0;
and on space bar: create actor: projectile.

on the projectile, create actor:
Code: Select all
if (pos==1)
{
xvelocity=-7;
}
if (pos==1)
{
xvelocity=+7;
}


hope that help(this is only side scroller games)
Programming games is an art,
    Respect it.
User avatar
Game A Gogo
 
Posts: 3466
Joined: Wed Jun 29, 2005 10:49 pm
Location: French Canada *laughs*
Score: 181 Give a positive score

Postby makslane » Sat Sep 10, 2005 12:07 pm

The problem is the ; at end of if:

if ((animindex = 0)); //If condition Do nothing

(xvelocity = xvelocity+3);

if ((animindex = 1)); //If condition Do nothing

(xvelocity = xvelocity-3);


Both xvelocity lines will be executed, so, there is no change in the xvelocity and your actor don't will move.
makslane
Site Admin
 
Posts: 3947
Joined: Sat Apr 05, 2003 6:47 pm
Score: 182 Give a positive score

Postby ALK3_Steph » Wed Sep 28, 2005 12:10 am

Ok its been awhile but I finally tried out those two methods and they didnt work for me. I used the code
Code: Select all
if (pos==0)
{xvelocity=+10;}
if (pos==1)
{xvelocity=-10;}

But that didnt work, it will just shoot towards the right reguardless of which way the guy is pointing, and I tried the otherway without the " ; " at the end and still nothing, any other ideas or explination?
"Take your wings outside, you cant fly in here, besides purple skies are betting soaring for you my angel, you're an angel, you little devil. As for me I'll be just fine as I stay inside and watch from the window" -Alkaline Trio (Goodbye Forever)
ALK3_Steph
 
Posts: 27
Joined: Sat Sep 10, 2005 2:40 am
Location: Norfolk, VA
Score: 0 Give a positive score

Postby Game A Gogo » Wed Sep 28, 2005 12:39 am

Didi you use the var thingy??
Programming games is an art,
    Respect it.
User avatar
Game A Gogo
 
Posts: 3466
Joined: Wed Jun 29, 2005 10:49 pm
Location: French Canada *laughs*
Score: 181 Give a positive score

Postby ALK3_Steph » Wed Sep 28, 2005 2:48 am

Yea I made a variable for Pos, and in the keydown for right I added, "Pos=0;" and "Pos=1;" in left, then, created a script on the projectile with the if statement. It would fire right, but, only right. So, I dont know if I missing something or what, but, its frustrating none the less! Haha.
"Take your wings outside, you cant fly in here, besides purple skies are betting soaring for you my angel, you're an angel, you little devil. As for me I'll be just fine as I stay inside and watch from the window" -Alkaline Trio (Goodbye Forever)
ALK3_Steph
 
Posts: 27
Joined: Sat Sep 10, 2005 2:40 am
Location: Norfolk, VA
Score: 0 Give a positive score

Postby Game A Gogo » Wed Sep 28, 2005 8:12 pm

wierd, always work for me.

Sorry if I was not helpfull. :oops:
Programming games is an art,
    Respect it.
User avatar
Game A Gogo
 
Posts: 3466
Joined: Wed Jun 29, 2005 10:49 pm
Location: French Canada *laughs*
Score: 181 Give a positive score

Postby ALK3_Steph » Thu Sep 29, 2005 12:13 am

Na dude you were quite helpful just I took C++ in highschool like 2 years ago and dont remember a thing about it so Im probably just doing it wrong somehow, haha. I appreciate you taking the time to reply and try to help though. I will eventually get it, Im sure
"Take your wings outside, you cant fly in here, besides purple skies are betting soaring for you my angel, you're an angel, you little devil. As for me I'll be just fine as I stay inside and watch from the window" -Alkaline Trio (Goodbye Forever)
ALK3_Steph
 
Posts: 27
Joined: Sat Sep 10, 2005 2:40 am
Location: Norfolk, VA
Score: 0 Give a positive score

Postby Joshua Worth » Thu Sep 29, 2005 12:32 am

They give you C++ lessons in highschool?! :shock: I really don't think you can do that in Australia.
Stay sweet
User avatar
Joshua Worth
 
Posts: 515
Joined: Tue Jul 19, 2005 12:00 am
Location: Stralia
Score: 5 Give a positive score

Postby ALK3_Steph » Thu Sep 29, 2005 12:33 am

Haha yea, I was living in California, and in programming class they teach you QBasic, C++, and Java. Did great at QBasic, did ok at C++ and did ok at Java but like I said, after highschool I didnt get into it much
"Take your wings outside, you cant fly in here, besides purple skies are betting soaring for you my angel, you're an angel, you little devil. As for me I'll be just fine as I stay inside and watch from the window" -Alkaline Trio (Goodbye Forever)
ALK3_Steph
 
Posts: 27
Joined: Sat Sep 10, 2005 2:40 am
Location: Norfolk, VA
Score: 0 Give a positive score

Postby Joshua Worth » Thu Sep 29, 2005 12:36 am

You want QBasic? I am the QBasic PRO. :D Shameful, isn't it? :oops:
Stay sweet
User avatar
Joshua Worth
 
Posts: 515
Joined: Tue Jul 19, 2005 12:00 am
Location: Stralia
Score: 5 Give a positive score

Postby ALK3_Steph » Thu Sep 29, 2005 1:08 am

Haha Im good on QBasic thanks. Haha. OO! I did wanna say that I JUST got the damn thing to work. You know what the problem was? I did

Code: Select all
if (pos=0)
{xvelocity=+20;}
if (pos=1)
{xvelocity=-20;}


And the solution to the entire thing was (pos==0).
Woo. I gotta say. Without your guys's help, Id never have gotten it, thanks again all!
"Take your wings outside, you cant fly in here, besides purple skies are betting soaring for you my angel, you're an angel, you little devil. As for me I'll be just fine as I stay inside and watch from the window" -Alkaline Trio (Goodbye Forever)
ALK3_Steph
 
Posts: 27
Joined: Sat Sep 10, 2005 2:40 am
Location: Norfolk, VA
Score: 0 Give a positive score

Postby Game A Gogo » Thu Sep 29, 2005 7:50 pm

all the pleasure was mine, and of course, yours!!
Programming games is an art,
    Respect it.
User avatar
Game A Gogo
 
Posts: 3466
Joined: Wed Jun 29, 2005 10:49 pm
Location: French Canada *laughs*
Score: 181 Give a positive score

Postby ALK3_Steph » Thu Sep 29, 2005 9:01 pm

I look forward to gaining more experience from you guys, and someday being able to share my knowledge with you, or someone new who has begun interest in this
"Take your wings outside, you cant fly in here, besides purple skies are betting soaring for you my angel, you're an angel, you little devil. As for me I'll be just fine as I stay inside and watch from the window" -Alkaline Trio (Goodbye Forever)
ALK3_Steph
 
Posts: 27
Joined: Sat Sep 10, 2005 2:40 am
Location: Norfolk, VA
Score: 0 Give a positive score


Return to Game Development

Who is online

Users browsing this forum: No registered users and 1 guest