Whether you're a newbie or an experienced programmer, any questions, help, or just talk of any language will be welcomed here.
Moderator: Coders of Rage
newbie1234
Chaos Rift Newbie
Posts: 15 Joined: Fri May 15, 2009 9:01 am
Current Project: I'm currently making my own GUI
Favorite Gaming Platforms: Err... Linux?
Programming Language of Choice: C++
Location: St. Petersburg, Russian Federation
Post
by newbie1234 » Wed May 27, 2009 10:36 am
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?
Falco Girgis
Elysian Shadows Team
Posts: 10294 Joined: Thu May 20, 2004 2:04 pm
Current Project: Elysian Shadows
Favorite Gaming Platforms: Dreamcast, SNES, NES
Programming Language of Choice: C/++
Location: Studio Vorbis, AL
Contact:
Post
by Falco Girgis » Wed May 27, 2009 4:38 pm
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.
trufun202
Game Developer
Posts: 1105 Joined: Sun Sep 21, 2008 12:27 am
Location: Dallas, TX
Contact:
Post
by trufun202 » Wed May 27, 2009 4:53 pm
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.
Falco Girgis
Elysian Shadows Team
Posts: 10294 Joined: Thu May 20, 2004 2:04 pm
Current Project: Elysian Shadows
Favorite Gaming Platforms: Dreamcast, SNES, NES
Programming Language of Choice: C/++
Location: Studio Vorbis, AL
Contact:
Post
by Falco Girgis » Wed May 27, 2009 5:03 pm
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!
trufun202
Game Developer
Posts: 1105 Joined: Sun Sep 21, 2008 12:27 am
Location: Dallas, TX
Contact:
Post
by trufun202 » Wed May 27, 2009 5:50 pm
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:
/flex
Innerscope
Chaos Rift Junior
Posts: 200 Joined: Mon May 04, 2009 5:15 pm
Current Project: Gridbug
Favorite Gaming Platforms: NES, SNES
Programming Language of Choice: Obj-C, C++
Location: Emeryville, CA
Contact:
Post
by Innerscope » Wed May 27, 2009 6:52 pm
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
Code: Select all
if((direction % 2)==0) {
y += speed * direction/2;
}else{
x += speed * direction;
}
just kidding
fingerfry
Chaos Rift Newbie
Posts: 34 Joined: Tue Sep 01, 2009 6:31 pm
Favorite Gaming Platforms: Xbox 360, PC, Gameboy Advance SP
Location: Palm Desert, California
Contact:
Post
by fingerfry » Wed Sep 09, 2009 6:27 pm
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
hurstshifter
ES Beta Backer
Posts: 713 Joined: Mon Jun 08, 2009 8:33 pm
Favorite Gaming Platforms: SNES
Programming Language of Choice: C/++
Location: Boston, MA
Contact:
Post
by hurstshifter » Wed Sep 09, 2009 7:06 pm
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...
fingerfry
Chaos Rift Newbie
Posts: 34 Joined: Tue Sep 01, 2009 6:31 pm
Favorite Gaming Platforms: Xbox 360, PC, Gameboy Advance SP
Location: Palm Desert, California
Contact:
Post
by fingerfry » Wed Sep 09, 2009 7:15 pm
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
newbie1234
Chaos Rift Newbie
Posts: 15 Joined: Fri May 15, 2009 9:01 am
Current Project: I'm currently making my own GUI
Favorite Gaming Platforms: Err... Linux?
Programming Language of Choice: C++
Location: St. Petersburg, Russian Federation
Post
by newbie1234 » Sun Sep 13, 2009 7:30 am
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.
captjack
Chaos Rift Cool Newbie
Posts: 50 Joined: Fri Sep 18, 2009 4:23 pm
Current Project: engine framework
Favorite Gaming Platforms: PC, XBox 360, PS3
Programming Language of Choice: C, C++
Location: Northern Virginia
Post
by captjack » Mon Sep 21, 2009 2:03 pm
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:
/flex
Who said math isn't cool?