Jump to content
  • Advertisement

JWColeman

Member
  • Content Count

    162
  • Joined

  • Last visited

Community Reputation

147 Neutral

About JWColeman

  • Rank
    Member

Personal Information

  • Role
    Amateur / Hobbyist
  • Interests
    Programming

Social

  • Github
    https://jwcoleman87.visualstudio.com/MYGAME2

Recent Profile Visitors

3943 profile views
  1. JWColeman

    Dungeon Crawler Challenge - Tile Movement!

    The thing about this code, is that I know I will eventually use it again, it just doesn't have much of a place in a tile based environment. I would have to configure my core objects to operate with or without it. Currently my game object relies on a position derived from it's physical component. So I would have to make that like, optional. Somehow :D. Refactoring sucks when there is a known deadline :).
  2. JWColeman

    Dungeon Crawler Challenge - Tile Movement!

    I'm beginning to think that I need to rework this so that I'm not using a physics class in order to accomplish this task. I took a bit of a broad stance on what physics was when i first started developing this thing. Essentially, I said to myself, if it moves, its physics. But it may be that I've overcomplicated my code following this rule, not sure. Like, currently, I'm using AABB collision in a map/tile/grid environment. and I'm not sure if that makes sense. I could just simply say, is the map tile you want to move to walkable? yes/no, do logic. But instead, I'm going through the steps to detect a collision and respond appropriately. This is what my physics class is currently doing. Also, all positions for game objects are derived from physics. If I tell a game object to move, its updating the physical component, which then in turn updates the user (the game object). This might be a level of complexity I can do without.
  3. JWColeman

    Dungeon Crawler Challenge - Tile Movement!

    Lol, I should really examine my code before i post it. So many redundant if else statements!
  4. Hello all, since the Frogger Challenge I have been hard at work doing some cleanup in my "engine" and adding a few features that were missing from the first challenge. Specifically, I was able to add add in a state machine as well as figured out how to use SFML for poller based input. I decided that I didn't have enough of one type of art to fully flesh out the graphics of a dungeon crawler, they were all a bit mismatched and I decided to forego frankensteining it together, so I went over to Oryx Design Labs and got their Ultimate Fantasy Tileset! One of my first major hurdles was that I decided I wanted to use tile based movement rather than the free movement that I used in the Frogger Challenge. I'm trying to slightly mimic the kind of motion i see in Sproggiwood and Paper Dungeons Crawler. I visited the forums for a while and ended up coming up with my own flavor of tile based movement that I believe at least is a close match to what I'm seeing in these games. I wanted diagonal movement, but I wanted everything locked to the tiles. and I think I have accomplished that at this time! See Below: 2018-12-24_00-10-03.mp4 This was more of a task than I thought it would be, but here is the code that makes it work, I'm definitely open to some suggestions here! Firstly, input! if (sf::Keyboard::isKeyPressed(sf::Keyboard::W) && sf::Keyboard::isKeyPressed(sf::Keyboard::D)) { if(gameobjects[0]->getPhysics()->inMotion == false) { gameobjects[0]->setVelocity(XMFLOAT3{ float(.025) * dt,float(.025) * dt, 0 }); gameobjects[0]->nextmapcoords.x = gameobjects[0]->mapcoords.x + 1; gameobjects[0]->nextmapcoords.y = gameobjects[0]->mapcoords.y + 1; } } else if (sf::Keyboard::isKeyPressed(sf::Keyboard::W) && sf::Keyboard::isKeyPressed(sf::Keyboard::A)) { if (gameobjects[0]->getPhysics()->inMotion == false) { gameobjects[0]->setVelocity(XMFLOAT3{ float(-.025) * dt,float(.025) * dt, 0 }); gameobjects[0]->nextmapcoords.x = gameobjects[0]->mapcoords.x - 1; gameobjects[0]->nextmapcoords.y = gameobjects[0]->mapcoords.y + 1; } } else if (sf::Keyboard::isKeyPressed(sf::Keyboard::S) && sf::Keyboard::isKeyPressed(sf::Keyboard::D)) { if (gameobjects[0]->getPhysics()->inMotion == false) { gameobjects[0]->setVelocity(XMFLOAT3{ float(.025) * dt,float(-.025) * dt, 0 }); gameobjects[0]->nextmapcoords.x = gameobjects[0]->mapcoords.x + 1; gameobjects[0]->nextmapcoords.y = gameobjects[0]->mapcoords.y - 1; } } else if (sf::Keyboard::isKeyPressed(sf::Keyboard::S) && sf::Keyboard::isKeyPressed(sf::Keyboard::A)) { if (gameobjects[0]->getPhysics()->inMotion == false) { gameobjects[0]->setVelocity(XMFLOAT3{ float(-.025) * dt,float(-.025) * dt, 0 }); gameobjects[0]->nextmapcoords.x = gameobjects[0]->mapcoords.x - 1; gameobjects[0]->nextmapcoords.y = gameobjects[0]->mapcoords.y - 1; } } else if (sf::Keyboard::isKeyPressed(sf::Keyboard::D)) { if (gameobjects[0]->getPhysics()->inMotion == false) { gameobjects[0]->getPhysics()->SetVelocityX(float(.025) * dt); gameobjects[0]->nextmapcoords.x = gameobjects[0]->mapcoords.x + 1; gameobjects[0]->nextmapcoords.y = gameobjects[0]->mapcoords.y; } } else if (sf::Keyboard::isKeyPressed(sf::Keyboard::A)) { if (gameobjects[0]->getPhysics()->inMotion == false) { gameobjects[0]->getPhysics()->SetVelocityX(float(-.025) * dt); gameobjects[0]->nextmapcoords.x = gameobjects[0]->mapcoords.x - 1; gameobjects[0]->nextmapcoords.y = gameobjects[0]->mapcoords.y; } } else if (sf::Keyboard::isKeyPressed(sf::Keyboard::W)) { if (gameobjects[0]->getPhysics()->inMotion == false) { gameobjects[0]->getPhysics()->SetVelocityY(float(.025) * dt); gameobjects[0]->nextmapcoords.x = gameobjects[0]->mapcoords.x; gameobjects[0]->nextmapcoords.y = gameobjects[0]->mapcoords.y + 1; } } else if (sf::Keyboard::isKeyPressed(sf::Keyboard::S)) { if (gameobjects[0]->getPhysics()->inMotion == false) { gameobjects[0]->getPhysics()->SetVelocityY(float(-.025) * dt); gameobjects[0]->nextmapcoords.x = gameobjects[0]->mapcoords.x; gameobjects[0]->nextmapcoords.y = gameobjects[0]->mapcoords.y - 1; } } So, I had to add some information to my gameobject class. Specifically, map coordinates, and next map coordinates. Then I had to limit my input to only when inmotion is false, which will be false whenever I have successfully locked to a tile. Now, to make all the map coordinates work correctly, I needed to be able to update the next map coordinates and current map coordinates in my game object update loop, using this code: void Game::UpdateMapPosition(GameObject * object) { XMFLOAT3A objectpos = object->getPosition(); int xcount = floor(objectpos.x / map->tileSizeX); int ycount = floor(objectpos.y / map->tileSizeY); object->mapcoords.x = xcount; object->mapcoords.y = ycount; XMFLOAT3A pos = map->At(xcount, ycount); if (object->currentDirection == Facing::UP_RIGHT || object->currentDirection == Facing::DOWN_LEFT) { if (pos.x == map->At(object->nextmapcoords.x, object->nextmapcoords.y).x) { object->getPhysics()->SetVelocityX(0); } else if (pos.y == map->At(object->nextmapcoords.x, object->nextmapcoords.y).y) { object->getPhysics()->SetVelocityY(0); } } else if (object->currentDirection == Facing::UP_LEFT || object->currentDirection == Facing::DOWN_RIGHT) { if (pos.x == map->At(object->nextmapcoords.x, object->nextmapcoords.y).x) { object->getPhysics()->SetVelocityX(0); } else if (pos.y == map->At(object->nextmapcoords.x, object->nextmapcoords.y).y) { object->getPhysics()->SetVelocityY(0); } } else if(object->currentDirection == Facing::RIGHT || object->currentDirection == Facing::LEFT) { if (pos.x == map->At(object->nextmapcoords.x, object->nextmapcoords.y).x) { object->getPhysics()->SetVelocityX(0); } else if (pos.y == map->At(object->nextmapcoords.x, object->nextmapcoords.y).y) { object->getPhysics()->SetVelocityY(0); } } else if(object->currentDirection == Facing::UP || object->currentDirection == Facing::DOWN) { if (pos.y == map->At(object->nextmapcoords.x, object->nextmapcoords.y).y) { object->getPhysics()->SetVelocityY(0); } else if (pos.y == map->At(object->nextmapcoords.x, object->nextmapcoords.y).y) { object->getPhysics()->SetVelocityY(0); } } } Again, definitely open to suggestions for cleanup here, this is what I was able to throw together given my current knowledge and understanding. The end result is definitely functional though! The next thing I think I want to do is incorporate the mouse in some kind of way, but I haven't thought up any ideas yet, lets here what you think! There are a few things I like about this setup, and of course a few that I don't like. I think the code is pretty easy to read, and I like that. However, It feels a bit bloated and large for the job its actually accomplishing, definitely some room for some tidying up and optimization. Anyways I think I've made a good start for the next challenge. What's next? Maybe make some of my objects interactable, like boxes and crates and junk. Loot is, I believe, the biggest part of the requirement, aside from beating the bad guys!
  5. I'm really not certain, and as for the gimp images, I'm pretty sure they are rgba, could be wrong though. Like I said, I'm really no pro when it comes to the inner workings of this stuff, and fortunately, it looks as if you've pretty much solved your problem. Maybe someone with more experience can chime in and thoroughly explain why its behaving this way.
  6. Well, likely, my best guess, is that stbi_load is putting something other than a null value in the A channel when its not present, therefore your shader handles it normally.
  7. It worked with the old image?
  8. Also, it may be that if you're pushing an RGBA through to your device but only sending it data for an RGB, it could be that each frame your RGB is getting shifted by sizeof(A)... I'm really no expert on the rendering pipeline but these are oddities that I'm aware can occur when data is not pairing up just right.
  9. Yep, Now, how to use it, is a whole other discussion I'm sure openGL has a device debug layer as well, its possible it could be throwing some warnings at you because of this.
  10. It sounds like your shader is the problem then, a null value in an alpha channel in your shader could cause some unexpected behavior. Have you tried stepping through the graphics debug and checking the alpha value, when from your paint file, the alpha isn't there? The quick solution is to just not use any png files that don't have an alpha
  11. So, the file from gimp worked but not from paint?
  12. How many channels does your image have? Could there be a problem where you are reading in a channel that isn't there, or, applying a value to a channel that is causing the distortion? IIRC paint does not support alpha channel
  13. What I mean is are they all packed into one image, or individual images. It looks like they are individual images so i dont think that is the problem (U/V's)
  14. Are you using individual images for the arrows? Or, are they packed together in an atlas? If you're sure it's not UV's... Try making your own set of arrows in gimp or something, maybe that will change it?
  15. So, as a hobbyist, with minimal formal training in C++ or object oriented programming, how relevant is this stuff to me? Feels like just a lot of discussion waaaaay above my head rn :).
  • 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!