Bradley Benton

Members
  • Content count

    3
  • Joined

  • Last visited

Community Reputation

112 Neutral

About Bradley Benton

  • Rank
    Newbie
  1. Thanks to both of your answers, I will have a look into spatial partitioning tomorrow when I am more awake. This is a game that I'm basically learning java through trial and error with. It's not so much that I am looking for the 'best' ways, I just want to know if my 'ways' are acceptable. I believe the checking zombies to survivors and vice versa will become a problem in the future, which is why I'll look into the partitioning. I believe a grid will solve the picking items up and I'll try to get a grid in the game. [quote name='jbadams' timestamp='1342078567' post='4958287'] This should work just fine for a small number of actors (survivors and zombies), but will not scale well; as you add more actors the number of checks you have to do increases drastically, and obviously this will start to have an impact on performance at some point. [/quote] I guess the number of entities would be relatively small. I would say no more than... 150 entities would be on the map at the same time? Kinda hard to say until I get further along with it. And performing less detailed simulations might work, but the map we're using now is 5k x 5k pixels, so it's not that large of an area. [quote name='Bacterius' timestamp='1342078571' post='4958288'] Firstly, don't set hard pixel values like a 50px range - you want your game to be able to be played on any resolution whatsoever, and for this to happen you need the game logic to be r esolution-independent. [/quote] I understand that scaling is an issue but for my first attempt at a small game, it will be forced to 800X600 resolution. I will take your advice in the future though, good idea! [quote name='Bacterius' timestamp='1342078571' post='4958288'] You should probably check if there is a click before doing any position analysis, since nothing will happen anyway if the mouse isn't clicked (more efficient). This can't really be answered because it's unclear how you manage your survivor entities, but you could just make it that if no survivor is near the mouse when it is clicked (= open space), then you loop over all survivors and "unselect" them. But it depends on how "selection" is defined inside your game, it could be a flag in each survivor entity or it could be a "selection list" attached to the player (if that makes sense). [/quote] Yea the selection is a boolean in the survivor class. I've tried doing a "If there is a click, check the mouse X and Y and see if a survivor is near" method but it absolutely would not work. I'll have to try and fiddle with this again. As for the animations, good advice on that. So I'd need spritesheets with however many frames I'd need. So for a pistol it's a flash+recoil, really simple, probably only needs two frames. As for a shotgun,shoot+recoil, brief pause, pump out, pause , pump in. So maybe (counting frames per action) 2 + 1 + 1 + 1 + 1 at a slower rate. Makes sense. I've heard plenty of[b] "[/b]Premature optimization is the root of all evil" quotes. I'm not necessarily optimizing yet, just trying to avoid what I know will become an issue. Thanks a ton for the advice so far!
  2. Hey all, I'm new to the forums. Posted this over at stack overflow but I'm not really sure if the people there will have the information for this. So I'm making a 2d Java game with the slick2d and MarteEngine libraries. This is the biggest project since I made checkers for my Java class. I am still pretty new to programming concepts and using optimal ways to get stuff done. The basic structure of my game is you are a player/hero in a zombie apocalypse and you can gather survivors to help you. There are a many areas that I'm concerned about in my programming. I'm not sure if my methods are a good choice for what I want. This game also does not currently have a grid/tile system. I've looked at some open source java games and they don't really answer my questions to my methods. So I'm going to make a list here of what I'm uncertain about and I hope you guys can confirm/deny if my methods are appropriate. Sorry if this list gets too long, I'm thinking of the questions as I type. [list=1] [*][b]Targeting/Attacking[/b] - Survivors will automatically attack zombies once they get within the gun's target range. To do this, I have every survivor get the distance (using distance formula) to every zombie and find the closest one to attack. I check for this constantly so if a faster zombie gets closer, the survivor will change targets. For zombies, they acquire a target and stick to it (for now). The zombies constantly check if they are within the attack range (around 50 pixels) using the distance formula. If they are within range, stop and attack, otherwise, move towards the target. [*][b]2D Camera[/b] - So a camera in a 2D environment moves the world around instead of you. My current method is have my zombies/survivors/any entities on the map stored in array lists. First the background is adjusted, then all the lists are cycled through and every entity's x and y values are modified. This seems to work alright but some stuff you can really notice sliding around on the background. Not really sure how to avoid this. [*][b]User Interface[/b] - I really have no clue how to work with UI. What I've been doing so far is simply using a background and then generating button objects and manually lining them up. Then, I check if the mouse is over any of the button's areas and if there is a click while moused over the button. I have three different backgrounds and buttons that I switch out with booleans. I'm going to recode that area though, using objects with the background and buttons. Is this the correct way to do UI? [*][b]Path Finding[/b] - I have no path finding system yet. Do I have to stick to a grid system? I really rather my entities move freely along the terrain and not in a weird square to square motion. [*][b]Selecting[/b] - I have it so you can select survivors, upgrade them, and other random stuff. My current method for selecting is constantly check where the mouse X and Y is. I get the distance from the mouse to every survivor and check if it is within 30 pixels. Then, I check if there is a click, if so, select the survivor and unselect all others. I'm still trying to figure out how to unselect all survivors if I click on open space. Is there a better way to go about doing this? [*][b]Picking stuff up[/b] - Same way as said before. I check the distance from the player to every item that can be picked up. If the item is within 30 pixels of the player, it picks it up. It seems to work fine for the moment I suppose. Maybe there really is no other way to do this. [*][b]Animations[/b] - I understand the how to animate with sprites, but I just want to make sure. So if I have 7 different guns to be shot, do I need to manually make functions that have precise timing on each sprite. Say if I have a shotgun, it needs a recoil, pump forward, brief pause, pump back, and ready again. For a pistol I need just the recoil really. So I'd have to make unique functions for each of these animations? [/list] Sorry to type this long list of questions. I try to gather information on this stuff as much as possible and I haven't been able to find many examples on this stuff. I greatly appreciated any answers, even just a yes or no answer. Thanks in advance!