Skip to content
Snippets Groups Projects
Commit 9ae38966 authored by Mattila Arttu Matias's avatar Mattila Arttu Matias
Browse files

koodia kirjoitettu lisää

parent fa3f9a48
No related branches found
No related tags found
No related merge requests found
......@@ -81,7 +81,7 @@
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1698072096858</updated>
<workItem from="1698072097960" duration="4604000" />
<workItem from="1698072097960" duration="10823000" />
</task>
<servers />
</component>
......
using System;
using System.Collections.Generic;
using System.Net.Mail;
using Jypeli;
using Jypeli.Assets;
using Jypeli.Controls;
......@@ -14,14 +15,45 @@ namespace Asteroid_Blaster;
/// </summary>
public class Asteroid_Blaster : PhysicsGame
{
// private Image[] sotilas = LoadImages("sotilasPaikallaan");
private Vector nopeusVasen = new Vector(-400, 0);
private Vector nopeusOikea = new Vector(400, 0);
private PhysicsObject sotilas;
private Image[] sotilasLiikkuu = LoadImages("sotilasPaikallaan", "sotilasliike", "sotilasjuoksee" );
public override void Begin()
{
PhysicsObject sotilas = new PhysicsObject(170,150);
Add(sotilas);
sotilas.Image = LoadImage("sotilasPaikallaan");
AsetaOhjaimet(); // pääohjelma näppäimille
Kentta
Level.CreateLeftBorder(0, false); // Luodaan kentälle rajat. Ylös ei luoda koska meterotien pitää tulla sieltä
Level.CreateBottomBorder(0, false);
Level.CreateRightBorder(0, false);
Camera.ZoomToLevel();
PhoneBackButton.Listen(ConfirmExit, "Lopeta peli");
Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli");
}
PhysicsObject LuoSotilas(double x, double y)
{
PhysicsObject sotilas = new PhysicsObject(170,150); // Luodaan sotilas ja annetaan sille kuva ja paikka
sotilas.X = 0.0;
sotilas.Y = Level.Bottom + 50;
sotilas.Image = LoadImage("sotilasPaikallaan");
Add(sotilas);
return sotilas;
}
void AsetaOhjaimet() // aliohjelma näppäimille
{
Keyboard.Listen(Key.Left, ButtonState.Down, AsetaNopeus, null, sotilas, nopeusVasen);
Keyboard.Listen(Key.Right, ButtonState.Down, AsetaNopeus, null, sotilas, nopeusOikea);
}
void AsetaNopeus(PhysicsObject sotilas, Vector nopeus)
{
sotilas.Velocity = nopeus;
}
}
\ No newline at end of file
......@@ -19,6 +19,12 @@
<None Update="Content\sotilasPaikallaan.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Content\sotilasjuoksee.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Content\sotilasliike.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment