Slick Forums

Discuss the Slick 2D Library
It is currently Wed May 22, 2013 6:55 pm

All times are UTC




Post new topic Reply to topic  [ 170 posts ]  Go to page Previous  1 ... 8, 9, 10, 11, 12
Author Message
 Post subject: can't use Camera :(
PostPosted: Thu Nov 01, 2012 5:10 pm 
Offline

Joined: Wed Oct 24, 2012 2:31 pm
Posts: 10
first of all thanks a lot for this awesome library

i m trying to do a simple side scroller game test and i think it can be done through Camera class right ? i am not sure . i downloaded latest zip from github , is there any problem with camera class ?
i am using netbeans everything is working fine, character is moving also but when i try this code in GameWorld ..

Code:
setCamera(new [b]Camera[/b](this, hero, gc.getWidth(),
           gc.getHeight(), 550, 170, hero.maxSpeed));


but there is a redline in bold-ed text Camera, an Error in constructor
and i dont get it class is importing just fine i just cant get it working there is no problem i checked many times What is Wrong ? please help Thanks :(


Top
 Profile  
 
 Post subject: Re: MarteEngine
PostPosted: Thu Nov 01, 2012 11:32 pm 
Offline
Site Admin

Joined: Mon Dec 08, 2008 2:17 pm
Posts: 140
lavago, I've compiled the Marte engine 0.3 src for you, you can download it here:

jar
Javadoc
sources
Full distribution

and these are the changes between 0.2 and 0.3:
Changes in ResourceManager:
Quote:
Allow to define an Animation from resources.xml
Rename <int> and <float> to <param> in resources.xml
Return Font instead of AngelCodeFont from getFont
Allow to load resources in 1 line: ResourceManager.loadResources("resources.xml");

Changes in Entity:
Quote:
currentAnim is now private, use setAnim
animations is now private, use addAnimation, isCurrentAnim and getCurrentAnim
currentImage is now private use setGraphic, getCurrentImage
resume, pause, restart alarms using entity.alarms
active is false when an entity is removed(#66)
Add anim does not set the entity animation, Use setAnim to set the initial animation.
define is deprecated, use bindToKey or bindToMouse in Entity and World(#59)

Other changes:
Quote:
Control sound and music using the new SFX class
A default camera is created in the world. To follow an entity use:
camera.follow(entity, CameraFollowStyle.TOPDOWN);
see it.marteEngine.test.avatar for usage.

Split build file into 2 parts: ME distribution and game distribution.
Use a String as id in the StateManager


Top
 Profile  
 
 Post subject: Re: MarteEngine
PostPosted: Fri Nov 02, 2012 3:18 am 
Offline

Joined: Thu Aug 30, 2012 12:13 am
Posts: 43
Thank You So Much Stef! You Are A Life Saver! :D


Top
 Profile  
 
 Post subject: Re: MarteEngine
PostPosted: Fri Nov 02, 2012 6:51 am 
Offline

Joined: Thu Aug 30, 2012 12:13 am
Posts: 43
Hey, I was wondering why my player wasn't moving when press the right or left arrow keys.

Code:
package gamepackage;

import it.marteEngine.entity.*;
import org.newdawn.slick.*;
import org.newdawn.slick.state.*;

public class PlayerFox extends Entity {
   
   public static String PFox = "pfox";
   
   Image foxsheet = new Image("Resources/Fox.png");
   Image foxleft = foxsheet.getSubImage(0, 0, 26, 18);
   Image foxright = foxsheet.getSubImage(52, 0, 26, 18);
   Image[] foxlefta = {foxsheet.getSubImage(0, 0, 26, 18), foxsheet.getSubImage(26, 0, 26, 18)};
   Image[] foxrighta = {foxsheet.getSubImage(52, 0, 26, 18), foxsheet.getSubImage(78, 0, 26, 18)};
   Animation ismovingleft = new Animation(foxlefta,300,true);
   Animation ismovingright = new Animation(foxrighta,300,true);
   
   public PlayerFox(float x, float y) throws SlickException {
      super(x, y);
      addType(PFox);
      setHitBox(0, 0, width, height);
      setGraphic(foxright);
      
   }

   public void render(GameContainer gc, StateBasedGame sbg, Graphics g) throws SlickException {
      super.render(gc, g);
   }

   public void update(GameContainer gc, StateBasedGame sbg, int delta) throws SlickException, InterruptedException {
      super.update(gc, delta);
      addAnimation("movingright", ismovingright);
      addAnimation("movingleft", ismovingleft);
      Input input = gc.getInput();
      
      if(input.isKeyPressed(Input.KEY_RIGHT)) {
         x -= (5 * delta);
         setAnim("movingright");
      }
      if(input.isKeyPressed(Input.KEY_LEFT)) {
         x += (5 * delta);
         setAnim("movingleft");
      }
      if(input.isKeyPressed(Input.KEY_SPACE)) {
         
      }
   }

}


Top
 Profile  
 
 Post subject: Woot ? it Worked :P
PostPosted: Fri Nov 02, 2012 12:34 pm 
Offline

Joined: Wed Oct 24, 2012 2:31 pm
Posts: 10
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 :)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 170 posts ]  Go to page Previous  1 ... 8, 9, 10, 11, 12

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group