Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

110 Neutral

About RamblingBaba

  • Rank

Personal Information

  • Interests

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Hello, So I've been messing around with isometric tiles. I've come across a problem when I'm using isometric tiles that are different sizes. These tiles are 156x86 and I've looked at a few sites and they never display correctly. While others work when they are the same size, like my 40x40 isometric tile. Are there formulas that only work if the dimensions are the same and vice-versa? If so, how can I switch between them? Right now this works for me with my 156x86 tile, but wouldn't if I used the 40x40 tiles: I believe for the same dimension tiles, I had to times the Y-axis by an additional 0.5 to get it to work. sf::Vector2f screenToIso(sf::Vector2i coord, sf::Vector2i tileSize) { return sf::Vector2f((coord.x - coord.y) * tileSize.x * 0.5, (coord.x + coord.y) * tileSize.y * 0.5); } All the formulas for finding out which tile I am clicking have been conflicting as well. One tile is reading as 4 tiles (for each axis). So the top (0,0) coordinate also reads as (1,0), (0,1), and (1,1). Dividing by 4 gets me the correct tile with the different dimension tiles. The only reason I tried 4 was that various sites sometimes were dividing by 4. So I was simply playing around. (I put a comment 4 of where I do that division). sf::Vector2i isoToScreen(sf::Vector2i coord, sf::Vector2i tileSize) { return sf::Vector2i((coord.x / (tileSize.x / 2)) + (coord.y / (tileSize.y / 2 /*4*/)) / 2, (coord.y / (tileSize.y / 2)) - (coord.x / (tileSize.x / 2)) / 2 /*4*/); } For those that know SFML, this is how I am getting this. I realize I could possibly be doing something wrong here. sf::Vector2f mousePos = window.mapPixelToCoords(sf::Mouse::getPosition(window),view); if (sf::Mouse::isButtonPressed(sf::Mouse::Left)) { // pointing out a float makes it read it as 5 tiles, adding (2,2) sf::Vector2i pos{isoToScreen((sf::Vector2i)mousePos,m_tile_size)}; std::cout << pos.x << ", " << pos.y << "\n"; } When I go to display them in a loop: for(...){for(...){ sf::Vector2f pos = { screenToIso({(float)x,(float)y},m_tile_size) }; pos.x -= m_tile_size.x / 2; pos.y -= m_tile_size.y / 2; sprite.setPosition(pos); window.draw(sprite); So is there a more global formula to use that won't cause conflicts between the same or different sizes? Any help would be greatly appreciated, I've gone to many sites and they seem to have differences. PS: This isn't about using a bigger tile than the floor tiles. It's just about understanding why one tile works and the other doesn't.
  2. Hello, So I have been programming with C++ for 2.5 years now. I have been interested in checking out C# for fun. My question is pretty simple. Does C# use a form typically for their games? The simple game examples I have watched on YouTube reminds me A LOT of Visual Basic. Was this just an easy way to show you C#? Or using the form is a big part of C#? Or is it nothing more than using something like MFC and completely irrelevant to making games? Thanks
  3. Hello, So I'm reading a book called SFML By Example C++ . I'm having trouble using my own sprite sheet and I have been messing around with their equation for getting the correct tile. In the Map class, they have an enum called Sheet that has the TileSize = 32, Sheet_Width = 250, Sheet_Height = 250. They determine the texture rect like this sf::IntRect tileBoundaries(m_id % (Sheet::Sheet_Width / Sheet::Tile_Size) * Sheet::Tile_Size, m_id / (Sheet::Sheet_Height / Sheet::Tile_Size) * Sheet::Tile_Size, Sheet::Tile_Size, Sheet::Tile_Size); What I noticed is the Y-axis does not determine the correct tile if the sheet isn't the same dimensions. So what I did is divide m_id by 2 and it seems to work for the most part. I also was using 64 for the tile size instead of 32 ...., m_id / 2 / (Sheet::Sheet_Height / Sheet::Tile_Size) * Sheet::Tile_Size, Sheet::Tile_Size, Sheet::Tile_Size); I decided to just run their formula vs my formula adjustment vs keeping the dimensions the same as the X axis in the console to see what was going on. Their formula was always off, and my adjustment by dividing by 2 worked until a specific point. When I was plugging in 896 and moving up by 64 to test numbers it began to fall apart. Is there a specific equation I could do with Y where I wouldn't have to worry about it falling apart? I don't have a sprite sheet that big, but 15 sprites down don't seem unrealistic and I'd like to be accurate every time. What confuses me is using the same dimensions for X and Y always worked, but I'm not sure if that could lead to some unwanted problems. I'd like to say it would not and I'd like to confirm that. I just find it pointless to have a Sheet_Height if the equation needs equal dimensions as the Sheet_Width. They specifically mention that the size doesn't' have to be the same. But it might as well be called SheetSize. Thanks, I hope that makes sense.
  4. RamblingBaba

    Explain to me Scene Node/Manager

    Apology, I don't use GameDev regularly so I forgot all about this post. From what I researched it seemed like it really isn't for every game genre in general. That is an excellent idea though, despite having zero interest in either looking into it a bit more might be beneficial. I just find it interesting, the example is always a space game. I was able to set up an example I came across where you add one character (main node so to speak) and you could toggle to any character added, and adding additional character would allow you to move any character added under the toggled (highlighted) character you choose like a big chain. The first character added could move the whole chain. Very interesting. Thanks for the suggestion.
  5. Hello everyone, hope today's been nice. I use C++ and trying to become better with game programming concepts. I was wondering if someone could perhaps explain to me more about SceneNodes/SceneManagers. I see how you would declare things such as a circle player (basic example) as a node, which could be anything from a Player or enemy and the scene manager would add this all to create a "Level". Even the Map would be a Scene. I have a great example of one (and 2 from a book), but for whatever reason, I can't understand what it replaces? What would make you say to yourself, "That would be a great idea to use for this!" Can anyone maybe explain this like you would a 5-year-old and tell me perhaps another way to think about this? I usually see this concept in games like Asteroids and I have a few books who use that as well! When I say like a 5-year-old I don't necessarily need to know how it works or the intricate details, but how you would use it, or perhaps, even prefer it? A simple 2D engine setup I usually use is...StateManager (Splash, Menu, GameState), EntityManager, InputManager, AudioManager, TextureManager, Map class (tiles), and components for the entity. It seems to me these SceneManagers replaces your typical Map class with a Scene class and you use Nodes for your entities. Which is why I believe I'm having a hard time understanding when/why this is a great addition to have. It seems like it usually is fit with specific games. I realize a "Map class" could be done many ways but just think of this complete basic terms (might be hard for some of you experts) so to sum it up in this case just reads a file, creates an array of a Tile struct, sets the sprite for each tile, and displays the intended map. I'll stop here before I go on. I hope this question makes SOME kind of sense. I don't feel I did a great job explaining my question. I have books that use it, I see how it works, but I have difficulty understanding it for my type of games (RPG/Old School Rogue) and if this is more of niche use. Thanks, everyone!
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!