[SDL] Shooting and Hello World!
Moderator: Coders of Rage
-
- 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
[SDL] Shooting and Hello World!
First of all, I would like to say hello to everyone here on this forum.
I have a question: Can somebody tell me or give me some sort of example of how to implement shooting feature in 2D platformer?
To be more precise, I want that bullet appears on left/right side of the character( depends on how main character is turned ) and speeds up until he collides with wall tiles.( pretty much something like Falco had in his video about previous projects I think ( Tile Demo or whatever that thing is called ) )
Oh, and I am using C++ and SDL if that matters. ....
I have a question: Can somebody tell me or give me some sort of example of how to implement shooting feature in 2D platformer?
To be more precise, I want that bullet appears on left/right side of the character( depends on how main character is turned ) and speeds up until he collides with wall tiles.( pretty much something like Falco had in his video about previous projects I think ( Tile Demo or whatever that thing is called ) )
Oh, and I am using C++ and SDL if that matters. ....
- 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:
Re: [SDL] Shooting and Hello World!
Y'know what, I have read this post like three times, and I have written (and deleted) maybe two different responses.
I'm going to do something a little different with you. Implementing bullets (my tile demo style) is really easy. I know you could do it. Instead of me just telling you a way to do it, you will do it yourself (on these boards), and we will walk you through.
I'll get you started. What is a bullet? It's a little box/sprite/square on the screen that goes either from right to left or left to right depending on the direction you were facing when you shot it.
Okay, so lets make a simple bullet class containing necessary things:
Okay, now you can start off by defining your "Update()" function and telling us what you think the next step should be.
I'm going to do something a little different with you. Implementing bullets (my tile demo style) is really easy. I know you could do it. Instead of me just telling you a way to do it, you will do it yourself (on these boards), and we will walk you through.
I'll get you started. What is a bullet? It's a little box/sprite/square on the screen that goes either from right to left or left to right depending on the direction you were facing when you shot it.
Okay, so lets make a simple bullet class containing necessary things:
Code: Select all
class Bullet {
public:
int x, y;
int direction; //We'll be simple and say like 0 is facing left and 1 is facing right
void Update(); //Make the bullet move based on direction
};
Re: [SDL] Shooting and Hello World!
Good idear Gyro... We should do this more often to teach independent thought to the youth of america...GyroVorbis wrote:Y'know what, I have read this post like three times, and I have written (and deleted) maybe two different responses.
I'm going to do something a little different with you. Implementing bullets (my tile demo style) is really easy. I know you could do it. Instead of me just telling you a way to do it, you will do it yourself (on these boards), and we will walk you through.
I'll get you started. What is a bullet? It's a little box/sprite/square on the screen that goes either from right to left or left to right depending on the direction you were facing when you shot it.
Okay, so lets make a simple bullet class containing necessary things:
Okay, now you can start off by defining your "Update()" function and telling us what you think the next step should be.Code: Select all
class Bullet { public: int x, y; int direction; //We'll be simple and say like 0 is facing left and 1 is facing right void Update(); //Make the bullet move based on direction };
- Kros
- Chaos Rift Regular
- Posts: 136
- Joined: Tue Feb 24, 2009 4:01 pm
- Current Project: N/A
- Favorite Gaming Platforms: PC, Playstation/2/3
- Programming Language of Choice: C++
- Location: Oregon,USA
- Contact:
Re: [SDL] Shooting and Hello World!
What if hes not from America? =)eatcomics wrote:america...
YouTube ChannelIsaac Asimov wrote:Part of the inhumanity of the computer is that, once it is competently programmed and working smoothly, it is completely honest.
- ultimatedragoon69
- Chaos Rift Regular
- Posts: 122
- Joined: Tue Oct 28, 2008 1:57 pm
- Current Project: Pangea's quest (text ~tile~ based rpg)
- Favorite Gaming Platforms: Dreamcast, PC, playstation 1, Virtual Boy, Snes
- Programming Language of Choice: c++
- Contact:
Re: [SDL] Shooting and Hello World!
it's nice to meet you, and great idea gyro.
---
“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.
---
“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.
Re: [SDL] Shooting and Hello World!
I'll bring him to america, anymore questions???Kros wrote:What if hes not from America? =)eatcomics wrote:america...
- MarauderIIC
- Respected Programmer
- Posts: 3406
- Joined: Sat Jul 10, 2004 3:05 pm
- Location: Maryland, USA
Re: [SDL] Shooting and Hello World!
Yeah. What do you smoke, again?eatcomics wrote:I'll bring him to america, anymore questions???
I realized the moment I fell into the fissure that the book would not be destroyed as I had planned.
Re: [SDL] Shooting and Hello World!
a LOOOOOOOOOOOOOT.... other than that I refuse to tell....MarauderIIC wrote:Yeah. What do you smoke, again?eatcomics wrote:I'll bring him to america, anymore questions???
Edit: Everybody's goin to the party have a real good time....
Re: [SDL] Shooting and Hello World!
Wouldn't you want your object's attributes to be private. That way you don't have someone setting a value that they cannot store into it. Like trying to get a long type (don't know if c++ has longs for data types) into an int. Then again, you probably won't be storing a long into a data type for positions.
Anyways this is a very great idea. Teach not tell. Get them to think of the answer and not give them.
Anyways this is a very great idea. Teach not tell. Get them to think of the answer and not give them.
- MarauderIIC
- Respected Programmer
- Posts: 3406
- Joined: Sat Jul 10, 2004 3:05 pm
- Location: Maryland, USA
Re: [SDL] Shooting and Hello World!
Falco's not a big fan of accessors. And you would use accessors to prevent returning NULL values or accessing arrays out-of-bounds, that sort of thing, not to avoid data conversion.
Hope OP replies soon :D
Hope OP replies soon :D
I realized the moment I fell into the fissure that the book would not be destroyed as I had planned.
- 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:
Re: [SDL] Shooting and Hello World!
Oh, god.Martyj wrote:Wouldn't you want your object's attributes to be private. That way you don't have someone setting a value that they cannot store into it. Like trying to get a long type (don't know if c++ has longs for data types) into an int. Then again, you probably won't be storing a long into a data type for positions.
Anyways this is a very great idea. Teach not tell. Get them to think of the answer and not give them.
I don't use accessors that do absolutely nothing but return and set a value. I use them when they do things like check for debugging, update multiple things, or as Marauder said. Otherwise it's pointless to me. You're writing more, useless code, your code that utilizes these accessors becomes 10 times uglier, etc.
It's up to you, but I would rather not treat this like a first year CS class. I also didn't want to discourage or confuse him with all of the complete OO whore bullshit.
- 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:
Re: [SDL] Shooting and Hello World!
I'm hoping newbie1234 didn't decide to bail when Falco told him to write his own "Update" function.
Current Project: Gridbug
Website (under construction) : http://www.timcool.me
Website (under construction) : http://www.timcool.me
- 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:
Re: [SDL] Shooting and Hello World!
Wow, this is why I don't help people.
-
- 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
Re: [SDL] Shooting and Hello World!
Hello everyone!
Wow, I wasn't expecting that you all will reply to my question so quickly. Thanks!
Unfortunately, I wasn't been able to write my own update function due to the lack of time. Work was really pushing hard on me lately, but I will have some time after 20th May.
Wow, I wasn't expecting that you all will reply to my question so quickly. Thanks!
Unfortunately, I wasn't been able to write my own update function due to the lack of time. Work was really pushing hard on me lately, but I will have some time after 20th May.
- dandymcgee
- ES Beta Backer
- Posts: 4709
- Joined: Tue Apr 29, 2008 3:24 pm
- Current Project: https://github.com/dbechrd/RicoTech
- Favorite Gaming Platforms: NES, Sega Genesis, PS2, PC
- Programming Language of Choice: C
- Location: San Francisco
- Contact:
Re: [SDL] Shooting and Hello World!
GyroVorbis wrote:Wow, this is why I don't help people.
Not all hope is lost! Hehe, he wasn't expecting the crazy reply speed that takes place here on the forums. Feel free to make an attempt whenever you get time, newbie1234, and we'll help you build off of your base code.newbie1234 wrote:Hello everyone!
Wow, I wasn't expecting that you all will reply to my question so quickly. Thanks!
Unfortunately, I wasn't been able to write my own update function due to the lack of time. Work was really pushing hard on me lately, but I will have some time after 20th May.
Falco Girgis wrote:It is imperative that I can broadcast my narcissistic commit strings to the Twitter! Tweet Tweet, bitches!