List of usage examples for com.badlogic.gdx.math Vector2 Vector2
public Vector2()
From source file:com.blindtigergames.werescrewed.debug.SBox2DDebugRenderer.java
License:Apache License
public SBox2DDebugRenderer(float _box_to_world_scale, boolean drawBodies, boolean drawJoints, boolean drawAABBs, boolean drawInactiveBodies, boolean drawVelocities) { box_to_world_scale = _box_to_world_scale; // next we setup the immediate mode renderer renderer = new ShapeRenderer(); renderer.scale(box_to_world_scale, box_to_world_scale, 1); lower = new Vector2(); upper = new Vector2(); // initialize vertices array for (int i = 0; i < vertices.length; i++) vertices[i] = new Vector2(); this.drawBodies = drawBodies; this.drawJoints = drawJoints; this.drawAABBs = drawAABBs; this.drawInactiveBodies = drawInactiveBodies; this.drawVelocities = drawVelocities; }
From source file:com.bss.game.Hook.java
License:Apache License
public Hook(float x, float y, World world) { super(x, y, 45f, 45f); this.world = world; //state = GOING_UP; state = STILL;/*from www .j av a 2 s. c o m*/ //velocity.set(30f, 30f); //hookingNow = true; maxReached = false; firstUpdate = true; direction = new Vector2(); movement = new Vector2(); velocity.set(0f, 5f); hookingVelocity = new Vector2(); circleBounds = new Circle(position.x + 23f, position.y + 23f, 23f); }
From source file:com.bss.game.World.java
License:Apache License
public World(WorldListener listener) { this.slappy = new SlappySeal(-10f, 95f); ///* w w w .jav a 2s.co m*/ this.hook = new Hook(80f, 250f, this); //this.boot = new Boot(480f, 400f, this, 0); //this.trout = new Trout(200f, 800f, this, 0); pointPosition = new Vector2(); //this.hook.velocity.setAngle(90f); // /*this.platforms = new ArrayList<Platform>(); this.springs = new ArrayList<Spring>(); this.squirrels = new ArrayList<Squirrel>(); this.coins = new ArrayList<Coin>();*/ this.listener = listener; rand = new Random(); //generateLevel(); //this.heightSoFar = 0; //this.score = 0; time = 10; timeText = "" + time; layout = new GlyphLayout(Assets.font, timeText, Color.YELLOW, 0f, 0, false); //layout.setText(font, timeText, Color.BLACK, 0f, 0, false); this.state = WORLD_STATE_RUNNING; i = new Intersector(); eh = new EllipseHit(10); enemies = new ArrayList<EnemyGameObject>(); hookedEnemies = new ArrayList<EnemyGameObject>(); setEnemiesFirst(); hookedFish = 0; }
From source file:com.disc.jammers.boxsprite.players.Player.java
public Player(World world, EventQueue queue, AssetManager manager, int player) { super(queue, manager); destination = new Vector2(); slidingDest = new Vector2(); playerObject = new EventObject(); upperBound = new Table.DebugRect(); lowerBound = new Table.DebugRect(); midBound = new Table.DebugRect(); playerRec = new Table.DebugRect(); bound = new ShapeRenderer(); isPlayerA = player == 0;//from w w w. j a v a2 s . com this.world = world; }
From source file:com.dongbat.game.buff.effects.AttractedToSource.java
@Override public void durationStart(World world, Entity source, Entity t) { MovementUtil.disableMovement(t);//w w w . ja v a 2 s . c om PhysicsUtil.setVelocity(world, t, new Vector2()); }
From source file:com.dongbat.game.buff.effects.AttractedToSource.java
@Override public void durationEnd(World world, Entity source, Entity target) { MovementUtil.enableMovement(target); PhysicsUtil.setVelocity(world, target, new Vector2()); }
From source file:com.dongbat.game.buff.effects.Respawn.java
@Override public void durationStart(World world, Entity source, Entity target) { PhysicsUtil.setRadius(source.getWorld(), source, 0f); EntityUtil.getComponent(world, target, Stats.class).setAllowComsumming(false); EntityUtil.getComponent(world, target, Stats.class).setConsumable(false); PhysicsUtil.setVelocity(world, target, new Vector2()); EntityUtil.getComponent(world, target, UnitMovement.class).setDisabled(true); if (WorldQueryUtil.isAiUnit(world, target.getId())) { PhysicsUtil.setPosition(target.getWorld(), target, new Vector2(150, 150)); }/* ww w. j av a 2s . c om*/ }
From source file:com.dongbat.game.util.factory.EntityFactory.java
/** * Create player unit and add to world/* ww w . j a va 2 s. c o m*/ * * @param world artemis world * @param type * @param position spawn position * @return Player entity that was just created */ public static Entity createPlayer(World world, Vector2 position, String type) { Entity e = world.createEntity(UUID.randomUUID()); CollisionComponent collision = new CollisionComponent(); UnitType unitType = new UnitType(type); UnitInfo info = UnitRegistry.get(type); String abilities = info.getAbilities(); AbilityComponent abilityComponent = new AbilityComponent(); AbilityUtil.abilityComponentFilled(abilities, abilityComponent); Stats stats = new Stats(); stats.setBaseRateSpeed(info.getBaseSpeedRate()); Physics physics = new Physics(); physics.setBody(PhysicsUtil.createBody(PhysicsUtil.getPhysicsWorld(world), position, info.getRadius(), e)); physics.getBody().setUserData(UuidUtil.getUuid(e)); UnitMovement movement = new UnitMovement(); movement.setDirectionVelocity(new Vector2()); movement.setDisabled(false); Player player = new Player(); Display display = new Display(); e.edit().add(abilityComponent).add(unitType).add(new BuffComponent()).add(physics).add(stats).add(player) .add(movement).add(new Detection()).add(collision).add(display); display.setPosition(PhysicsUtil.getPosition(world, e)); display.setRadius(PhysicsUtil.getRadius(world, e)); display.setRotation(EntityUtil.getComponent(world, e, UnitMovement.class).getDirectionVelocity().angle()); // TextureAtlas move = AssetUtil.getUnitAtlas().get("move"); // Animation animation = new Animation(0.1f, move.getRegions()); // animation.setPlayMode(Animation.PlayMode.LOOP); // display.setDefaultAnimation(new AnimatedSprite(animation)); display.setDefaultAnimation(AnimationUtil.getUnitAnimation()); return e; }
From source file:com.dongbat.game.util.factory.EntityFactory.java
/** * Create Food with box2d Steering behavior * * @param world artemis world//www.j a va 2 s . co m * @param position spawn position * @return Food entity that was just created */ public static Entity createFood(World world, Vector2 position, UUID parent) { Entity e = world.createEntity(UUID.randomUUID()); Physics physics = new Physics(); physics.setBody(PhysicsUtil.createBody(PhysicsUtil.getPhysicsWorld(world), position, FOOD_RADIUS, e)); physics.getBody().setUserData(UuidUtil.getUuid(e)); Stats s = new Stats(); s.setConsumable(true); s.setAllowComsumming(false); s.setParent(parent); UnitMovement movement = new UnitMovement(); movement.setDirectionVelocity(new Vector2()); Display display = new Display(); e.edit().add(new CollisionComponent()).add(physics).add(s).add(new Food()).add(movement) .add(new Detection()).add(new BuffComponent()).add(display); display.setPosition(PhysicsUtil.getPosition(world, e)); display.setRadius(PhysicsUtil.getRadius(world, e)); display.setRotation(EntityUtil.getComponent(world, e, UnitMovement.class).getDirectionVelocity().angle()); display.setDefaultAnimation(AnimationUtil.getHotFood()); return e; }
From source file:com.dongbat.game.util.factory.UnitFactory.java
/** * Create projectile unit/*from w ww . j a v a 2s . co m*/ * * @param world artemis world * @param parent entity that execute that projectile unit * @param position spawn position * @param radius unit radius * @return projectile unit that was just created */ public static Entity createProjectileUnit(World world, Entity parent, Vector2 position, float radius, boolean allowConsumming, boolean consumable, boolean feedParent) { Entity e = world.createEntity(UUID.randomUUID()); Stats stats = new Stats(); stats.setAllowComsumming(allowConsumming); stats.setConsumable(consumable); stats.setParent(world.getManager(UuidEntityManager.class).getUuid(parent)); stats.setFeedParent(feedParent); Physics physics = new Physics(); physics.setBody(PhysicsUtil.createBody(PhysicsUtil.getPhysicsWorld(world), position, radius, e)); physics.getBody().setUserData(UuidUtil.getUuid(e)); physics.getBody().setBullet(true); e.edit().add(physics); UnitMovement movement = new UnitMovement(); movement.setDirectionVelocity(new Vector2()); Display display = new Display(); e.edit().add(stats).add(new Player(false)).add(new BuffComponent()).add(new SubUnit()) .add(new CollisionComponent()).add(new Detection()).add(movement).add(display); display.setPosition(PhysicsUtil.getPosition(world, e)); display.setRadius(PhysicsUtil.getRadius(world, e)); display.setRotation(EntityUtil.getComponent(world, e, UnitMovement.class).getDirectionVelocity().angle()); // TextureAtlas move = AssetUtil.getUnitAtlas().get("hot_food"); Animation animation = new Animation(0.1f, new TextureRegion(AssetUtil.cold)); animation.setPlayMode(Animation.PlayMode.LOOP); display.setDefaultAnimation(new AnimatedSprite(animation)); return e; }