@@ -9,8 +9,9 @@ class Arm : Sprite
{
private Player _player;
private Vec2 _armVector;
public Projectiles projectile;

public Arm(Player player) : base("checkers.png")
public Arm(Player player) : base("hand.png")
{
SetOrigin(0, height / 2);
_player = player;
@@ -24,17 +25,29 @@ void Update()

void RotateArm ()
{
float angleInRadians = Mathf.Atan2(_armVector.y, _armVector.x);
rotation = Vec2.Rad2Deg(angleInRadians);
float angleInRadians;
if (_player.scaleX == 1)
{
angleInRadians = Mathf.Atan2(_armVector.y, _armVector.x);
rotation = Vec2.Rad2Deg(angleInRadians);
}
if (_player.scaleX == -1)
{
angleInRadians = -Mathf.Atan2(_armVector.y, _armVector.x);
rotation = Vec2.Rad2Deg(angleInRadians) + 180;
}
}

public void Shooting()
{
Projectiles Projectile = new Projectiles();
game.AddChild(Projectile);
Projectile.x = _player.x + _armVector.x;
Projectile.y = _player.y + _armVector.y;
Projectile.rotation = this.rotation;
if(projectile == null)
{
projectile = new Projectiles();
game.AddChild(projectile);
projectile.x = _player.x + _armVector.x;
projectile.y = _player.y + _armVector.y;
projectile.rotation = Vec2.Rad2Deg(Mathf.Atan2(_armVector.y, _armVector.x));
}
}


@@ -35,28 +35,40 @@ void Update()

private void CheckCollision()
{
for(int i = background.Count - 1; i >= 0; i--)
for (int i = background.Count - 1; i >= 0; i--)
{
AnimSprite anims = background[i];
if (anims.HitTest(player))
{
if(tiles[i] == 2)
if (tiles[i] == 8)
{
player.position.y = playerOldY;
player.position.y = anims.y - player.height / 2;
player.velocity.y = 0;
player.SetOnGound();
}
if (tiles[i] == 12)
if (tiles[i] == 4)
{
player.position.x = playerOldX;
player.position.x = anims.x + player.width / 2 + 32;
player.velocity.x = 0;
}
if(tiles[i] == 10)
if (tiles[i] == 6)
{
player.position.x = playerOldX;
player.position.x = anims.x - player.width / 2;
player.velocity.x = 0;
}
}
if (player.arm.projectile != null)
{
if (anims.HitTest(player.arm.projectile))
{
if(tiles[i] == 8 || tiles[i] == 4 || tiles[i] == 6 || tiles[i] == 2)
{
player.arm.projectile.Destroy();
player.arm.projectile = null;
Console.WriteLine("CREATING PORTALSSSs");
}
}
}
}
}

@@ -9,7 +9,7 @@ public class TMXLevel : GameObject
{
//constructor not used because level uses inheritence and only needs the methods
private AnimSprite animSprite;
const int TileSize = 64;
const int TileSize = 32;

protected List<Item> items = new List<Item>();
protected List<AnimSprite> background = new List<AnimSprite>();
@@ -123,7 +123,7 @@ private void interpretCell(int x, int y, int frame)
//adding an animation sprite with the right frame from the level
private void AddSprite(int frame)
{
animSprite = new AnimSprite("tilesheet1.png", 9, 5);
animSprite = new AnimSprite("tilesheet.png", 3, 3);
animSprite.SetFrame(frame);
AddChild(animSprite);
background.Add(animSprite);
@@ -7,13 +7,12 @@ public class MyGame : Game

public MyGame () : base(1024, 768, false)
{
Level level = new Level("level1.tmx");
Level level = new Level("level2.tmx");
AddChild(level);
}

void Update ()
{

}

static void Main() {
@@ -19,8 +19,8 @@ class Player : AnimSprite
private float frame = 0.0f;
private float firstframe = 0.0f;
private float lastframe = 0.0f;
private int _directionX;
private Arm arm;
private int _directionX = 1;
public Arm arm;

public Player(Vec2 pPosition = null) : base("player.png", 16 , 2)
{
@@ -39,6 +39,7 @@ public Player(Vec2 pPosition = null) : base("player.png", 16 , 2)

void Update()
{
Console.WriteLine(velocity.y);
UpdateAnimation();
Movements();
Step();
@@ -49,32 +50,30 @@ void Update()

private void Movements()
{
if (Input.mouseX <= x)
_directionX = -1;
if (Input.mouseX >= x)
_directionX = 1;
if (Input.GetMouseButtonDown(0))
arm.Shooting();
if (Input.GetKeyDown(Key.W))
{
if (onGround)
{
acceleration.Add(new Vec2(0, -20));
Console.WriteLine(true);

}
}
if (Input.GetKey(Key.D))
{
acceleration.Add(new Vec2(1, 0));
firstframe = 0;
lastframe = 15;
_directionX = 1;
acceleration.Add(new Vec2(0.8f, 0));
}

else if (Input.GetKey(Key.A))
{
acceleration.Add(new Vec2(-1, 0));
firstframe = 0;
lastframe = 15;
_directionX = -1;
acceleration.Add(new Vec2(-0.8f, 0));
}

else {
firstframe = 16;
lastframe = 22;
onGround = false;
}
scaleX = _directionX;
@@ -136,11 +135,39 @@ public void SetOnGound()

void UpdateAnimation()
{
frame = frame + 0.2f;
if (frame >= lastframe + 1)
frame = firstframe;
if (frame < firstframe)
frame = lastframe;
if (velocity.y == 0)
{
if (Mathf.Abs(velocity.x) > 1.5f)
{
frame = frame + velocity.x / 15 * _directionX;

firstframe = 0;
lastframe = 15;
}
else
{
frame += 0.1f;

firstframe = 16;
lastframe = 22;
}
if (frame < firstframe)
{
frame = lastframe;
}
if (frame > lastframe)
{
frame = firstframe;
}
}
else if (velocity.y <= -1)
frame = 23;
else if (velocity.y > -1 && velocity.y < 5)
frame = 24;
else if (velocity.y > 5)
frame = 25;


SetFrame((int)frame);
}
}
@@ -16,5 +16,6 @@ void Update ()
{
Move(15, 0);
}

}
}
Binary file not shown.
Binary file not shown.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<map version="1.0" orientation="orthogonal" renderorder="right-down" width="32" height="24" tilewidth="32" tileheight="32" nextobjectid="1">
<tileset firstgid="1" name="tilesheet" tilewidth="32" tileheight="32" tilecount="9">
<image source="tilesheet.png" width="96" height="96"/>
</tileset>
<layer name="Kachelebene 1" width="32" height="24">
<data encoding="csv">
1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,3,
4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,6,
4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,6,
4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,6,
4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,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0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,6,
4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,6,
4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,6,
7,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,9
</data>
</layer>
</map>
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
@@ -18,13 +18,13 @@ C:\Users\MasteR\Desktop\Start GXP\sourcefiles\GXPEngine\obj\x86\Debug\GXPEngine.
C:\Users\MasteR\Desktop\Start GXP\sourcefiles\GXPEngine\bin\Debug\GXPEngine.exe
C:\Users\MasteR\Desktop\Start GXP\sourcefiles\GXPEngine\bin\Debug\GXPEngine.pdb
C:\Users\MasteR\Desktop\Start GXP\sourcefiles\GXPEngine\obj\x86\Debug\GXPEngine.csprojResolveAssemblyReference.cache
C:\Users\Roedie\Desktop\Start GXP\sourcefiles\GXPEngine\obj\x86\Debug\GXPEngine.exe
C:\Users\Roedie\Desktop\Start GXP\sourcefiles\GXPEngine\obj\x86\Debug\GXPEngine.pdb
C:\Users\Roedie\Desktop\Start GXP\sourcefiles\GXPEngine\obj\x86\Debug\GXPEngine.csprojResolveAssemblyReference.cache
C:\Users\Roedie\Desktop\Start GXP\sourcefiles\GXPEngine\bin\Debug\GXPEngine.exe
C:\Users\Roedie\Desktop\Start GXP\sourcefiles\GXPEngine\bin\Debug\GXPEngine.pdb
C:\Users\Roedie\Desktop\Elliptica\GXP\sourcefiles\GXPEngine\obj\x86\Debug\GXPEngine.exe
C:\Users\Roedie\Desktop\Elliptica\GXP\sourcefiles\GXPEngine\obj\x86\Debug\GXPEngine.pdb
C:\Users\Roedie\Desktop\Elliptica\GXP\sourcefiles\GXPEngine\obj\x86\Debug\GXPEngine.csprojResolveAssemblyReference.cache
C:\Users\Roedie\Desktop\Elliptica\GXP\sourcefiles\GXPEngine\bin\Debug\GXPEngine.exe
C:\Users\Roedie\Desktop\Elliptica\GXP\sourcefiles\GXPEngine\bin\Debug\GXPEngine.pdb
C:\Users\Slixx\Documents\GitHub\Elliptica\GXP\sourcefiles\GXPEngine\obj\x86\Debug\GXPEngine.exe
C:\Users\Slixx\Documents\GitHub\Elliptica\GXP\sourcefiles\GXPEngine\obj\x86\Debug\GXPEngine.pdb
C:\Users\Slixx\Documents\GitHub\Elliptica\GXP\sourcefiles\GXPEngine\bin\Debug\GXPEngine.exe
C:\Users\Slixx\Documents\GitHub\Elliptica\GXP\sourcefiles\GXPEngine\bin\Debug\GXPEngine.pdb
C:\Users\Slixx\Documents\GitHub\Elliptica\GXP\sourcefiles\GXPEngine\obj\x86\Debug\GXPEngine.csprojResolveAssemblyReference.cache
C:\Users\Slixx\Desktop\Elliptica\GXP\sourcefiles\GXPEngine\obj\x86\Debug\GXPEngine.exe
C:\Users\Slixx\Desktop\Elliptica\GXP\sourcefiles\GXPEngine\obj\x86\Debug\GXPEngine.pdb
C:\Users\Slixx\Desktop\Elliptica\GXP\sourcefiles\GXPEngine\bin\Debug\GXPEngine.exe
C:\Users\Slixx\Desktop\Elliptica\GXP\sourcefiles\GXPEngine\bin\Debug\GXPEngine.pdb
C:\Users\Slixx\Desktop\Elliptica\GXP\sourcefiles\GXPEngine\obj\x86\Debug\GXPEngine.csprojResolveAssemblyReference.cache
Binary file not shown.
Binary file not shown.
Binary file not shown.