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

stein102

Members
  • Content count

    230
  • Joined

  • Last visited

Community Reputation

556 Good

About stein102

  • Rank
    Member
  1. So I did what Spidi suggested and transformed the screen space to the world space and that didn't work. It turns out that the code works exactly as intended only if I don't zoom my camera. Here's the camera code. Any idea why it only works when my zoom is equal to 1? public class Camera2D { public Vector2 Position { get; set; } public float Rotation { get; set; } public float Zoom { get; set; } public Vector2 Origin { get; set; } static int TILE_HEIGHT_HALF = 64; static int TILE_WIDTH_HALF = 128; private readonly Viewport _viewport; public Camera2D(Viewport viewport) { _viewport = viewport; Rotation = 0; Zoom = 1; Origin = new Vector2(viewport.Width / 2f, viewport.Height / 2f); Position = Vector2.Zero; } public Matrix GetViewMatrix() { return Matrix.CreateTranslation(new Vector3(-Position, 0.0f)) * Matrix.CreateTranslation(new Vector3(-Origin, 0.0f)) * Matrix.CreateRotationZ(Rotation) * Matrix.CreateScale(Zoom, Zoom, 1) * Matrix.CreateTranslation(new Vector3(Origin, 0.0f)); } public Vector2 cartToIso(Vector2 cart) { Vector2 temp = new Vector2(0,0); temp.X = (cart.X - cart.Y) * TILE_WIDTH_HALF; temp.Y = (cart.X + cart.Y)*TILE_HEIGHT_HALF; return temp; } public Vector2 IsoToCart(Vector2 iso) { iso += Position; Vector2 temp = new Vector2(0, 0); temp.X = ((iso.X / TILE_WIDTH_HALF) + (iso.Y/TILE_HEIGHT_HALF))/2; temp.Y = ((iso.Y/TILE_HEIGHT_HALF) - (iso.X/TILE_WIDTH_HALF)) / 2; temp.X -= 0.5f; temp.Y += 0.5f; return temp; } }
  2.   That makes a lot of sense, I forgot to transform the mouse coordinates to the world space coordinates. I'll try this when I get home from school tomorrow and see how that works out. I'm guessing that will solve my issues. I'll post the results tomorrow.     I never really thought about that before, I'll change that too and keep that in mind.     Sorry about that, the chunk I posted is just inside my main update method and gets called every game loop, not every time the mouse button is pressed. My mistake.
  3. It's called whenever the left mouse button is pressed.   After testing it again it seems like the movement direction is the last direction the mouse moved and not towards the mouse.
  4. I'm trying to have my player follow the mouse when the mouse button is held down but I'm having some trouble figuring it out. The motion is seemingly random. if(Mouse.GetState().LeftButton == ButtonState.Pressed) { int speed = 5; Vector2 mouse = new Vector2(Mouse.GetState().X, Mouse.GetState().Y); Vector2 direction = mouse - player.GetPosition(); direction.Normalize(); player.SetPosition(Vector2.Add(player.GetPosition(),(direction*speed))); } Any ideas?
  5. I've been avoiding a* since I'm not really sure how to implement it. I planning on generating the road first and then the landscape around it, does it really matter what order I do this in?   I like the idea of using waypoints, I may attempt something like that. I was looking in to midpoint displacement algorithms which would make the road look more natural, the issue is that it still takes the shortest path.
  6. The final goal is to create a road system similar to the one in Diablo2. A random enterance and exit are plotted on the map, then a winding path connects the two nodes. I have implemented a system that selects two random places on the edge of a map, then connects them. My issue is that the path is rather boring. Are there any good ways to improve the path my road takes? This is what I currently use to create the path: private List<Vector2> generatePath(Vector2 p1, Vector2 p2) { List<Vector2> nodes = new List<Vector2>(); nodes.Add(p1); while (!p1.Equals(p2)) { float xDiff = p2.X - p1.X; float yDiff = p2.Y - p1.Y; double atan = Math.Atan2(yDiff, xDiff); double quadrant = Math.Round(4 * atan / (2 * Math.PI) + 4) % 4; if (quadrant == 0) p1.X++; if (quadrant == 1) p1.Y++; if (quadrant == 2) p1.X--; if (quadrant == 3) p1.Y--; nodes.Add(p1); } nodes.Add(p2); return nodes; }
  7. I'm getting an error in my game where my foreground is not rendering on top of my background. My idea is that maybe I messed up my layer sorting method. Does anything look wrong with this? public static ArrayList<MapLayer> sortLayers(ArrayList<MapLayer> layers){ ArrayList<MapLayer> sortedLayers; sortedLayers = layers; int n = sortedLayers.size(); MapLayer temp = null; for(int i = 0; i < n; i++){ for(int j = 1; j < (n-1); j++){ if(sortedLayers.get(j-1).getDepth() > sortedLayers.get(j).getDepth()){ temp = sortedLayers.get(j-1); sortedLayers.set(j-1,sortedLayers.get(j)); sortedLayers.set(j,temp); } } } }
  8. I've been working on a isometric tilemap engine. Everything has been working fine up until recently when I tried implementing a moving camera. The tile picking has been off if the camera is moved. I've tried offsetting by the camera's displacement and it's still not giving the desired results. If I only move the camera along the x-axis, the tile picking works as intended, if any y-axis movement is involved, it doesn't behave correctly. I'm not sure what's going on here. Any help would be appreciated.   This method is called when a place on the game world is clicked. There is no correction for the camera in this method at the moment, I took it out due to it not working correctly. It's simply the base method that worked before the moving camera was implemented. The first two lines of code give me the camera's displacement along a given axis. cam.viewportWidth/2 is the default camera x coordinate. This is also applied to the Y-Axis.   If you need any more information, let me know and I can supply it. public void getTileAt(OrthographicCamera cam, Vector2 mouse){ camOffsetX = cam.viewportWidth/2-cam.position.x; camOffsetY = -(cam.viewportHeight/2-cam.position.y); System.out.println(camOffsetX + ":" + camOffsetY); mouse.x -= X_OFFSET; mouse.y = Math.abs(mouse.y - Gdx.graphics.getHeight()); Vector2 mp = isoToCart(mouse); Vector2 coords = new Vector2((float)Math.floor(mp.x), (float)Math.floor(mp.y)); try{ Tile t = new Tile("cube","redcube.png"); layers.get(0).setTileAt(t, (int)coords.x, (int)coords.y); System.out.println(coords); }catch(ArrayIndexOutOfBoundsException e){ System.out.println("Coords out of bounds"); } }
  9. When an event fires, you could place it in a queue and during the game loop, iterate through it and handle them accordingly.
  10.   AX and AY are the just properties for aX and aY, they basically act as getters and setters for the variables. aX and aY are being set in the main game loop where it just takes the direction of the thumbstick and adds to the variable depending on how much it's pressed.   1. I agree with you, I'll change that after I get it working correctly. This is just a prototype I was throwing together because I've never worked in monogame or C# before(I come from a Java and LibGDX background) 2. That was originally what I had done, but I changed it to what I have now because I was getting some stuttering when the block was on the ground. It would accelerate too quickly into the ground and a collision would occur to move the object back above the ground.  3. That makes a lot of sense, I'll give that one a shot.       Oh okay, I see what you mean. That had never occurred to me, I'll try implementing changing the velocity directly as opposed to the acceleration.   I'll look into adding an animation for the play and see what happens. I've never done anything like that with monogame so that means there's some more reading to be done :)   Thanks for all the advice!
  11. Okay, I got a video up. Here's the link. The video is a bit long but it gets the point across.   It's kind of hard to tell from just the video but the change in direction seems to have a pretty large delay.
  12.   I found that in a thread a while ago(I don't remember where exactly) where it was suggested to check which collision axis was shallower to determine which collision has happened first. I have changed that already but I did so before seeing your post.   What I've done is get two time variables that are basically float timeY = intersection.Height/velocityY and the same for X. This has been a lot more accurate.   My problem I'm having now is that the movement feels VERY unnatural. But I suppose that is just a matter of tweaking values, right? I was also considering changing all my movement related variables from ints to floats to get slightly more smooth movements. Would this help?
  13. I'm not at my PC at the moment but all the code for jumping does is increase the y velocity by a set amount. I can post a video of the behavior in the morning since I'm a little unsure how to explain it
  14. I'm working on getting a platformer prototype up and running in C# using monogame. The movement and collision "work" but are very awkward. For example, if you stand on the edge of a platform and jump straight up, you fall right through the platform. I'll post my code and hopefully someone sees something that doesn't look right. If any additional information is needed I can add more. public Player(GraphicsDevice device) { x = 100; y = 100; width = 32; height = 64; maxVX = 10; gravity = -2; grounded = false; Rect = new Rectangle(x, y, width, height); WhiteRectangle = new Texture2D(device, 1, 1); WhiteRectangle.SetData(new[] { Color.White }); } public void Update() { rect = new Rectangle(x, y, width, height); if (!grounded || standingOn==null) { aY = gravity; }else { aY = 0; } VY += AY; VX += AX; if (aX > 10) aX = 10; if (aX < -10) aX = -10; if (vX > maxVX) vX = maxVX; if (vX < -maxVX) vX = -maxVX; System.Console.WriteLine(vX +":" + aX); lastX = x; lastY = y; x += VX; y -= VY; } public void CollisionCheck(List<Platform> collideables) { foreach(var p in collideables) { if (rect.Intersects(p.Rect)) { Rectangle intersection = Rectangle.Intersect(rect, p.Rect); if(intersection.Height < intersection.Width) { if (y < p.Y) { standingOn = p; grounded = true; y = p.Y - height; vY = 0; aY = 0; }else { y = p.Y + p.Height + 1; vY = 0; } }else { if(x < p.X) { x = p.X - width - 1; }else { x = p.X + p.Width + 1; } } vX = 0; aX = 0; } } //Check if player falls off platform if (standingOn != null) { if(x+width < standingOn.X || x > standingOn.X +standingOn.Width) { grounded = false; standingOn = null; } } } public void ApplyFriction() { aX = 0; if (vX > 0) aX -= 2; if (vX < 0) aX += 2; } EDIT: Almost forgot to include the code that changes the acceleration player.AX += (int)(pad.ThumbSticks.Left.X * 10) / 5;
  15. So I recently started playing around with C# and Monogame. The question I have is pretty simple, would it be worth it to work on releasing a game for the xbox360 live arcade? Worth while as in, would there be a large enough demographic that still plays indie games on live arcade to release a game to that as opposed to another platform?   Thanks, Stein102