Froyo

Members
  • Content count

    9
  • Joined

  • Last visited

Community Reputation

201 Neutral

About Froyo

  • Rank
    Newbie
  1. Thanks, I know A LOT of games use ini, but honestly have never edited one, what are the advantages? surley if it is simply writing values to the file, i will come across the same uglyness of writing to a txt file and again can easily get a little sloppy.   Are there any good web-tutorials on ini? quick google, didnt really show any promises :/   Thanks though You shouldn't need a tutorial to make INI files, they're pretty simple and informal. They're just plain text files with name-value pairs.   http://en.wikipedia.org/wiki/INI_file   As far as integrating it with C++, just stream to write/read file from the file.
  2. Literally every question you posted can be found on these forums. I don't mean to be rude, but use the search feature so somebody else doesn't have to for you. These threads come about very often and have been answered countless times before.
  3. I really need to find a good tutorial like this for Java. The ones I've looked at haven't been much help.. maybe it's just me though.
  4. Good tutorials for learning Java?

    Java for Dummies helped me learn pretty quickly, but I also had a pretty deep knowledge in other programming languages. As far as gaming is concerned, you should try reading "Killer Game Programming". It's pretty old but it is still very helpful. http://fivedots.coe.psu.ac.th/~ad/jg/
  5. Timer vs. thread.sleep();

    I've had pretty good results with Thread.sleep() but I haven't tried using a timer so I can't speak about that. I had a 2D game with a top-down view (like Zelda LttP or Pokemon) and I've ran it for 45 minutes to an hour with 0 frames lost at 30 frames (and game.updates()) per second. Haven't tried it any higher but that's only because I don't have a reason to.
  6. Handling many objects

    After some research I found that HashTable is included in a Java package "Java.util.Dictionary", but it is legacy now. Using a HashMap seems to be the way to go, so I'll try that for now. I looked into some spacial data structures and I think I'd like to avoid them for now if possible. R-Trees and Quadtrees are the two I looked at and to be honest they seem pretty daunting to me at a glance. I think I'd be better off using conditionals to check the coordinates of an object on the game map.
  7. Handling many objects

    [quote name='marc40000' timestamp='1346604037' post='4975765'] I think you need something like this. While an array might not be the best choice, you need a place where all you game objects are put in so you can do things with all of them like your move() or a general gamelogicupdate() or a render() etc. I prefer to have a hashtable to store my game objects in. This comes with some handy features: - you can still iterate over all your objects - every object you create can get a unique id and you can store it in the hastable by that unique id. With an array you could use the index for that, but as the game continues, you get higher and higher ids while old objects get removed and you get holes in your array. OR you could put new objects at the places of removed objects, but then, your index-ids aren't unique anymore. - each object having a unique id allows objects to reference each other without tricky sideeffects. For eaxmple imagine a unit A chase another unit B. You could add a reference of B in A and that way A can check B's location in the gamelogicupdate() and knows where to move. However, what if B gets destroyed? It get removed from the scene, but it keeps existing because A has a reference to it. If A only knew B's id, it can do the same as above by checking the hashtable of B and get B's position. When B gets destroyed, A will notice because the hashtable lookup will fail. Also note that references/pointers are only valid locally. When you add network play, you absolutely need some kind of unique ids. Instead of a hashtable one could use a map. Besides that, you probably want a spatial datastructure as well to put your game objects in so you can do queries like "give me alle objects within a radius of 5m of point p.". One might be able to combine these datastructures somehow, I don't know thought. I always used those two next to each other. [/quote] This is what I was looking for. I've never dealt with hashtables or maps in Java so I'm gonna go ahead and look at some references on those now. I appreciate the help! Edit: At a glance, I notice that hashtables are similar to associative arrays in other languages. I take it that I'd still have to iterate through the hashtable and call [i]GameObject.Update()[/i] on each iteration. Do you think this is better than an object recursively controlling itself? I'm trying to choose the best method to handle objects before I expand and cause a jumbled mess for myself.
  8. Handling many objects

    [quote name='Uzumakis' timestamp='1346593939' post='4975725'] Acc to the current situation that goes without any doubt that you code will get more and more complex with the increase in the number of the units there will be more loops more array and so on insted of using loops for ur job why dont u give a try to a time class makin and independet method for each class or making a sinlge one and adjusting all the elements acc to that single timer results way easier then that for loops [/quote] Are you saying I should make each object update on its own (either by making it runnable or using a while loop)? I guess I'm not understanding how this would work where the object would still be able to interact with everything else that is updating on a different cycle.
  9. Handling many objects

    I'm currently making a 2d RPG in Java and its engine is coming along quite nicely.. however I am a bit confused on how I should handle a certain situation. I have a class [i]Unit[/i] which is any game character (subclasses for NPCs, Player, etc). The problem is there are always going to be several instances of this class and each one will need to update independently each time the canvas is rendered. What's the best way to manage this? Currently each time gameUpdate() runs (optimally 60 times per second), it loops through an ArrayList that contains each [i]Unit[/i]. Is there any way to forego using an array to handle each object? It seems like using an array like this will come back to haunt me when the game is more complex. This is what I have now and I'd like to improve it or scrap it altogether. [source lang="java"]package engine; import java.util.*; public class ObjectHandler extends ArrayList<GameObject> { private static final long serialVersionUID = -8598610051757901108L; public ObjectHandler() { System.out.println("ObjectHandler loaded."); } public static ObjectHandler getObjectHandler() { if (ref == null) ref = new ObjectHandler(); return ref; } // This method is ran every time // the game is updated. gameUpdate() public void update() { for (int i = 0; i < size(); i++) { get(i).move(); } } // This method is ran every time // the game is updated. gameRender() public void drawList() { String name; for (int i = 0; i < size(); i++) { name = null; name = get(i).name; } } /* OBJECTS ADD THEMSELVES IN THEIR CONSTRUCTOR * public void add(String unitName) { Unit unit = new Unit(unitName); //System.out.println(unit.name); add(unit); }*/ private static ObjectHandler ref; } [/source]