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 - takatalvi

Pages: [1]
1
Graphics / Re: How can i slow down the rate my projectiles fire.
« on: May 03, 2017, 09:32:19 am »
Analysing solely the code you posted. Here's how it reads to me.

For every monster, check every tower to see if they're in range. If they are in range, Create a bullet at so and so position.

I think therein lies your issue. You're creating a new bullet every time you check collision(presumably every frame).

In my opinion, I would create a shoot() method in your tower class. If a monster is in range, call this method, but dont spawn a bullet right away. Have a local clock, and check to see that it's past a certain time before actually spawning a new bullet. Most important, when you spawn a new bullet, you need to ::reset() the clock, or it'll auto fire exactly like I think you're seeing now.

2
General discussions / Re: sf::View as a minimap.
« on: December 23, 2015, 01:50:59 pm »
What about http://www.sfml-dev.org/tutorials/2.3/graphics-view.php?
There is a minimap example in there.

That's just a demonstration, no actual code for accurately positioning a sf::View.

(1.f / targetSize.x) * x
is equal to:
x / targetSize.x
 ;)

Hurray for math! Thanks for that, I posted this after one of those "Wow this day was too long" kinda days.

3
General discussions / sf::View as a minimap.
« on: December 22, 2015, 04:14:06 pm »
I've recently started working on a new project that uses sf::View as a camera to a Scene. Then I started messing around with using a 2nd view as a mini map, but positioning and sizing the thing was a pain. I read through the Documentation, and the numerous tutorials all over the internet, and I haven't seen anyone do this yet, so here it is.

I do admit this is just a simple hack that I threw in, but it took me awhile to think to do it this way. Hopefully I can save someone else the trouble. I created a camera class that is a wrapper for sf::View. For positioning and/or sizing I made some helper functions with terrible names, but they work well enough for now.

Here is the declaration.
(click to show/hide)

And here is the simple implementation.
(click to show/hide)

I registered to the forums just for this, so I hope it helps someone!

Pages: [1]
anything