• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.

Gilla

Members
  • Content count

    3
  • Joined

  • Last visited

Community Reputation

100 Neutral

About Gilla

  • Rank
    Newbie
  1. I fully understand not wanting to read through my code to find bugs. Is there some more information I can give that might help me get a better idea about what I'm missing. Most of my code there is just repeated for the 4 sides. Let me try and trim it down for readabilities sake. [code] public void bottom(Entity entity, editor.MapComponent map){ /* * calculate which tile the bottom of entity is in */ map.rowIndex = (int) ((entity.Y + entity.Height ) / map.tileHeight); // find the row bottom of entity is in for (float x = (entity.X); x <= ((entity.X) + entity.Width); x += map.tileWidth){ // check each column the bottom of the entity is in map.columnIndex = (int) (x / map.tileWidth); // the (int) casts the entity.x float into an int so I can do the calculation map.selectedTile = map.map[map.rowIndex][map.columnIndex]; if( map.selectedTile == 1){// tile is unwalkable collision is true entity.collision[0] = 1; } } //check the bottom right column entity is in map.columnIndex = (int) (( (entity.X ) + entity.Width) / map.tileWidth); map.selectedTile = map.map[map.rowIndex][map.columnIndex]; if( map.selectedTile == 1){ entity.collision[0] = 1; } } [/code] Some where my code is picking up collision on both the horizontal and verticle movement, when it should only be one of the other if my code has moved him correctly.
  2. [quote name='FlyingDutchman' timestamp='1317104701' post='4866327'] I think I had the same problem. I fixed it by checking first IF the player hits the tile.. than from which side.. than i write all the hits in one char.. when i update my player i update his position, than read it out if have had hit and from where and update again.. It had also to do with the View Direction.. Go to this thread: [url="http://www.gamedev.net/topic/607049-sdl-efficient-collision-detection/"]http://www.gamedev.n...sion-detection/[/url] post #8 something contains my code... The trick is to go through all the tiles in the environment of the player, so the grid around him, and check if there is AT LEAST one hit on one tile with the flag isWalkable no.. and when yes from which direction. So before i loop through so 9 tiles around the player, i set 4 bools for the direction to false. than i check, as soon as i have a hit, the bool goes true.. after the loop i write the 4 values in an char go back and test against the current viewDirection. Than i update .. [/quote] As far as I can tell that's the way I'm doing it. The character can only collide with something in the direction he's moving, so I can use his velocity to determine that. No reason to check for collision on the top of him if he's falling. If he's falling I check for collision on his bottom side. Moving right, I check his right side, ect. I also check for collision on the entire side of the direction he's moving. That is the for loops you see. If he were falling I'd check his bottom left corner. Then a tile width to the right. Continue until you reach his bottom right corner. If I have found a collision I move the character to the out side of the tile he collided with. I do this once for his vertical collision, and then again with his horizontal. My issue seems to be my collision component is picking up a collision on an axis that should already be solved and is stopping my character from moving. For instance. On the ground he can't move left or right but can jump. When jumping and touching a wall he can' fall or rise. I've poured over this code dozens of times and I can't see where my logical error is. I really need a fresh set of eyes on it. Thanks
  3. I'm making a 2D game with a tile engine. The issue seems to be my code is testing vertical and horizontal collision in a different order then I intended, causing the sprite get pushed off the screen when colliding. Or in some cases being locked in place due to faulty collision. My code is fairly simple so I can't see why it's failing. Here is the collision component, and I'll explain the code below. [code]public class CollisionComponent { float x, y; /* * This here is a collision array * I know, wtf right? * He'eres the idea. * I need to test for verticle and horizontal collision seperatly. * If i don't then my game will ignore one for the other. This causes * falls through floors and stuff. With collision being an array * I can have one function return two values intead of two functions * returning one value each. */ public void checkTouching(Entity entity, editor.MapComponent map ){ entity.collision[0] = 0; entity.collision[1] = 0; /* * Entity is falling, check bottom side collision */ if (entity.verticleVelocity > 0.0f){ bottom (entity, map); if (entity.collision[0] == 1){ entity.Y = ((map.rowIndex * map.tileHeight) - entity.Height) ; entity.verticleVelocity = 0.0f; } } /* * Entity is rising, check top side for collision */ else if (entity.verticleVelocity < 0.0f){ top (entity, map); if (entity.collision[0] == 2){ entity.Y = ((map.rowIndex + 1) * map.tileHeight); entity.verticleVelocity = 0.0f; } } /* * Entity is moving right, check right for collision */ if (entity.Velocity > 0.0f){ right(entity, map); if (entity.collision[1] == 3){ entity.X = ( ((map.columnIndex ) * map.tileWidth) - entity.Width) ; } } /* * Entity is moving left, check left for collision */ else if (entity.Velocity < 0.0f){ left(entity, map); if (entity.collision[1] == 4){ entity.X = ((map.columnIndex + 1) * map.tileWidth); } } } public void bottom(Entity entity, editor.MapComponent map){ /* * calculate which tile the bottom of entity is in */ map.rowIndex = (int) ((entity.Y + entity.Height ) / map.tileHeight); for (float x = (entity.X); x <= ((entity.X) + entity.Width); x += map.tileWidth){ map.columnIndex = (int) (x / map.tileWidth); // the (int) casts the entity.x float into an int so I can do the calculation map.selectedTile = map.map[map.rowIndex][map.columnIndex]; if( map.selectedTile == 1){ entity.collision[0] = 1; } } /* * this copy pasta code is horrible I know ..... same as above * it's actually kind of meta now as I just copy pasta'd the * copy pasta code for each side of the sprite.... */ map.columnIndex = (int) (( (entity.X ) + entity.Width) / map.tileWidth); map.selectedTile = map.map[map.rowIndex][map.columnIndex]; if( map.selectedTile == 1){ entity.collision[0] = 1; } } public void top(Entity entity, editor.MapComponent map){ /* * calculate which tile the top of entity is in */ map.rowIndex = (int) ((entity.Y ) / map.tileHeight); for (float x = (entity.X); x <= ((entity.X ) + entity.Width); x += map.tileWidth){ map.columnIndex = (int) (x / map.tileWidth); // the (int) casts the entity.x float into an int so I can do the calculation map.selectedTile = map.map[map.rowIndex][map.columnIndex]; if( map.selectedTile == 1){ entity.collision[0] = 2; } } /* * this copy pasta code is horrible I know ..... same as above * it's actually kind of meta now as I just copy pasta'd the * copy pasta code for each side of the sprite.... */ map.columnIndex = (int) (( (entity.X) + entity.Width) / map.tileWidth); map.selectedTile = map.map[map.rowIndex][map.columnIndex]; if( map.selectedTile == 1){ entity.collision[0] = 2; } } public void right(Entity entity, editor.MapComponent map){ /* * calculate which tile the right of entity is in */ map.columnIndex = (int) ((entity.X + entity.Width ) / map.tileWidth); for (float y = (entity.Y) ; y <= ((entity.Y ) + entity.Height); y += map.tileHeight){ map.rowIndex = (int) ( (y) / map.tileHeight); // the (int) casts the entity.x float into an int so I can do the calculation map.selectedTile = map.map[map.rowIndex][map.columnIndex]; if( map.selectedTile == 1){ entity.collision[1] = 3; } } /* * this copy pasta code is horrible I know ..... same as above * it's actually kind of meta now as I just copy pasta'd the * copy pasta code for each side of the sprite.... */ map.rowIndex = (int) (((entity.Y) + entity.Height) / map.tileHeight); map.selectedTile = map.map[map.rowIndex][map.columnIndex]; if( map.selectedTile == 1){ entity.collision[1] = 3; } } public void left(Entity entity, editor.MapComponent map){ /* * calculate which tile the right of entity is in */ map.columnIndex = (int) ((entity.X) / map.tileWidth); for (float y = (entity.Y) ; y <= ((entity.Y ) + entity.Height); y += map.tileHeight){ map.rowIndex = (int) ((y) / map.tileHeight); // the (int) casts the entity.x float into an int so I can do the calculation map.selectedTile = map.map[map.rowIndex][map.columnIndex]; if( map.selectedTile == 1){ entity.collision[1] = 4; } } /* * this copy pasta code is horrible I know ..... same as above * it's actually kind of meta now as I just copy pasta'd the * copy pasta code for each side of the sprite.... */ map.rowIndex = (int) (( (entity.Y) + entity.Height) / map.tileHeight); map.selectedTile = map.map[map.rowIndex][map.columnIndex]; if( map.selectedTile == 1){ entity.collision[1] = 4; } } } [/code] It is rough I know. I hold the collision results in a 2d array. The first index hold vertical collision(0 for not, 1 for collision on bottom, 2 for collision on top), and I use the second index for the horizontal collision. I test verticle collision first and move the sprite if collision was true. I then test horizontal collision and so blah blah. The rest of my code basically works by polling input (which only changes velocity), applying physics (which applies the velocity to the sprite's position), then testing collision and finally updating the screen. I've included all my source if you want to look at it, but the collision code should be enough. Any ideas where I'm going wrong here? I think this collision code should work.