• Content count

  • Joined

  • Last visited

Community Reputation

1361 Excellent

About stitchs_login

  • Rank

Personal Information

  • Interests
  1. 2D Making 2D simple games (Zelda for example)

    A good place to start for tutorials would be Youtube. One such tutorial I am currently working from uses Java, the instructors pace is moderate, so really gives you a chance to keep up to speed with bite-sized tutorial. The requirement is that you have *some* basic Java knowledge. I won't go too much into Java, as it is heavily documented and summarised around the web, and in places on this website. I'll just say that Java is a very high-level language that takes away the headache of memory management, which a language like C++ imposes (though it is easier now with things like smart-pointers). It also compiles once and is usable on any platform: Linux, Windows etc. Tutorials here: Another option specifically tailored to beginner games programming is Unity, though I've not had any experience with it. Good luck! Stitchs.
  2. 2D Camera Jitters

    Hi @GoliathForge, The tick() method in Camera is a hangover that I'm removing in this phase. When you say that I should refactor some naming, do you mean that having the parameter names the same as the instance-level members could be confusing? Or am I missing some consistency in the naming pattern? As for Creature::move() package dev.mygame.entities.creatures; import dev.mygame.entities.Entity; import dev.mygame.Handler; public abstract class Creature extends Entity { public static final int DEFAULT_HEALTH = 10; public static final float DEFAULT_SPEED = 1.0f; public static final int DEFAULT_WIDTH = 64; public static final int DEFAULT_HEIGHT = 64; protected int health; protected float speed; protected float xMove; protected float yMove; public Creature(Handler handler, float x, float y, int width, int height) { super(handler, x, y, width, height); health = DEFAULT_HEALTH; speed = DEFAULT_SPEED; xMove = 0f; yMove = 0f; } public void move() { x += xMove; y += yMove; } .... } I admit, I haven't yet printed the values to the setFocus method, so I will do that in my next round of implementation. Thinking about my original wording, if anything, it's not camera jitter I'm experiencing. It's more akin to a tear in some graphic rendering between tiles when I move my player vertically. @the incredible smoker Could you elaborate in relation to the screen-tearing that I'm experiencing? Right now, I don't *need* the precision provided by doubles. It would be something I'd consider in the future when I begin to implement physics calculations that may require it. Currently, I'm following a tutorial series that doesn't suggest using them. If this is a possible solution to my issues, I would love to hear some more context to your answer. Thanks, Stitchs.
  3. 2D Camera Jitters

    Hey, I'm running through some game tutorials and have just implemented my camera. It scrolls, following the player sprite, and culls tiles from the map outside of bounds. One thing I'm noticing is some minor artifact tearing between some of the tiles that make up the on-screen map. Originally, I assumed it was because I coded my camera X and Y as Integers, and my player coordinates as floats, so there was some classic data loss from downcasting float -> int. I modified that, and removed integer casts that related to passing player coordinates to the camera. This has reduced the tearing, but everything still jitters a small amount. The player only moves at a speed of 1.0f. If I run it at 3.0f, it is more noticable. Where could I be going wrong? Thanks, Stitchs (code below). package dev.mygame.display; public class Camera { private float x; private float y; private int w; private int h; private int focusX; private int focusY; public Camera(float x, float y, int w, int h) { this.x = x; this.y = y; this.w = w; this.h = h; } public float getX() { return x; } public void setX(float x) { this.x = x; } public float getY() { return y; } public void setY(float y) { this.y = y; } public int getFocusX() { return focusX; } public void setFocus(float focusX, float focusY) { float lerp = 1.0f; x += lerp * (focusX - w/2 - x); y += lerp * (focusY - h/2 - y); } public int getFocusY() { return focusY; } public int getWidth() { return w; } public int getHeight() { return h; } public void tick() { // centre the camera on the focus point //focusX -= w/2; //focusY -= h/2; // set the origin so we can offset everything else x = focusX; y = focusY; } } package dev.mygame.entities.creatures; import java.awt.Graphics; import dev.mygame.gfx.Assets; import dev.mygame.Game; public class Player extends Creature { private Game game; public Player(Game game, float x, float y) { super(game, x, y, Creature.DEFAULT_WIDTH, Creature.DEFAULT_HEIGHT); = game; } @Override public void tick() { getInput(); move(); } private void getInput() { xMove = 0; yMove = 0; if(game.getKeyManager().up) { yMove = -speed; } if(game.getKeyManager().down) { yMove = +speed; } if(game.getKeyManager().left) { xMove = -speed; } if(game.getKeyManager().right) { xMove = +speed; } } @Override public void render(Graphics g) { g.drawImage(Assets.playerOne, (int)(x - game.getCamera().getX()), (int)(y - game.getCamera().getY()), width, height, null); } } package dev.mygame.states; import java.awt.Graphics; import dev.mygame.entities.creatures.Player; import dev.mygame.gfx.Assets; import dev.mygame.Game; import dev.mygame.worlds.World; import dev.mygame.display.Camera; public class GameState extends State { private Player player; private World world; public GameState(Game game) { super(game); world = new World(game, "/maps/World1.json"); player = new Player(game, world.getSpawnX(), world.getSpawnY()); } @Override public void tick() { player.tick(); game.getCamera().setFocus(player.getX() + player.getWidth()/2, player.getY() + player.getHeight()/2); } @Override public void render(Graphics g) { world.render(g); player.render(g); } }
  4. Metroid-vania style level design

    I watched a few minutes of your video, some pretty slick looking stuff there! Far beyond what I was even imagining my room/grid layout would look like! So what you're saying is, you have your tmx files, and the generation process looks through these and outputs JSON, which is read later to layout the connection of the rooms? And I assume the tmx extension is from the Tiled map program you use? Stitchs.
  5. Metroid-vania style level design

    This is my train of thought initially. But more in terms of, which doors link to which doors, and N doors might be stored in an array in the Room class.
  6. Metroid-vania style level design

    Thanks for the responses. Alot more to think about that I first anticipated. With this approach, couldn't it become inefficient to have to search the possible rooms each time, if the map is huge? What I'm saying is, that you could do an initial cull on rooms that are past the door (say, the door is facing left, and if the right half of the grid, then we ignore all rooms behind it), but you would still have to search every rooms grid coordinates and compare 2 values. Whereas with an ID to ID mapping, you either compare one value, or create some Door class, which stores the ID of the door it joins to (similar to how a linked list stores a reference/pointer (language dependent =D) to the next element in a list. This does sound pretty interesting, and I do a lot with JSON at work, so it wouldn't be unfamiliar ground for me. Could you provide snippets of what info these files contain. When you say "generate", do you have a randomly generated labyrinth every time a brand new game a started? Thanks again. Really useful stuff! Liyaan.
  7. Metroid-vania style level design

    Thanks for the reply. I did wonder if what I had would be expandable for more complex features and interactions. So when you say that the world is laid out on a grid, does this mean that all the rooms are loaded into memory from the very start of the game, with resources such as sprites and graphics being loaded on "is in room" basis? Does the concept of rooms even exist? Or is everything traversable as if the entire map is a single room/level? Stitchs.
  8. Metroid-vania style level design

    Hi all, I'm currently designing a map of rooms for a Metroid-style game (really inspired by the AM2R remake) and wanted to run my design by you for some feedback. My thinking is you have a Room class, said class being able to load a text file which is made up of a map of ID's. These ID's would be mapped to different block types which have varying properties (wall/floor/lava blocks as an example). Each room would contain one+ door objects. These doors would have ID's allowing you to link rooms based on the connecting ID's. This would also be information found in each rooms textfile config. Every room would contain an inventory of objects like enemies, items, power-ups, that the player can interact with in some way. There will be no random generation (yet, limited experience) and each room will be 'crafted' in a text file. The locations for these item would also be laid out in the text file that is loaded. Once loaded, their individual behaviours would be (like enemies patrol etc.). My thinking is also to load rooms on a basis relative to the current room the player is in. The rooms connecting to the current room are loaded into memory and once a new room is entered, rooms outside of the depth n-1 or n+1 will be unloaded. Thanks for your time guys! Stitchs.
  9. Magic Item Tech, testing - part 1.

    Great read! I've been having to do a lot of JUnit testing at my new job and this is completely fascinating/a way that I want to work in the future.
  10. I completely agree Nypyren. This is a self-imposed limitation that I am doing to test with that particular set of Unicode characters. I wanted to refine the method first, and then expand it to include a bigger character set.   Stitchs.
  11. Hi all,   I've been presented with a small challenge:   1) Make a function that counts the number of each individual character in a string. Report back to the user in the form <character, number of occurrences> the character that appears the most.   So the function would take a string input; i.e. "rabbit" and output the character that occurs the most in said string; i.e. <'b', 2>.   I have coded up a function (to my understanding of Big O notation is that it is Linear O(N)). public static string GetMostFrequentCharacter(string input) { string result = "The String is empty."; if (IsStringValid(input)) { int INDEX_CONVERTER = 32; int[] characterCounts = new int[127 - INDEX_CONVERTER]; char characterToConvert; // first loop counts the occurrence of each character in the string for (int i = 0; i < input.Length; i++) { characterToConvert = input[i]; characterCounts[(int)characterToConvert - INDEX_CONVERTER]++; } int highestCount = 0, arrayPosition = -1; // second loop finds which character appeared the most, only the last // highest count to appear in the list will count. for (int i = 0; i < characterCounts.Length; i++) { // check to see if the current index value is higher // than the previous higher count if (characterCounts[i] >= highestCount) { // get the value at the current index highestCount = characterCounts[i]; arrayPosition = i; } } if (arrayPosition < 0) { result = "There was an error in processing the string."; } else { // finally, convert the arrayPosition into a suitable char representation char characterToOutput = (char)(arrayPosition + INDEX_CONVERTER); // format the output string result = string.Format("<'{0}', {1}>", characterToOutput, highestCount); } } return result; } I'm happy with the way most of it works. My only problem is that, say I have 2 characters that appear an equal number of times. My current method only takes the last highest value, in order of UNICODE value. Say we have the string "foof". The output for said function would be <'o', 2>, it does not present the last letter to appear, only the last in order of UNICODE.   I don't want to create another storage for characters that appear equal number of times (I already have 2 arrays). I have looked on the internet, but the only responses I am finding is if someone knows the character they are looking for, before they use the function; they ask "How many times does 'a' appear?"   Any help or feedback would be greatly appreciated.   Stitchs.
  12. C# Linked List implementation review

    @ChaosEngine: I was going to implement it as a Generic Type, but I'm never going to use it for my projects and wanted something that I could get information from quickly, for testing, which is why I pre-made it using the String class.   @Pink Horror: I' guessing that if I wanted to look at/use every item I would (internal code): for(int i = 0; i < list.Length; i++) { DoSomething(currentNode); currentNode =; } User code: DoSomethingWithAllListItems(int pLength); This would be O(N) Linear as it will take an amount of time and resources proportional, to the size of the list (which if it gets very big, will cost a lot). If I want constant time, such as the change I have made to my AddNode() method, I would need to be able to access a node directly, knowing it's location beforehand.   I hope I have understood what you are trying to say, but what would be a constant alternative to looping the list. Would I have to order it first?   Stitchs.
  13. C# Linked List implementation review

    As an update: I went back to my AddNode method. If I use a reference (let's call it tail) which stores the final node in the list so that new nodes can be added without traversing the list. public void AddNode(string stringIn) { StringNode newNode = new StringNode(stringIn); if (IsEmpty()) { list = newNode; tail = list; } else { = newNode; tail =; } } What I'm struggling to understand is how my else statement works. It works, as in it adds nodes successfully. Can anyone clarify that my thought process as to what I'm doing is correct?   If the list is empty, I add the new node as the head and make the tail equal to the head (the head is both the first and last node).   If there is a node (say we are at the point that we haven't added anymore than one), then we make the (aka equal to our new node. Then we make tail equal this last node.   What I'm struggling to understand; once we exit the AddNode function, and the temp variable newNode is no longer in memory, what is preserving the references to these different nodes in memory? Only list and tail exist, I'm changing what tail points to every time I add a node to a non-empty list, how are any nodes in-between able to be referenced/not being flagged for garbage collection?   Please ask if you need anymore clarification.   Stitchs.
  14. C# Linked List implementation review

    Hi all,   Thanks for the feedback so far. I am implementing it to further my understanding of how they work. My intent would be to use the .NET implementation.   I did think as I was implementing the loops with indexes that what happens if the list gets too big? I know that each node is stored, non-sequentially, in memory which makes it longer to iterate over.   I have thought about adding a reference for the tail; making it the result of AddNode().   What I'm stuck on is the idea of holding a place in the list. Isn't this just as slow as starting from the beginning? If you start at the beginning then you don't have to worry about going backwards. Otherwise I need to create a doubly Linked List to be able to traverse back and forth.   I have some great feedback to work on from this.   Thanks,   Stitchs.
  15. Hi all,   I am part way through implementing my own Linked List class (only stores Strings for now) to better understand how they work. I have completed the major portions of it; Add, Delete, Insert etc. and was just wondering if I could get some feedback on the code thus far. private StringNode list; public MyStringList() { list = null; // empty by default; } public void InsertNode(string stringIn, uint index) { // Check that user is not trying to insert outside the valid // range of nodes. if (IndexOutOfUpperBounds(index)) { return; } // create a string node to insert into the list StringNode newNode = new StringNode(stringIn); StringNode current; StringNode temp; if (index == 0) { // store the list head. temp = list; // set the new node as the new list head list = newNode; // reconnect the old list head to the new list head. = temp; return; } // temp node that is a reference to the beginning node current = list; // loop to the position of the node at index // because of the way that current is initialized, we can // skip index zero. for (int i = 1; i < index; i++) { // check that there is another node to process. if ( != null) { current =; } } // store a reference to the next node (the one at the index we desire) so as to preserve it temp =; // set the to point to the location of the new node // and set the new nodes next to point to that of the old = newNode; = temp; } public bool DeleteNode(uint index) { if (IndexOutOfUpperBounds(index)) { return false; } // temp node representing the current node in the list. StringNode current = list; // temp node representing the previous node in the list. StringNode previous = null; // if the user has searched for a node that is not the first in the list if (index > 0) { // loop from 0 to the index position. for (int i = 0; i < index; i++) { if (current != null) { previous = current; current =; } } } // need conditions to assure that the predecessor of a node, // removed from the end will point to null // a check to see if we are at the end of the list. if (( == null) && (current != list)) { // make the very last node null, so it will be removed by // garbage collection = null; current = null; } // condition that a node removed from the middle will link the two // nodes that surround it, properly else if (( != null) && (current != list)) { // change the previous node to link to the node up ahead. =; current = null; } // condition that the successor of a node removed from the front // will properly set the new list head. else { // check that the list head is not the only node if ( != null) { list =; } else { list = null; } } // reduce number of nodes by 1, if we have got to this point, // there is no need to check if we are allowed to decrement. this.Count--; return true; } I have not included the entire implementation, for simplicity's sake. I would like to draw your attention to the Insert and Delete methods. They work in all the tests I have performed. I feel like they could be streamlined more. If you need anymore information, feel free to ask and I shall do my best to explain.   Many thanks,   Stitchs.