anyways im just gonna post my code here if anyone have time to tell me what stupid mistakes im doing the function in question is called playermoveblock
THIS IS THE PLATFORM ENTITY CODE
package entities
{
import flash.geom.Point;
import net.flashpunk.Entity;
import net.flashpunk.FP;
import net.flashpunk.utils.Input;
import net.flashpunk.utils.Key;
import entities.invisiblewall
import net.flashpunk.graphics.Spritemap;
import entities.Player
public class collisionplatform extends Entity
{
[Embed(source = "../../assets/graphics/shadow.png")]
private const SHADOW:Class;
public var sprShadow:Spritemap = new Spritemap(SHADOW, 48, 32)
protected const PLATFORM_HSPEED:int = 70;
protected const PLATFORM_VSPEED:int = 50;
protected const GRAVITY2:int = 0;
protected const JUMP:int = 100;
protected var a:Point;
protected var v:Point;
public var player:Player;
public function collisionplatform()
{
type = "platform"
name = "player"
sprShadow.add("shadowstatic", [0, 1, 2, 3, 4, 5], 10, true);
sprShadow.add("shadowjump", [6, 7, 8, 9, 10, 11], 10, true);
setHitbox(20, 5)
a = new Point();
v = new Point();
graphic = sprShadow
}
public override function update():void
{
// Checking platform input.
var hInput:int = 0;
var vInput:int = 0;
if (Input.check(Key.LEFT))
{
(hInput -= 1);
}
if (Input.check(Key.RIGHT))
{
(hInput += 1);
}
if (Input.check(Key.DOWN))
{
(vInput += 1);
}
if (Input.check(Key.UP))
{
(vInput -= 1);
}
if (Input.pressed(Key.SPACE))
{
sprShadow.play("shadowstatic");
}
sprShadow.play("shadowjump");
if (collide("invisiblewall", x, y))
{
(vInput += 1);
}
var platform:collisionplatform = FP.world.getInstance("platform");
// Update physics.
v.x = PLATFORM_HSPEED * hInput;
v.y = PLATFORM_VSPEED * vInput;
a.y = GRAVITY2;
v.y += a.y;
// Apply physics.
x += v.x * FP.elapsed;
y += v.y * FP.elapsed;
//collision with ennemy
var player:Entity;
if(player = collide("Enemy", x, y))
{
player = (player as Player);
player.playermoveblock();
}
super.update();
}
}
}
THIS IS THE PLAYER ENTITY CODE
package entities
{
import flash.display.BitmapData;
import flash.geom.Point;
import net.flashpunk.graphics.Spritemap;
import net.flashpunk.Entity;
import net.flashpunk.FP;
import net.flashpunk.utils.Input;
import net.flashpunk.utils.Key;
import net.flashpunk.graphics.Anim
import entities.collisionplatform
public class Player extends Entity
{
[Embed(source="../../assets/graphics/sprite map low res fone.png")]
private const KOREANDUDE:Class;
[Embed(source = "../../assets/graphics/sprite map 2 low res.png")]
private const KOREANDUDEJUMP:Class;
public var angle:Number = 270.0;
public var sprKoreanDude:Spritemap = new Spritemap(KOREANDUDE, 48, 32)
public var sprKoreanDudeJUMP:Spritemap = new Spritemap(KOREANDUDEJUMP, 48, 32)
protected const PLAYER_HSPEED:int = 70;
protected const GRAVITY:int = 5;
protected const JUMP:int = 100;
protected var a:Point;
protected var v:Point;
public function Player()
{
type = "player"
name = "player";
sprKoreanDude.add("run", [0, 1, 2, 3, 4, 5], 10, true);
sprKoreanDude.add("stand", [6, 7, 8, 9, 10, 11], 10, true);
sprKoreanDudeJUMP.add("jump", [6, 7, 8, 9, 10, 11], 10, true);
sprKoreanDudeJUMP.add("runleft", [0, 1, 2, 3, 4, 5], 10,true);
graphic = sprKoreanDude
//graphic = sprKoreanDudeJUMP
setHitbox(25,30);
a = new Point();
v = new Point();
//sprKoreanDude.play("stand");
}
public override function update():void
{
// Checking player input.
var hInput:int = 0;
var vInput:int = 0;
if (Input.check(Key.LEFT))
{
(hInput -= 1) && (graphic = sprKoreanDudeJUMP) && (sprKoreanDudeJUMP.play("runleft"));
}
if (Input.check(Key.RIGHT))
{
(hInput += 1) && (graphic = sprKoreanDude) && (sprKoreanDude.play("run"));
}
if (hInput == 0)
{
(graphic = sprKoreanDude) && (sprKoreanDude.play("stand"));
}
if (Input.check(Key.SPACE))
{
(jump()) && (graphic = sprKoreanDudeJUMP) &&(sprKoreanDudeJUMP.play("jump"));
}
else
{
a.y = GRAVITY;
v.y += a.y;
}
//UP AND DOWN MOVEMENT
if (Input.check(Key.UP) && (collide("platform", x, y)))
{
y += -50 * FP.elapsed;
}
if (Input.check(Key.DOWN) && (collide("platform", x, y)))
{
y += 50 * FP.elapsed;
}
//CHECKED
if (Input.check(Key.PAGE_DOWN))
{
playermoveblock();
}
// Update physics.
v.x = PLAYER_HSPEED * hInput;
//PLAYER_VSPEED * vInput = false
a.y = GRAVITY;
v.y += a.y;
// Apply physics.
x += v.x * FP.elapsed;
y += v.y * FP.elapsed;
//Collision with platform
if (collide("platform", x, y))
{
v.y = -10;
}
// Simple collision with boundries.
if(y + height > FP.screen.height)
{
v.y = 0;
y = FP.screen.height - height;
}
// Update parent shit.
super.update();
}
public function playermoveblock():void
{
y += -50 * FP.elapsed;
}
protected function jump():void
{
if(collide("platform", x, y))
{
v.y = -JUMP;
}
}
}
}
Dont know what else to do.