• 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.

Mekuri

Members
  • Content count

    61
  • Joined

  • Last visited

Community Reputation

301 Neutral

About Mekuri

  • Rank
    Member

Personal Information

  • Location
    Denmark
  1. Thanks a lot - I will ;-)
  2. A while ago I participated in Ludum Dare 28, where my entry was a far from finished horror game. I decided that I would continue on that project, and before I knew it I had a completely new project on my hands. I've made a small video showing some basic gameplay from the game- The game is far from done, I estimate around 10-15% done, but I think it's time to get a video out there to hear peoples opinion. I've been working on it in my spare time for a few month now, and during that time I've picked up Blender to do some 3D modelling. Every 3D model in my game, except for the trees, is made by me- Some are better than others, since I am still fairly new to modelling. Anyways I'll stop now and show you the video. Thanks for reading- And thanks for watching!   https://www.youtube.com/watch?v=k8Gdlg5H2K8
  3. Hey all.   Thanks a lot for your replies. I've read through them all and based on that I've decided to use the first method I wrote- Giving a reference to the level to each mob as they are instantiated.   The game I am working on is a 2D tile based game. I really like the idea of a game control object, this way each entity in the game can have their own movement logic, and afterwards the game control unit can handle any collision that might need attention.     You have a good point. The map will always be instantiated first, and then after, the mobs will be placed, based on data from the level class. I think I am going to stick with my first solution, since I can't really see that it should cause any problems.   I might have been a bit unclear in my explanation above (I tend to be that, sorry). But I am actually using polymorphism. I have a base "Actor class" that has several virtual methods like Update and Draw. Both the player, and the mobs inherit from this base class. These are then called through the playscreens update and draw methods accordingly.   This was very helpful. The idea of having methods in the map that assists mobs in finding things near it.. That's a splendid idea, I haven't thought of that. Most of my mobs are going to be more or less static in their behavior, like moving around until they encounter an obstacle, then turn around. Bosses and at least one of the mobs will need to know where the player is though.  Nice to know about how things work in Minecraft- Being a Minecrafter myself, I've always been curious about how things work.    Thanks a lot for all of your replies. You guys have some very nice ideas, that I can definitely use.
  4. For about a year I was working on a game, on a learning by doing basis. This worked well for me, and the result, so far, isn't that bad. I shelved that project for now though, and I started working on a new one, with a somewhat smaller scale. A question that has been bothering me for a very long time, is surfacing again. Let me explain...   When I make a game, I make several "Screen" classes, that each contain a screen, like the menu screen or the playscreen, etc. When the game is playing the playscreen is of course shown. The playscreen then has an instance of a level class, that contains the level array, lists with mobs and items, and the starting location for the player. Each type of mob has it's own class, that derives from a base class (to make it possible to keep them all in the same list). Now this is all well and good, but my problem arises, when I start doing the movement logic for either the player or the mobs. Since each mob has its own movement logic, it will need to check its surroundings for obstacles and such.  And here is the problem - What would be the best way to do this, while maintaining a solid code structure? In my first project, each mob that was created received a reference to the world array, which fixed the problem. This time I was thinking about making the level array static, and then use a public static property to access it from wherever I would need it, but both of those solutions seems.. wrong somehow to me? I mean making my mobs dependent on a static variable in another class, doesn't that somehow break the whole idea of object oriented programming? Passing down a reference somehow seems more preferable, but again, it seems wrong. I would then make the mobs dependent on the level class to be initialized, before it would even be possible to initialize it properly...   Am I seeing ghosts here? Or did I miss a much smoother option?    Thanks for reading.
  5. I was sitting and thinking about this code (I can't test it right now) and thought of a way to check the intersection depth.    I found a possible solution. Wouldn't it be possible to just do the following:   y - top = vertical Intersection Depth  x - left = horizontal Intersection Depth   Since top and left defines the top left point for the rectangle that is created due to the Rectangle based intersection, y and x simply shows how many pixels into that "sub rectangle" we are.    This seems right in my head. Anyone who agrees or disagrees?   Thanks for reading!
  6. I recently started playing around with pixel based collision detection, and it is working as I expected. Currently I use the pixel based collision to determine whether or not the player has hit a dangerous object (like a spike or such). All other "tiles" in my world are still being handled by rectangle based collisions. I would like to change that though.  What I do currently for collision with solid tiles is that I check the intersection depth, one axis at a time, and adjust accordingly. This works fine so far. But now I would like to be able to do pixel based collision responses on my tiles, which means that I can no longer use the intersection depth of two rectangles, because this would clearly give some weird results.   I can't seem to find much about pixel based collision responses online. All I actually want to know is how I get the intersection depth between two images...   The code I use for pixel based collision detection is the following: private bool PixelbasedCollision(Rectangle rect1, Color[] data1, Rectangle rect2, Color[] data2) { int top = Math.Max(rect1.Top, rect2.Top); int bottom = Math.Min(rect1.Bottom, rect2.Bottom); int left = Math.Max(rect1.Left, rect2.Left); int right = Math.Min(rect1.Right, rect2.Right); for (int y = top; y < bottom; y++) { for (int x = left; x < right; x++) { Color color1 = data1[(x - rect1.Left) + (y - rect1.Top) * rect1.Width]; Color color2 = data2[(x - rect2.Left) + (y - rect2.Top) * rect2.Width]; if (color1.A != 0 && color2.A != 0) return true; } } return false; } private Color[] GetTileColorData(int x, int y) { Color[] tmp = new Color[TILE_SIZE * TILE_SIZE]; _tileSheet.GetData<Color>(0 * TILE_SIZE, new Rectangle(_world[x,y].Variant * TILE_SIZE, (int)(_world[x,y].Type - 1) * TILE_SIZE, TILE_SIZE, TILE_SIZE), tmp, 0, tmp.Length); return tmp; } Basically the GetTileColorData method creates an array of the Color based on an image. These are then given as arguments to the PixelbasedCollision method.   I was hoping that it was somehow possible to get the exact collision depth based on what happens in the PixelbasedCollision method, but I'm kind of stuck.   My question in short is:   How can I get the intersection depth between two images in a pixel based collision? - And is the information I need somewhere inside my PixelbasedCollision method?   Thanks for reading! :-)  
  7. Hey again.   I just wanted to check back, and say that I managed to solve the problem. The problem was the two for loops in the WorldCollision method. So basically I had to change the maximum range to check within. See below:   Before for (int x = sprite.Bounds.X / TILE_SIZE - 1; x < sprite.Bounds.X / TILE_SIZE + 2; x++) { for (int y = sprite.Bounds.Y / TILE_SIZE - 1; y < sprite.Bounds.Y / TILE_SIZE + 2; y++) {  After for (int x = sprite.Bounds.X / TILE_SIZE - 1; x < (sprite.Bounds.X + sprite.Bounds.Width) / TILE_SIZE + 1; x++) { for (int y = sprite.Bounds.Y / TILE_SIZE - 1; y < (sprite.Bounds.Y + sprite.Bounds.Height) / TILE_SIZE + 1; y++) I believe that the reason it was jittering is that the player sprite has a different size than the tiles. Each tile is 32X32, while the player sprite varies in size based on the current animation frame (For pixel perfect collision detection). The way I calculate the maximum iteration value (can you say that?) makes sure that it checks the tile exactly next to it, both to the right and downwards, whereas it only did so to the left and upwards before.   Anyways- Thanks for your input, just wanted to post the solution in case someone else could use it :-)
  8.   Nice catch- I need some restructuring there. (Structure is really my weakness :P) - Thanks a lot.   This might very well be it. I won't be able to try this until tomorrow, but I can see why this could cause the jittering.   Thanks a lot for the input :-)
  9.   I removed the above- It was some code I forgot to remove, from when I played around with the physics, earlier. It did not change anything though. Thanks for the input.
  10. Hey there. I recently began on a new project, inspired by my Ludum Dare entry, and I decided to some more solid collision detection than in my other project.   I've finally reached a result that I am fairly happy with, but I experience jitters, that I don't fully understand. When I move right and collide with something, my sprite jitters.. But when going left, it works exactly as intended. Also there are a few corner cases where there's some small jitter.   I do the collision detection and seperation like this:   1. Do horizontal movement. 2. Check and resolve horizontal collisions. 3. Do vertical movement. 4. Check and resolve vertical movement.   For both the horizontal and vertical step, I first check for rectangular collision, and then pixel based within the rectangle. Since I divide both movement and collision handling up in horizontal and vertical, I have a hard time understanding why it jitters.   The code I am using is the following:   Player class handles movement and velocity private void Movement() { PreviousPosition = position; //TODO: Add custom controls, by saving keys in a list or something, and then compare pressed keys to that list, and act accordingly. if (InputController.CurrentKeyboardState.IsKeyDown(Keys.A) || InputController.CurrentKeyboardState.IsKeyDown(Keys.Left)) movement = -1.0f; else if (InputController.CurrentKeyboardState.IsKeyDown(Keys.D) || InputController.CurrentKeyboardState.IsKeyDown(Keys.Right)) movement = 1.0f; else movement = 0f; //For testing jump strength - Final version will have a fixed strength! if(InputController.IsKeyPressed(Keys.OemPlus)) BASE_JUMP_POWER++; else if (InputController.IsKeyPressed(Keys.OemMinus)) BASE_JUMP_POWER--; //Velocity velocity.X += movement * BASE_SPEED; velocity.X *= AIR_DRAG; velocity.Y += GRAVITY; velocity.X = MathHelper.Clamp((float)Math.Round(velocity.X, 4, MidpointRounding.ToEven), -MAX_MOVE_SPEED, MAX_MOVE_SPEED); if (isOnGround) { velocity.Y = MathHelper.Clamp(-velocity.Y * .8f, -MAX_JUMP_SPEED, -BASE_JUMP_POWER); isOnGround = false; } velocity.Y = MathHelper.Clamp((float)Math.Round(velocity.Y, 4, MidpointRounding.ToEven), -MAX_JUMP_SPEED, MAX_FALL_SPEED); } public override void ApplyHorizontalMovement() { position.X += velocity.X; position.X = (float)Math.Round(position.X); } public override void ApplyVerticalMovement() { position.Y += velocity.Y; position.Y = (float)Math.Round(position.Y); } Movement() is called every update cycle. Notice the apply movement methods, those are called by the "playfield" class, during collision handling, as you can see in the following code: blic void WorldCollision(Sprite sprite, bool verticalMovement) { if (verticalMovement) sprite.ApplyVerticalMovement(); else sprite.ApplyHorizontalMovement(); for (int x = sprite.Bounds.X / TILE_SIZE - 1; x < sprite.Bounds.X / TILE_SIZE + 2; x++) { for (int y = sprite.Bounds.Y / TILE_SIZE - 1; y < sprite.Bounds.Y / TILE_SIZE + 2; y++) { Rectangle tmp = new Rectangle(x * TILE_SIZE, y * TILE_SIZE, TILE_SIZE, TILE_SIZE); if (sprite.Bounds.Intersects(tmp)) { if (StaticTileInfo.GetCollisionType(_world[x, y].Type) != Collision.Passable) { if (PixelbasedCollision(sprite.Bounds, sprite.GetTextureData, tmp, GetTileColorData(x, y))) { if (StaticTileInfo.GetCollisionType(_world[x, y].Type) == Collision.Spike) { sprite.IsDying = true; return; } else { if (verticalMovement) { float intersectionDepth = RectangleExtensions.GetVerticalIntersectionDepth(sprite.Bounds, tmp); sprite.Position += new Vector2(0, intersectionDepth); if (StaticTileInfo.GetCollisionType(_world[sprite.Bounds.Center.X / TILE_SIZE, (sprite.Bounds.Bottom + 1) / TILE_SIZE].Type) == Collision.Impassable || StaticTileInfo.GetCollisionType(_world[sprite.Bounds.Left / TILE_SIZE, (sprite.Bounds.Bottom + 1) / TILE_SIZE].Type) == Collision.Impassable || StaticTileInfo.GetCollisionType(_world[sprite.Bounds.Right / TILE_SIZE, (sprite.Bounds.Bottom + 1) / TILE_SIZE].Type) == Collision.Impassable) sprite.IsOnGround = true; else sprite.Velocity = new Vector2(sprite.Velocity.X, 0); } else { float intersectionDepth = RectangleExtensions.GetHorizontalIntersectionDepth(sprite.Bounds, tmp); sprite.Position += new Vector2(intersectionDepth, 0); sprite.Velocity = new Vector2(0, sprite.Velocity.Y); } break; } } } else continue; } } } if(!verticalMovement) WorldCollision(sprite, true); } private bool PixelbasedCollision(Rectangle rect1, Color[] data1, Rectangle rect2, Color[] data2) { int top = Math.Max(rect1.Top, rect2.Top); int bottom = Math.Min(rect1.Bottom, rect2.Bottom); int left = Math.Max(rect1.Left, rect2.Left); int right = Math.Min(rect1.Right, rect2.Right); for (int y = top; y < bottom; y++) { for (int x = left; x < right; x++) { Color color1 = data1[(x - rect1.Left) + (y - rect1.Top) * rect1.Width]; Color color2 = data2[(x - rect2.Left) + (y - rect2.Top) * rect2.Width]; if (color1.A != 0 && color2.A != 0) return true; } } return false; } private Color[] GetTileColorData(int x, int y) { Color[] tmp = new Color[TILE_SIZE * TILE_SIZE]; _tileSheet.GetData<Color>(0 * TILE_SIZE, new Rectangle(_world[x,y].Variant * TILE_SIZE, (int)(_world[x,y].Type - 1) * TILE_SIZE, TILE_SIZE, TILE_SIZE), tmp, 0, tmp.Length); return tmp; }   I've also made a small video showing the issues I am having: http://www.youtube.com/watch?v=FC8eYy1LRGQ   I hope I provided all the information necessary. I know there's a lot of code, but I was hoping someone with experience might immediately know the error just from seeing the movie :-)   Thanks for reading!
  11. Thanks a lot for all the replies   I already noticed one flaw in the way I update things. Instead of just changing a value when the grass is growing, I am actually creating a whole new instance of that specific tile. There's absolutely no reason for that, and I am pretty sure creating loads of new instances in one update cycle causes problems.   I like the idea. I wasn't actually considering updating the entire world, only within my update radius. Doing this might very well make it possible though. Thanks for the input   I think I do obsess about performance lately. I haven't had the chance to test my game any other computers than my own, and a very old laptop. The laptop can't run the game very well, I do believe that it is because of my lighting, which is rather CPU intensive. Currently the way I handle updates, is simply by iterating all the tiles within a certain distance from the player, and change the tiles accordingly. I am not happy with that approach though, since all dirt tiles within range will grow grass every time I run the update. I always wondered what the difference is between references and pointers. I never did much C++, but I did learn that pointers was the force of C++, which had be wondered what the difference between those two were. It's nice to know that they're similar at least. - Thanks for your input   After reading all these posts, I think I've decided on a queue system, as you suggested. I was thinking of keeping it all in one big queue (List) and then at certain intervals (maybe random) I update a certain amounts of tiles on the list, and remove them, if no more updates are required, or move them to the bottom of the queue.   This will also be very useful for plants, and farm objects that I am adding to the game soon. Also when winter is over, I can use this to melt the snow over time.   I really appreciate all the input I got from you guys   Thanks a lot!
  12. In the tile based game I am making I sometimes need to update several tiles at once. Since I keep my world in a 2D tile array, I can't seem to find a good way to update the specific tiles I want updated.   An example: When grass grows, I periodically need to check if it is time for it to grow. Since there are a lot of dirt tiles, there will be a lot of dirt tiles to go through. When searching for dirt tiles that needs to be updated, I search from top to bottom, until I hit a dirt tile, which needs to be updated. The part that gets taxing, is that since I don't necessarily know which tiles need updating, I have to iterate through a lot of them (Or at least all withing my Update Radius). Since the player can change the world, the tiles to be updated can change very quickly. I have considered adding the reference variables to a list, and then update the tiles on the list. But since the list can become quite long fast, I'm worried that I might be spending too many resources.   Solutions I've thought about: - The first one is more or less just brute force. Periodically I iterate through the tiles within my Update radius, and update them. I've done this  and sometimes this causes a lag for a second or so when the updates are applied- So this is not a good solution. - Every time I draw my world, I iterate through a lot of tiles (those within my Draw radius). I was thinking about simply doing the tile updates  there, since I already have an iteration going. I am pretty sure this is bad practice, and I know that Draw is potentially called fewer times than update, so I dropped the idea. - The list idea I mentioned earlier, where I add tiles that needs to be updated to a list, and iterate through that list periodically. The problems I see with this method is that I still need to figure out which tiles to put on the list, which means I need to check for that every time the world changes somewhere. Another problem I see is if the list is getting too big. I don't think memory will be a big issue, but updating potentially thousands of tiles at once, will cause huge slowdowns. A fix could be to look at the list more often, and only update small parts of it- Like a queue system.   So my question is: What would be a good way to update "random" tiles in a 2D array?   Thanks for reading
  13.   One of the bigger mistakes I did back when I started, was to have a lot of classes depend on each other. In hindsight I can see why you would avoid that. It is at times like these I tend to get discouraged, since I realize that I still have a lot to learn - I did end up making parts of my event system, but it's nothing similar to this. I did keep it fairly clean, so that it mostly handles timing and changing of some event related variables. Thank you for your detailed input, and sorry for not replying sooner ;-)
  14. Hey there- Thanks for your input - Sorry for the late reply, got struck by a flu a few days ago.- Better now though   I am already having a few classes that could be described as "god classes". he way I do things is probably not the "best" way to do it. My entire game is a "learning by doing" project. I do occasionally go back and change things, but some of my code is just too tied in that it would take tremendous amounts of time to do so- I started this project almost 11 months ago, so there's a lot of work in it already   When you start playing the game I have a gamestate enumerator that I set to "PlayField. I then have a Playfield class, (my play screen) which is loaded. It then loads the TileWorld class and a player Class. At the same time, my PlayGUI (user interface class) reacts to the gamestate and draws on top. Here I'm thinking the correct way to do things would be to have the Playfield class load the PlayGUI instead. Anyways I'm going a bit off topic.   Day/Night cycles are handled through the TileWorld class. It has a background class that handles everything on the background (cloud movement, sun/moon cycle, background objects) and it at also handles the ingame time. I can then use the timer here to determine whether it is night or day, and handle things accordingly.   The way I currently handle weather is quite simple- I have an enumerator with 3 values- Normal, Rain and Snow. When the value is changed, the UpdateWeather method in my TileWorld class (the class that handles most logic related to a game world) simply acts differently (if, else if, else). The idea was to have the EventSystem class to change it, based on the current season, and some random modifiers that the EventSystem handles.   The size of my world can easly be several million tiles (currently max world size is aprox 31.5 million tiles), so the way I handle tiles are different from what you suggest. My Tile class contains an enumerator that holds the value of the TileType, and another that holds the value of the BackgroundTileType, the orientation of the tile, and the amount of water in the tile (if any). Then I have my WorldItemClass that inherrits from the Tileclass. This is basically used for items that are made of more than one tile, and may be usable, like crafting tables, furnaces, etc. I also have a container class that inherrits from it, and a few other types. The reason I made those tiles inherrit from Tile, is that they require more data. For instance, the chest item, which is a containertype item, is required to have an inventory "inside of it"- This way, I don't need to have all the tiles to be able to have an inventory, which saves loads of memory, and hdd space when saving.   Anyways, just wanted to explain how I do things and my logic (or lack thereof) behind it.   Thanks for your input. I always look for ways to improve my code and learn new things. I really appreciate it. If anyone has some thoughts on the structure I've explained, don't hesitate to share them- Thanks
  15. I am about to start making an event system for my game. All the way through this game I've had a hard time determining how to structure things, but this event system will have a huge impact on the game, so I figured it was a good idea to get it "right" from the beginning. The event system will handle all kinds of random events in my game- In this example, let's assume it controls when the weather will change. My problem is what class get to do what. I have my TileWorld class, which currently contains the World Array (2D tile based game), it contains methods that handles mining and building (I have a static WorldBuilder class that assists here, but not relevant atm). It also has a particle engine object that handles all particle generation- which in turn is used to create the weather effects like snow and rain.  Now I also have this EventSystem class, that decides when to change the weather. The TileWorld will have an instance of the EventSystem.   My questions are:   - Should the EventSystem handle everything related to weather, or only change the weather and let the TileWorld class handle the rest? - Which of the classes should contain the variable(s) related to the weather? (For Instance the weather variable is in the TileWorld, but is changed from the EventSystem)   - If I decide to let the TileWorld hold the variables, and the EventSystem only handles the logic to change events(weather), I will have to give the EventSystem a reference to the TileWorld- I've done this quite a lot in my game, is this good practice, or should I use a different approach?   I hope I've expressed myself clearly enough- Thanks for reading :-)