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

Pages: [1] 2
1
Window / Re: Recommended way to change mouse cursor
« on: March 31, 2020, 06:42:49 pm »
Thank you I will try much appreciated.

2
Window / Recommended way to change mouse cursor
« on: March 31, 2020, 04:18:00 pm »
Hello,

This is just a quick question about changing the mouse cursor image for different events, "Move, Click, etc".
What is the recommended way to do this ?
1) Create new sf::Cursors for each event ?
2) Use a sprite ?
3) Is there a way I am missing ?

Regards.

3
General / Re: How to handle collision for multiple objects efficiently ?
« on: September 02, 2017, 11:50:56 am »
Hey Tigre,

Your solution is perfectly valid and a good one, and I believe I may have read the topic incorrectly.
I would take a similar approach also.

Game Class {

// Vars
Ball object
Paddle object
Array of block objects

//Functions
ball.update()
paddle.update(Ball &m_ball)
handleCollisions() {
    for(const auto &itr : blocks) {
        // Check block and ball for collisions and update on collision
    }
}

If you don't like having the collision check here you could
for(const auto &itr : blocks) {
        itr.checkCollision(Ball &m_ball);
}

4
General / Re: How to handle collision for multiple objects efficiently ?
« on: September 01, 2017, 06:23:17 pm »
There is nothing wrong with iterating over a vector to check for collisions with a simple game like arkanoid.

Don't waste your time trying to build the perfect and most efficient code. Get the collisions up and running and see if its a problem first.

If you find its an issue then maybe look into splitting your level up into multiple parts or use a tile based approach.

Feel free to message if you have any issues.



5
General / Re: Hard Coding Value of Sprite's Position
« on: July 08, 2017, 02:01:22 pm »
If the sprites position and size are based on percentages of the screen size, they will be scaled/stretched accordingly on different devices.

Just be careful if the devices have different aspect ratios. 4:3 / 16:9 etc
This can cause a circle to turn into an oval.


6
General / Real time events vs Polling Events using a joypad
« on: July 08, 2017, 01:56:06 pm »
Whats the proper use of these events regarding joypad input for example ?

7
You can do something like this to get you started.
But I recommend maybe you look into state machines if your game is going to get complex.

Code: [Select]
                // Couple of ways to do it.

                // #1 Player position is the same as his previous position
                if(playerPos == prevPlayerPos){
                           // change animation to idle
                }
                // #2 Player velocity = 0, player is not moving
                if(playerVel.x == 0 && playerVel.y == 0){
                           // change animation to idle
                }
 
                #3
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Left)) {
// change animation to left
}
else if (sf::Keyboard::isKeyPressed(sf::Keyboard::Right)) {
// change animation to right
}
                else{
                        // change animation to idle
                }
}

Hope this helps you get started.

8
General / Re: CPU usage 100% help
« on: June 04, 2017, 03:07:48 pm »
The frames are still locked to 60 its just using 100% cpu time.

9
General / CPU usage 100% help
« on: June 03, 2017, 05:24:02 pm »
Quick question
Why is my cpu usage at 100% when I enable vsync ?
If I used window.setFramerateLimit(60) this is not the case and the cpu usage is relatively low

My graphics card is a nvidia gtx970.
Thanks

Code: [Select]
int main()
{
sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");
window.setVerticalSyncEnabled(true);

while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event)){
if (event.type == sf::Event::Closed)
window.close();
}
window.clear();
window.display();
}
return 0;
}

10
General / Query about handling input across many classes
« on: January 26, 2017, 01:57:33 am »
Just wondering what is the correct way to handle input across many classes. Example title scene, game scene.
Should each scene have sf::event or is there a preferred way for going about this.

Thanks

11
General / Re: Setting up shader problems
« on: October 30, 2016, 12:43:18 am »
Problem solved, just created a sf::shader * m_shockwave;
m_shockwave = &m_shaders.get(Shaders::Shockwave);

Still learning.

12
General / Setting up shader problems
« on: October 29, 2016, 11:45:20 pm »
Just looking over the asset SFML manager on Git and wondering the following.

// Loads Shader into a map
m_shaders.load(Shaders::Shockwave, "../resources/shader/shockwave.vert", "../resources/shader/shockwave.frag");

// x = shader in the map
sf::Shader &x = m_shaders.get(Shaders::Shockwave);

If I had a shader created in my .h file how do I go about adding the shader stored in my map to the shader I created ?

Or is it better to ignore an assest manager for shaders and just loadFromFile ?

13
General / Screen wrap with views
« on: October 29, 2016, 12:42:13 pm »
I am looking for advice to approach this problem.

The game will be 4 screens across.
The view will be 1 screen in size.
My player will always be in the centre of the screen.
When the player centre x point > 4th screen centre you should see the 1st screen again.

Thanks in advance

14
General / Re: Query about data structure for stateManager
« on: October 15, 2016, 02:28:32 am »
Yes of course there will be a class lol.

What I mean is, whats the best solution for changing scenes, deleting, checking if scene exists before creating a new one etc. Apologies  if my questions wasn't clear.

15
General / Query about data structure for stateManager
« on: October 14, 2016, 11:42:20 pm »
Just inquiring what would be considered a good data structure to use for a manager of states ?

Pages: [1] 2
anything