Slick Forums https://slick.ninjacave.com/forum/ |
|
MarteEngine https://slick.ninjacave.com/forum/viewtopic.php?f=10&t=2702 |
Page 12 of 12 |
Author: | mikex [ Thu Nov 01, 2012 5:10 pm ] |
Post subject: | can't use Camera :( |
Author: | Stef [ Thu Nov 01, 2012 11:32 pm ] |
Post subject: | Re: MarteEngine |
Author: | lavago [ Fri Nov 02, 2012 3:18 am ] |
Post subject: | Re: MarteEngine |
Thank You So Much Stef! You Are A Life Saver! ![]() |
Author: | lavago [ Fri Nov 02, 2012 6:51 am ] |
Post subject: | Re: MarteEngine |
Author: | mikex [ Fri Nov 02, 2012 12:34 pm ] |
Post subject: | Woot ? it Worked :P |
Thanks Stef ![]() that new updated version worked just fine for me. and side-scrolling is also smooth however when i press jump and run than hero jumps smooth but when coming down camera trys to center hero and the hero goes a little back and the scence stops and ruins the smooth-ness EDIT :: Solved .. just had to put this line in update method camera.follow(hero, CameraFollowStyle.TOPDOWN); Thanks a lot for this awesome library ![]() |
Author: | sspitfire [ Wed Feb 19, 2014 10:17 am ] |
Post subject: | Re: MarteEngine |
Hi all. Im following the tutorials on the ME wiki and Im stuck at the input tutorial - it doesnt work for me in the Player and Level class - it only works in the HelloWorld Class using the slick2d methods for input. Can you point out my mistake ? Here are my classes following the tutorials. [code] import org.newdawn.slick.AppGameContainer; import org.newdawn.slick.GameContainer; import org.newdawn.slick.SlickException; import org.newdawn.slick.state.StateBasedGame; /** * Launch Hello World example **/ public class HelloWorldTest extends StateBasedGame { public HelloWorldTest(String title) { super(title); } @Override public void initStatesList(GameContainer container) throws SlickException { // add HelloWorld to current game with id 1 addState(new HelloWorld(1, container)); } public static void main(String[] argv) { try { AppGameContainer container = new AppGameContainer(new HelloWorldTest( "Hello World Marte Engine")); container.setDisplayMode(800, 600, false); container.setTargetFrameRate(60); container.start(); } catch (SlickException e) { e.printStackTrace(); } } } ======== import it.randomtower.engine.World; import org.newdawn.slick.GameContainer; import org.newdawn.slick.Graphics; import org.newdawn.slick.Image; import org.newdawn.slick.Input; import org.newdawn.slick.SlickException; import org.newdawn.slick.state.StateBasedGame; //import it.randomtower.engine.World; //slick input works public class HelloWorld extends World { private Image img; private boolean one = false; public HelloWorld(int id, GameContainer container) throws SlickException { super(id, container); img = new Image("data/Alien.png"); } @Override public void render(GameContainer container, StateBasedGame stateBasedGame, Graphics g) throws SlickException { super.render(container,stateBasedGame,g); g.drawString("Hello World", 300, 200); img.draw(100, 100, 0.2f); // if (one) g.drawString("one pressed", 100, 100); } @Override public void init(GameContainer container, StateBasedGame game) throws SlickException { // TODO Auto-generated method stub super.init(container, game); } @Override public void update(GameContainer arg0, StateBasedGame arg1, int arg2) throws SlickException { // TODO Auto-generated method stub super.update(arg0, arg1, arg2); Input in = container.getInput(); // if(in.isKeyDown(Input.KEY_1)) one = true; // if(in.isKeyDown(Input.KEY_4)) System.out.println("4 pressed"); } } ============ import org.newdawn.slick.GameContainer; import org.newdawn.slick.Graphics; import org.newdawn.slick.Image; import org.newdawn.slick.Input; import org.newdawn.slick.SlickException; import it.randomtower.engine.entity.Entity; //no input works public class Player extends Entity { /** * @param x, x coordinate on screen where Player starts * @param y, y coordinate on screen where Player starts * @throws SlickException */ public Player(float x, float y) throws SlickException { super(x, y); // load Image from disk and associate it as player image Image img = new Image("data/Alien.png"); setGraphic(img); // define a command to handle input define("RIGHT", Input.KEY_RIGHT); } @Override public void update(GameContainer container, int delta) throws SlickException { // TODO Auto-generated method stub super.update(container, delta); // check if a key is down if(check("RIGHT")){ // do anything you like, for example: x = x+10; System.out.println("right pressed!"); } // Input in = container.getInput(); // if(in.isKeyDown(Input.KEY_2)) System.out.println("2 is pressed!"); } @Override public void render(GameContainer arg0, Graphics arg1) throws SlickException { // TODO Auto-generated method stub super.render(arg0, arg1); } } ========== import org.newdawn.slick.GameContainer; import org.newdawn.slick.Graphics; import org.newdawn.slick.Input; import org.newdawn.slick.SlickException; import org.newdawn.slick.state.StateBasedGame; import it.randomtower.engine.ME; import it.randomtower.engine.World; import it.randomtower.engine.entity.Entity; //slick input not working public class Level extends World { private boolean five = false; /** * @param id, unique identifier for World * @param container, container for World */ public Level(int id, GameContainer container) { super(id, container); // TODO Auto-generated constructor stub } @Override public void add(Entity e) { // TODO Auto-generated method stub super.add(e); } @Override public void init(GameContainer container, StateBasedGame game) throws SlickException { super.init(container, game); Player player = new Player(100,100); add(player) ;// cant resolve World.GAME as in the tutorial } @Override public void update(GameContainer container, StateBasedGame game, int delta) throws SlickException { super.update(container, game, delta); Input in = container.getInput(); if(in.isKeyDown(Input.KEY_5)) { five = true; } } @Override public void render(GameContainer container, StateBasedGame game, Graphics g) throws SlickException { super.render(container, game, g); if(five) System.out.println("five!"); } } |
Page 12 of 12 | All times are UTC |
Powered by phpBB® Forum Software © phpBB Group http://www.phpbb.com/ |