Page 2 of 2

Re: [SDL] Shooting and Hello World!

Posted: Wed May 27, 2009 10:36 am
by newbie1234
Hmm, I imagine that the code for Update() function should look like something like this:

Code: Select all

Bullet::Update()
{
      if( direction == 1 )
      {
           x++;
      }
      
      if( direction == 0 )
      {
           x--;
      }
}
What do you guys think?

Re: [SDL] Shooting and Hello World!

Posted: Wed May 27, 2009 4:38 pm
by Falco Girgis
newbie1234 wrote:Hmm, I imagine that the code for Update() function should look like something like this:

Code: Select all

Bullet::Update()
{
      if( direction == 1 )
      {
           x++;
      }
      
      if( direction == 0 )
      {
           x--;
      }
}
What do you guys think?
Yeah, that'll do the trick.

Re: [SDL] Shooting and Hello World!

Posted: Wed May 27, 2009 4:53 pm
by trufun202
I'm a fan of having Direction being 1 and -1, then you can do this:

Code: Select all

Bullet::Update()
{
     x += 1 * direction;
}
Either way works, of course. ;)

Re: [SDL] Shooting and Hello World!

Posted: Wed May 27, 2009 5:03 pm
by Falco Girgis
trufun202 wrote:I'm a fan of having Direction being 1 and -1, then you can do this:

Code: Select all

Bullet::Update()
{
     x += 1 * direction;
}
Either way works, of course. ;)
oOoOo, clevar!

Re: [SDL] Shooting and Hello World!

Posted: Wed May 27, 2009 5:50 pm
by trufun202
GyroVorbis wrote:
trufun202 wrote:I'm a fan of having Direction being 1 and -1, then you can do this:

Code: Select all

Bullet::Update()
{
     x += 1 * direction;
}
Either way works, of course. ;)
oOoOo, clevar!
This also allows you to switch directions easily:

Code: Select all

direction *= -1;
/flex

Re: [SDL] Shooting and Hello World!

Posted: Wed May 27, 2009 6:52 pm
by Innerscope

Code: Select all

direction *= -1;

/flex
Nice invert, been hitting the gym lately?


I'm thinking you might need a constant for the speed as well...
and lets not forget up and down: -2,2 :twisted:

Code: Select all

	if((direction % 2)==0) {
			y += speed * direction/2;
	}else{
			x += speed * direction;
	}

:lol: just kidding

Re: [SDL] Shooting and Hello World!

Posted: Wed Sep 09, 2009 6:27 pm
by fingerfry
ultimatedragoon69 wrote: “Give a man a fish; you have fed him for today. Teach a man to fish; and you have fed him for a lifetime”

-unkown person wrote this.
I believe THIS is the correct quote:
“Give a man a fish; you have fed him for today. Teach a man to fish; and you have fed him for a lifetime. Teach a man to sell fish and he eats steak.”

—Author unknown
;)

Re: [SDL] Shooting and Hello World!

Posted: Wed Sep 09, 2009 7:06 pm
by hurstshifter
fingerfry wrote:
ultimatedragoon69 wrote: “Give a man a fish; you have fed him for today. Teach a man to fish; and you have fed him for a lifetime”

-unkown person wrote this.
I believe THIS is the correct quote:
“Give a man a fish; you have fed him for today. Teach a man to fish; and you have fed him for a lifetime. Teach a man to sell fish and he eats steak.”

—Author unknown
;)

How dare you resurrect a 4 month old thread...

Re: [SDL] Shooting and Hello World!

Posted: Wed Sep 09, 2009 7:15 pm
by fingerfry
hurstshifter wrote:
fingerfry wrote:
ultimatedragoon69 wrote: “Give a man a fish; you have fed him for today. Teach a man to fish; and you have fed him for a lifetime”

-unkown person wrote this.
I believe THIS is the correct quote:
“Give a man a fish; you have fed him for today. Teach a man to fish; and you have fed him for a lifetime. Teach a man to sell fish and he eats steak.”

—Author unknown
;)

How dare you resurrect a 4 month old thread...

You got to start somewhere :roll:

Re: [SDL] Shooting and Hello World!

Posted: Sun Sep 13, 2009 7:30 am
by newbie1234
Actually, the correct one is: “Sell a man a fish, he eats for a day, teach a man how to fish, you ruin a wonderful business opportunity.” - Karl Marx.

Re: [SDL] Shooting and Hello World!

Posted: Mon Sep 21, 2009 2:03 pm
by captjack
trufun202 wrote:
GyroVorbis wrote:
trufun202 wrote:I'm a fan of having Direction being 1 and -1, then you can do this:

Code: Select all

Bullet::Update()
{
     x += 1 * direction;
}
Either way works, of course. ;)
oOoOo, clevar!
This also allows you to switch directions easily:

Code: Select all

direction *= -1;
/flex

Who said math isn't cool? :)