Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

126 Neutral

About cooljava50544

  • Rank
  1. cooljava50544

    Making 2D Images

    That is great advice, and I appreciate it. I plan to look in to those soft wares 
  2. cooljava50544

    Making 2D Images

    I switched from 3D game development to 2D, and I want to make 2D images for my games. I'm aiming to be a "lone wolf" meaning I make my games by myself, and I have all the skills to do so. Even though I am not artistic by heart, I'd like to learn.   That leads me to two questions: 1. What software should I use? 2. Where should I learn how to use that software effectively?
  3.   Yes, that is important too.   Speaking from my own expierience, I did an apprenticeship as Programmer before going to study CS. My last year of apprenticeship I spent in a Programming Team, we learned Java in School for a year during the apprenticeship.   I literally had no idea about this weird OO thing and Java, until the Boss of the team I did the last year of my apprenticeship in decided to pick a java project for the practical part of my final exams. I had to understand Java in a week to get a good grade and not fail the exams. Still, the year before I literally sat about 4 hours per week trying to learn Java and couldn't even grasp the concepts of OO     So don't underestimate Java. Even though people say its easier than other programming languages... if its your first language (or first OO language), it will take you some time to understand it.   I feel lucky now lol
  4. cooljava50544

    What game engine best fits my description?

    3D is my main goal for now, and I guess I'll stick with JME3 for the time being.
  5. cooljava50544

    First try at Tower Defense

    I tried making this tower defense game. I've made a lot of bugs in my code, and I really need some help. I'm new, and I'm basically stuck. It's been days, in fact. Please note that I'm using JMonkeyEngine 3.0, so I hope you guys are familiar with working with this engine. Please note that this is not complete, so that's why you may see some useless variables.   Let me explain what it basically it. Everything is made out of cubes even the floor, so we have a base which is a rectangle, and cubes moving towards it. I've got that part finished, and on both sides of the path we have two rectangular towers. The user clicks on one to select them, and presses "c" to give them a charge. A charge is basically an ammo packet, and each charge has 5 bullets.   Here's the code for a charge:   package mygame; public class Charges {     private int damage = 5;     private int bullets = 5;          public int getDamage() {         return damage;     }     public int getRemainingShots() {         return bullets;     } } Here is the class with all the main methods, and I believe everything is in order in this class. I might be wrong, though.   package mygame; import com.jme3.app.SimpleApplication; import com.jme3.app.state.AppState; import com.jme3.collision.CollisionResults; import com.jme3.input.KeyInput; import com.jme3.input.MouseInput; import com.jme3.input.controls.ActionListener; import com.jme3.input.controls.KeyTrigger; import com.jme3.input.controls.MouseButtonTrigger; import com.jme3.input.controls.Trigger; import com.jme3.math.Ray; import com.jme3.math.Vector2f; import com.jme3.math.Vector3f; import com.jme3.renderer.RenderManager; import com.jme3.scene.Geometry; import com.jme3.system.AppSettings; import java.util.ArrayList; public class Main extends SimpleApplication {     private static final String MAPPING_SELECT_TOWER = "Select Tower";     private static final String MAPPING_CHARGE_TOWER = "Charge Tower";          private static final Trigger TRIGGER_LEFT_CLICK = new MouseButtonTrigger(MouseInput.BUTTON_LEFT);     private static final Trigger TRIGGER_KEY_C = new KeyTrigger(KeyInput.KEY_C);          private TowerControl selected = null;     public static void main(String[] args) {         AppSettings settings = new AppSettings(true);         settings.setSettingsDialogImage("Interface//708459-1920x1080-java1920x1200.png");         settings.setTitle("Tower Defense");                  Main app = new Main();         app.setShowSettings(false);         app.setSettings(settings);       //app.setDisplayStatView(false);       //app.setDisplayFps(false);                  app.start();     }     @Override     public void simpleInitApp() {         flyCam.setDragToRotate(true);         flyCam.setMoveSpeed(100);         inputManager.setCursorVisible(true);                  GamePlayAppState gamePlay = new GamePlayAppState();         stateManager.attach((AppState) gamePlay);                  inputManager.addMapping(MAPPING_SELECT_TOWER, TRIGGER_LEFT_CLICK);         inputManager.addMapping(MAPPING_CHARGE_TOWER, TRIGGER_KEY_C);                  ActionListener selectListener = new ActionListener() {             public void onAction(String name, boolean isPressed, float tpf) {                 if(name.equals(MAPPING_SELECT_TOWER)) {                     if(isPressed == false) {                         CollisionResults results = new CollisionResults();                         Vector2f click2d = inputManager.getCursorPosition();                         Vector3f click3d = cam.getWorldCoordinates(new Vector2f(click2d.getX(),                                                                    click2d.getY()), 0f);                         Vector3f dir = cam.getWorldCoordinates(new Vector2f(click2d.getX(),                                                                click2d.getY()), 1f).                                                                subtractLocal(click3d);                         Ray ray = new Ray(click3d, dir);                         rootNode.collideWith(ray, results);                         if(results.getClosestCollision() != null && results.getClosestCollision().getGeometry().                             getControl(TowerControl.class) != null) {                             TowerControl tower = results.getClosestCollision().getGeometry().                                 getControl(TowerControl.class);                             selected = tower;                         }                         else                             selected = null;                     }                 }             }                   };                  ActionListener chargeListener = new ActionListener() {             public void onAction(String name, boolean isPressed, float tpf) {                 if(name.equals(MAPPING_CHARGE_TOWER)) {                     if(selected != null) {                         TowerControl tower = selected;                         ArrayList<Charges> charges = tower.getCharges();                         charges.add(new Charges());                         tower.setCharges(charges);                         GamePlayAppState gamePlay = new GamePlayAppState();                         gamePlay.setBudget(gamePlay.getBudget() - 1);                         selected = null;                     }                 }             }         };         inputManager.addListener(selectListener, MAPPING_SELECT_TOWER);         inputManager.addListener(chargeListener, MAPPING_CHARGE_TOWER);     }     @Override     public void simpleUpdate(float tpf) {         //TODO: add update code     }     @Override     public void simpleRender(RenderManager rm) {         //TODO: add render code     }      } As you can see, I am selecting towers by casting a ray from the visible cursor, and not the center of the screen. Now, I believe that the tower is actually receiving charges when I press c. In fact, there is a tower far enough from the enemies(creeps) that if I select, and press c it will shoot a bullet. Another problem arises from here, but I'll get to that later.   Here's the necessary code for the Tower Control: Now, my controlUpdate method is suppose to be repeatedly checking if there is a charge and if so use up the bullets on the nearest creep. I had some trouble on how to do this, but I tried my best. Sadly, an exception is being thrown from line 40, and I've tried so many things. I just can't figure it out.   Here's the stack trace:  at java.util.ArrayList.rangeCheck(ArrayList.java:635) at java.util.ArrayList.get(ArrayList.java:411) at mygame.TowerControl.controlUpdate(TowerControl.java:40) at com.jme3.scene.control.AbstractControl.update(AbstractControl.java:112) at com.jme3.scene.Spatial.runControlUpdate(Spatial.java:570) at com.jme3.scene.Spatial.updateLogicalState(Spatial.java:688) at com.jme3.scene.Node.updateLogicalState(Node.java:152) at com.jme3.scene.Node.updateLogicalState(Node.java:152) at com.jme3.app.SimpleApplication.update(SimpleApplication.java:244) at com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop(LwjglAbstractDisplay.java:151) at com.jme3.system.lwjgl.LwjglDisplay.runLoop(LwjglDisplay.java:185) at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:228) at java.lang.Thread.run(Thread.java:744) Now when I said I could manage to get a bullet to be shot(which is a simple drawn line) it stays there, doesn't detach itself from the rootNode, and doesn't creep the creep no matter what damage, health I set.   package mygame; import com.jme3.math.Vector3f; import com.jme3.renderer.RenderManager; import com.jme3.renderer.ViewPort; import com.jme3.scene.control.AbstractControl; public class CreepControl extends AbstractControl{     private int health;     private int index;     private GamePlayAppState gamePlay;          CreepControl(GamePlayAppState gamePlay, int health, int index) {         this.gamePlay = gamePlay;         this.health = health;         this.index = index;     }          @Override     public void controlUpdate(float tpf) {         if(health > 0)             spatial.move(0, 0, -tpf);         else if(health < 0) {             gamePlay.getRootNode().detachChild(spatial);             gamePlay.setBudget(gamePlay.getBudget() + 10);         }                System.out.println(spatial.getLocalTranslation());         if(spatial.getLocalTranslation().z > 0) {             gamePlay.getRootNode().detachChild(spatial);             gamePlay.setHealth(gamePlay.getHealth() - 20);         }     }          @Override     public void controlRender(RenderManager rm, ViewPort vp) {              }     public int getHealth() {         return health;     }     public void setHealth(int health) {         this.health = health;     }     public int getIndex() {         return index;     }     public void setIndex(int index) {         this.index = index;     } } Also, I used if(spatial.getLocalTranslation < 0), so they can detach themselves from the rootNode if that condition is met, but they just keep going on infinitely.    I'll also show my appState class if that can help in any way. package mygame; import com.jme3.app.Application; import com.jme3.app.SimpleApplication; import com.jme3.app.state.AbstractAppState; import com.jme3.app.state.AppStateManager; import com.jme3.asset.AssetManager; import com.jme3.material.Material; import com.jme3.math.ColorRGBA; import com.jme3.math.Vector3f; import com.jme3.scene.Geometry; import com.jme3.scene.Node; import com.jme3.scene.Spatial; import com.jme3.scene.shape.Box; import java.util.ArrayList; public class GamePlayAppState extends AbstractAppState {     private SimpleApplication app;     private Node rootNode;     private AssetManager assetManager;        private int health;     private int level;     private int budget;     private int score;     private ArrayList<Spatial> creeps = new ArrayList<Spatial>();     private boolean lastGameWon;          @Override     public void initialize(AppStateManager stateManager, Application app) {         this.setApp((SimpleApplication) app);         this.setRootNode(this.getApp().getRootNode());         this.setAssetManager(this.getApp().getAssetManager());                  createScene(getRootNode(), getAssetManager());     }          @Override     public void update(float tpf) {              }          @Override     public void cleanup() {         getRootNode().detachAllChildren();     }          private void createScene(Node rootNode, AssetManager assetManager) {     Box bFloor = new Box(33, 1, 33);     Geometry floor = new Geometry("Box", bFloor);     floor.setLocalTranslation(0, -5, 0);     Material orange = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");     orange.setColor("Color", ColorRGBA.Orange);     floor.setMaterial(orange);     Box bBase = new Box(2.5f, 1, 1);     Geometry base = new Geometry("Box", bBase);     Material yellow = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");     yellow.setColor("Color", ColorRGBA.Yellow);     base.setMaterial(yellow);     Box bTower = new Box(.4f, 2, .4f);     Geometry tower = new Geometry("Box", bTower);     Material green = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");     green.setColor("Color", ColorRGBA.Green);     tower.setMaterial(green);     Geometry tower2 = tower.clone();          tower.setUserData("chargesNum", 10);     tower2.setUserData("chargesNum", 10);     tower.setUserData("index", 0);     tower2.setUserData("index", 1);          tower.addControl(new TowerControl(this, 100, 0));     tower2.addControl(new TowerControl(this, 100, 1));               Box bCreep = new Box(.4f, .4f, .4f);     Geometry creep = new Geometry("Box", bCreep);     Material black = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");     black.setColor("Color", ColorRGBA.Black);     creep.setMaterial(black);          Geometry creep2 = creep.clone();     Geometry creep3 = creep.clone();     Geometry creep4 = creep.clone();     Geometry creep5 = creep.clone();     Geometry creep6 = creep.clone();          creep.setUserData("health", 100);     creep2.setUserData("health", 100);     creep3.setUserData("health", 100);     creep4.setUserData("health", 100);     creep5.setUserData("health", 100);     creep6.setUserData("health", 100);     creep.setUserData("index", 0);     creep2.setUserData("index", 1);     creep3.setUserData("index", 2);     creep4.setUserData("index", 3);     creep5.setUserData("index", 4);     creep6.setUserData("index", 5);              creep.addControl(new CreepControl(this, 25, 0));     creep2.addControl(new CreepControl(this, 25, 1));     creep3.addControl(new CreepControl(this, 25, 2));     creep4.addControl(new CreepControl(this, 25, 3));     creep5.addControl(new CreepControl(this, 25, 4));     creep6.addControl(new CreepControl(this, 25, 5));                        getCreeps().add(creep);         getCreeps().add(creep2);         getCreeps().add(creep3);         getCreeps().add(creep4);         getCreeps().add(creep5);         getCreeps().add(creep6);     Node playerNode = new Node();     Node towerNode = new Node();     Node creepNode = new Node();     floor.setLocalTranslation(0, -2, 1);     base.setLocalTranslation(Vector3f.ZERO);     tower.setLocalTranslation(-2.2f, 0, 4);     tower2.setLocalTranslation(2.5f, 0, 5.5f);     creep.setLocalTranslation(0, -0.6f, 12);     creep2.setLocalTranslation(1, -0.6f, 9f);     creep3.setLocalTranslation(-1, -0.6f, 15);     creep4.setLocalTranslation(1.5f, -0.6f, 18);     creep5.setLocalTranslation(1.1f, -0.6f, 19);     creep6.setLocalTranslation(-1.15f, -0.6f, 20);     rootNode.attachChild(floor);     rootNode.attachChild(playerNode);     playerNode.attachChild(base);     rootNode.attachChild(towerNode);     towerNode.attachChild(tower);     towerNode.attachChild(tower2);     rootNode.attachChild(creepNode);     creepNode.attachChild(creep);     creepNode.attachChild(creep2);     creepNode.attachChild(creep3);     creepNode.attachChild(creep4);     creepNode.attachChild(creep5);     creepNode.attachChild(creep6);             }   I'm really begging for help on this, so please help me debug my code on step at a time.      
  6. cooljava50544

    What game engine best fits my description?

    The thing is I don't really want to spend time learning another language. I'm trying to basically be a lone wolf, meaning I want to possess all the skills for game development whether it'd be programming or creating graphics, etc. I just rather stick with Java for the time being, so I can get things done faster.   Do you think it's even worth it to switch from JME3?
  7. Hello, everybody. I've been trying to develop games for about a month, but I'm not sure if I like my engine. Maybe there's a different engine that I'd feel more comfortable with. So I'm going to give a description, and I'd like a match as close a possible from your personal experience. I'm currently using JMonkey Engine 3.0.   I can use Java to work with the engine. Has a really strong and active community. Has plenty of tutorials whether it'd be video or typed Has great documentation Easy for newer developers   Now I doubt that there is a game engine with such specific and great needs, but it'd be nice to get close.   Thanks 
  8. First of all, no you do not lack the required intelligence, 8 months is no time at all when it comes to programming and there really is no such thing as a "simple tower defense game" (Its not normally the type of game we would recommend for beginners due to the complexity involved). I would recommend getting familiar with whatever debugger your IDE includes (here is a guide for eclipse: http://www.vogella.com/tutorials/EclipseDebugging/article.html ). If you still struggle you could post the relevant code here and ask for more specific advice.   I believe pretty much everything is screwed up. Should I just post all of my written code? And thanks for making me feel better :d
  9. I've been trying to use JMonkey Engine 3.0 to develop a simple tower defense game. I am only using cubes, and you select on a tower and press c to give it ammo. The bullets are just simple lines. There are so many problems in my code. I've been studying a java for about 8 months, and I am starting to feel discouraged. I'm actually following an exercise from my book, and I am confused as heck. The reason why I say that is because I can't seem to figure out how to debug my code. There's stupid stuff like when the cube-shaped enemy reaches the base, and it's z position is less than zero it will disappear, but it doesn't. I've been stuck on this for days.   Could I get any friendly and honest advice? Thanks 
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!