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

Pages: 1 ... 13 14 [15] 16 17 ... 25
211
whats your operational system, version of SFML, code editor, compiler, etc?...

212
General / Re: Weird Behaviour with tilemap
« on: July 13, 2020, 06:12:58 pm »
i'm also not sure of what is "weird and messed up", but it seems to be a problem with your sLevel. is that string the tilemap internally? why not an array or vector of ints? try to change that, because your problem could be an inconsistency between your sLevel x and y size and your intended x and y size.

213
General / [SOLVED] need a better collision idea
« on: July 11, 2020, 04:54:41 pm »
hello!
I'm creating this city like game, but having some trouble with collision between the cursor and the building tiles.
my first idea (which is working now) was to detect collision with only the ground area of each building. but its extremely counter intuitive. video explaining:
http://www.youtube.com/watch?v=6bubui54T_c

by 7 seconds I move the cursor over a building, but the selected tile is the ground behind it.

I need some insight on how to make a better collision detection, considering that buildings have different heights (and street tiles have almost no height at all).
observation: the tiles are made of sf::Quads (shaped as parallelograms/diamonds, NOT rectangles) in a sf::VertexArray.

original tile image:


tiles boundings before rotating the view (notice that most buildings won't use all the tile size).


I don't know if it is of any help, but the building tiles before rotating the view:


and after rotating:


grid lines are for reference.
any idea is apreciated. thanks in advance!  ;D

214
Graphics / Re: Should I use sf::Texture or sf::Image
« on: June 23, 2020, 01:33:37 pm »
there is no sense in doing the first, since you'll need to load it in a texture anyway.
sf::Image is ONLY for when you want to modify that image (like drawing), for everything else use a Texture.

215
Window / Re: Sprite can't be positioned
« on: November 30, 2019, 08:10:54 pm »
why are you using desktop mode, instead of your sf::RenderWindow variable?

I would do it like
sprite.setPosition((float)render_window.getSize().x/2-sprite.getSize().x/2, (float)render_window.getSize().y/2-sprite.getSize().y/2)

216
General / Re: Moving a view with mouse
« on: November 08, 2019, 11:45:45 am »
did you try this from the tutorials?

217
Graphics / Re: Sprites and problems with a onboardgrafic ..
« on: November 06, 2019, 04:53:16 pm »
could be a driver problem.
other than that, we can only help if you create a minimal code to reproduce the problem and post it here.
and your "for information" link is in another language, so it no help at all...

218
System / Re: [Help] I don't understand sf::Time, sf::Clock
« on: November 04, 2019, 03:14:33 pm »
the tutorials are not awful, but you need to have the slightest idea of what you are doing.
what exactly didnt work?

219
System / Re: [Help] I don't understand sf::Time, sf::Clock
« on: November 04, 2019, 10:30:12 am »
I don't think there is much to explain. sf::Time is a specific time, and sf::Clock is a time that change automatically as time passes.

You can make something like:
sf::Clock clock;
sf::String string;
if (clock.getElapsedTime().asSeconds >= sf::seconds(10){
    clock.reset();
}
string.setText(clock.getElapsedTime().asSeconds());
 

I typed from my phone, so I didnt tested it ?

Also, did you check the tutorials?
https://www.sfml-dev.org/tutorials/2.5/system-time.php

220
Graphics / Re: get click on an isometric tile
« on: November 02, 2019, 08:43:38 pm »
actually the article is exactly what you need. you should calculate the tiles position with proper math. the way you are trying to do won't work, simply because a isometric tile has different bounds than the FloatRect.

OR you could do another way: create square tiles, calculate the mouse position, the selected tile, all based on square tiles. and at the end of everything, you just rotate the whole sf::View by 45 dregrees.

221
SFML projects / Re: Screenshot Thread
« on: October 29, 2019, 04:55:55 pm »
I'm working on a isometric tilemap city. so far it works good, and I haven't seen any unexpected bugs in the past few days.
what it does:
-creates a tilemap based on binary space partitioning (or atleast I think it can be described like that  :P)
-gives a "value" atribute to each tile (tiles near to the city center tend to have higher values)
-camera is controlled by holding down the right mouse button and moving it around

building the random/procedural city:


grey tiles are streets:


and a video (warning: it takes 1:45 building the map)
http://www.youtube.com/watch?v=gYVybRyChNQ

next step is to change these square tiles to hexagonal shapes, to fake 3d axes in isometric :)

222
Graphics / Re: strange behaviour with View and Viewport
« on: October 28, 2019, 04:43:06 pm »
works perfectly! thanks again!  ;D

223
Graphics / Re: strange behaviour with View and Viewport
« on: October 28, 2019, 02:34:35 pm »
thank very much to both of you
i got up with this:

if (sf::IntRect(view_one.getCenter().x-view_one.getSize().x/2, view_one.getCenter().y-view_one.getSize().y/2, view_one.getSize().x, view_one.getSize().y).contains(sf::Vector2i(pos_in_view))){


I don't know if this would be used frequently, but wouldn't it be interesting to add such function in the sf::View class?

224
Graphics / Re: strange behaviour with View and Viewport
« on: October 26, 2019, 05:34:19 pm »
hi! after your response, I was looking what I could be doing wrong.
you are right, the view size and viewport are not interfering with each other. turns out I was making the calculation of the viewport in a wrong way. I was using these lines:
sf::Vector2f pos_in_view = window.mapPixelToCoords(sf::Mouse::getPosition(window), view_one);
if (sf::IntRect(
view_one.getCenter().x-view_one.getSize().x/2,
view_one.getCenter().y-view_one.getSize().y/2,
view_one.getCenter().x+view_one.getSize().x/2, view_one.getCenter().y+view_one.getSize().y/2).contains(sf::Vector2i(pos_in_view))){
but this temporary IntRect if not the same size the viewport occupies in the window; it just has the size of the View, BEFORE being looked at by the view itself, what is short for "doesn't make any sense at all".


but since I'm already here let me ask, then: how do I check if the cursor is inside a particular Viewport?
I tried this:
sf::Vector2f pos_in_view = window.mapPixelToCoords(sf::Mouse::getPosition(window), view_one);

if (sf::FloatRect(0, 0, view_one.getViewport().width*window.getSize().x, view_one.getViewport().height*window.getSize().y).contains(pos_in_view)){
but it didn't worked, and now I have no idea at all on how to do it  :P

225
Graphics / Re: strange behaviour with View and Viewport
« on: October 26, 2019, 10:08:13 am »
I did that. It doesn't say anything about the view center; just states that the reset() function resets the rotation angle.
About the coordinates, I find it hard to believe that it's intended. Changing the view size should really change the viewport position in the screen!?
I mean, if you set the viewport and then zoom, the viewport is messed up.

Pages: 1 ... 13 14 [15] 16 17 ... 25
anything