Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - wooshj

Pages: [1]
1
General / Re: Projectiles
« on: July 19, 2017, 01:09:09 pm »
Oh its that simple? lol, vectors are very powerful.

2
General / Projectiles
« on: July 19, 2017, 06:17:54 am »
Hello,

So I'm having issues understanding something and I'm not sure if this is the correct place to ask this since technically its more game code related and not SFML related but we'll see.

If you want to shoot a projectile from a character using a class called lets say projectile, the way I saw another person do it was he would whenever space was pressed, create an instance of projectile then push it back onto a vector.

I have two questions about this; firstly shouldn't you use a dynamic instance of the projectile and then delete it either when the program ends by looping through the vector, or if it goes out of screen(certain cordinate?). Secondly I can't understand how creating the instance and pushing it onto the vector works? For example the code:

Code: [Select]
for("player presses space bar")
{
projectle1.rect.setPosition(Player1.rect.getPosition()); //rect is just the hitbox and image is following it
projectleArray.push_back(projectle1);
}

This is creating a using the same instance called projectile1 over and over again? How does that even make sense? does that mean when you delete projectle1 all the projectiles are lost?

Also again should you use a dynamic version of projectle1? Or can you not do that with instances.. Kinda new to this.

Thanks :)

3
General / Re: Using multiple sprite images for movement
« on: June 22, 2017, 06:39:18 pm »
Alright thanks. For some reason the way i was thinking about it was you would load the spritesheet onto the screen then cut it out and hide that spritesheet lol, now it makes a lot more sense.

4
General / Using multiple sprite images for movement
« on: June 22, 2017, 01:21:40 pm »
Using a spritesheet what is the best way to show a character moving? Is loading in each different image the best way to do it? For example if I click the W key it shows the image of character facing up, then if the I press S it clears the screen and draws the sprite of the character facing down. Is this the best way to do it? Reason I ask is because I saw a video of a guy who cropped the image using setTextureRect and just cropping the spriteSheet right in the game.

Pages: [1]