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

Pages: 1 ... 5 6 [7] 8 9 ... 16
91
Window / Re: Events outside of Main Thread
« on: October 02, 2017, 04:47:49 pm »
Can you not keep the Window creation and event polling in the main thread and move your slow calculations to the other thread?

92
Graphics / Re: Inclination of objects from Tiled Map Editor
« on: September 14, 2017, 07:45:35 pm »
It sounds like your basic problem is that you want a way to check collisions between rotated rectangles? SFML doesn't provide a built-in way to do this, but you could implement the "separating axis theorem" for this. You can google that term to find a lot more information on it.

93
Window / Re: Cant access to window.draw thru function on C++.
« on: August 25, 2017, 05:59:29 pm »
Are you perhaps trying to draw a sprite after its corresponding texture has gone out of scope and been destroyed? See the section titled "The white square problem" in the sprites and textures tutorial.

If this is not the issue then post a minimal example of your code so we can see what is going on.

94
Quote
Starting from SFML 2.2, when static linking, you will have to link all of SFML's dependencies to your project as well. This means that if you are linking sfml-window-s.lib or sfml-window-s-d.lib for example, you will also have to link opengl32.lib, winmm.lib and gdi32.lib.

Did you do this step, as described in the SFML tutorials?

95
Graphics / Re: Rotation going nuts
« on: July 08, 2017, 12:03:09 am »
As Martin Sand pointed out, it looks like you are trying to treat the origin as an absolute global position, but it should instead be treated as a local position relative to your entity. From the SFML documentation:
Quote
The coordinates of this point must be relative to the top-left corner of the object, and ignore all transformations

96
Graphics / Re: Rotation going nuts
« on: July 07, 2017, 10:05:24 pm »
Can you show us the code where you were setting the origin of the entity?

97
General / Re: class variables reset value after function loop
« on: June 26, 2017, 05:21:59 pm »
It seems to me that your edit is pointing out what the problem is. Every loop you call drawable_objects(). drawable_objects() calls cityA.resourceSetter(10,10,10). resourceSetter will set cityFood to 10. You are therefore resetting cityFood to 10 every loop.

If you don't mind me making a few other suggestions:
  • The way you are using static variables isn't really any better than just using globals. Why not just construct those variables in main() or some class and pass them in as a function parameter where needed?
  • Why does gameTime inherit from overworldLocations?
  • You may want to look up the use of commas in C++. I'm not sure what you are expecting this function to return:
int resourceGetter() {

        return cityFood, cityIndustry, cityPopulation;
}

98
Graphics / Re: 1024 x 1024 tile map
« on: June 23, 2017, 04:47:55 pm »
Like eXpl0it3r, I'm not sure I'm understanding what your actual question is. I think I understand what you are trying to do, but what are you actually stuck on? Here is the tutorial for vertex arrays. Is this the one you read? Do you not know how to even get started or are you just unsure on how to calculate the position of the vertices?

99
Graphics / Re: Problem with text
« on: June 19, 2017, 07:39:05 pm »
sf::RenderWindow window(sf::VideoMode(320, 240), "Font Test");
...
text.setPosition(250, 250);

It looks like you are trying to draw your text outside of the window. Your window height is set to 240 pixels, but you are drawing text with a Y position of 250.

Also, make sure you check the return value of font.loadFromFile("ditr.ttf") to make sure it doesn't fail.

100
Graphics / Re: One Texture Shared to Multiple Sprites
« on: May 26, 2017, 06:05:08 pm »
You should just try out the code you posted and see if it works  :)

What you'll probably find, though, is that it won't do what you want. Sprites only hold a pointer to the texture. They don't internally make a copy of the texture themselves. There is only one texture in memory here, so if you change it then it will impact all of your sprites.

An alternative approach is to make one texture that contains all of your images (a "sprite sheet", PlayerAndEnemy.png). After setting the texture on your sprites, call setTextureRect() to only show the desired piece of the texture.

101
General / Re: Isometric Draw Order
« on: May 23, 2017, 09:26:39 pm »
There is another version of std::sort that takes in a 3rd parameter. The third parameter is a function you can pass in to describe how your objects should be ordered.

http://www.cplusplus.com/reference/algorithm/sort/

The examples on that page should be helpful. Especially make note of the example that uses "myfunction"

102
Graphics / Re: Movement
« on: May 05, 2017, 04:54:48 pm »
Interestingly, someone else just made a post right before you trying to solve the same problem. Are you perhaps working together?

Your problem is that Rect.getRotation() returns the angle in degrees, but sin and cos expect the angle to be in radians.

103
General / Re: Smart Moving Problem
« on: May 05, 2017, 04:42:50 pm »
Make a variable that keeps track of the angle of the spaceship. Use trigonometric functions (such as sin and cos) to calculate how much the spaceship should be moved in the x and y directions based on that angle when the 'up' key is pressed.

104
Graphics / Re: Help with renderWindow not displaying
« on: May 01, 2017, 11:21:50 pm »
Is "cell" an sf::RectangleShape object? If so, do you ever set its size?

is "posOut" an sf::Text object? If so, do you ever set its font?

105
General / Re: undefined reference to...
« on: April 27, 2017, 08:35:52 pm »
Are you 100% sure you downloaded the version of SFML that matches your compiler? Be sure to read everything in that tutorial link you provided (especially the things in the red boxes).

Pages: 1 ... 5 6 [7] 8 9 ... 16
anything