Skip to content
Snippets Groups Projects
Commit 0237fd39 authored by Yli-Tainio Janne Sakri Juhani's avatar Yli-Tainio Janne Sakri Juhani
Browse files

pistelaskuri, kolikkojen keräys, maali

parent b324443b
No related branches found
No related tags found
No related merge requests found
......@@ -8,13 +8,11 @@
</component>
<component name="ChangeListManager">
<list default="true" id="0cb08879-2df4-4f3a-a1a9-8178f387d135" name="Changes" comment="">
<change afterPath="$PROJECT_DIR$/kolikkogoblin/content/goblin1.png" afterDir="false" />
<change afterPath="$PROJECT_DIR$/kolikkogoblin/content/portaali.png" afterDir="false" />
<change afterPath="$PROJECT_DIR$/kolikkogoblin/content/tasonkuva1.png" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/.idea.kolikkogoblin/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/.idea.kolikkogoblin/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/kolikkogoblin/content/goblin2.png" beforeDir="false" afterPath="$PROJECT_DIR$/kolikkogoblin/content/goblin2.png" afterDir="false" />
<change beforePath="$PROJECT_DIR$/kolikkogoblin/content/goblin3.png" beforeDir="false" afterPath="$PROJECT_DIR$/kolikkogoblin/content/goblin3.png" afterDir="false" />
<change beforePath="$PROJECT_DIR$/kolikkogoblin/content/kolikko.png" beforeDir="false" afterPath="$PROJECT_DIR$/kolikkogoblin/content/kolikko.png" afterDir="false" />
<change beforePath="$PROJECT_DIR$/kolikkogoblin/content/palikka.png" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/kolikkogoblin/content/piikkeja.png" beforeDir="false" afterPath="$PROJECT_DIR$/kolikkogoblin/content/piikkeja.png" afterDir="false" />
<change beforePath="$PROJECT_DIR$/kolikkogoblin/content/tasonkuva.png" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/kolikkogoblin/kolikkogoblin.cs" beforeDir="false" afterPath="$PROJECT_DIR$/kolikkogoblin/kolikkogoblin.cs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/kolikkogoblin/kolikkogoblin.csproj" beforeDir="false" afterPath="$PROJECT_DIR$/kolikkogoblin/kolikkogoblin.csproj" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
......@@ -29,31 +27,35 @@
&quot;associatedIndex&quot;: 4
}</component>
<component name="ProjectId" id="2WqblizK0xS1l6qxX20E3VMkyn9" />
<component name="ProjectLevelVcsManager">
<ConfirmationsSetting value="2" id="Add" />
</component>
<component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent">{
&quot;keyToString&quot;: {
&quot;RunOnceActivity.OpenProjectViewOnStart&quot;: &quot;true&quot;,
&quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;,
&quot;WebServerToolWindowFactoryState&quot;: &quot;false&quot;,
&quot;XThreadsFramesViewSplitterKey&quot;: &quot;0.608985&quot;,
&quot;git-widget-placeholder&quot;: &quot;main&quot;,
&quot;node.js.detected.package.eslint&quot;: &quot;true&quot;,
&quot;node.js.detected.package.tslint&quot;: &quot;true&quot;,
&quot;node.js.selected.package.eslint&quot;: &quot;(autodetect)&quot;,
&quot;node.js.selected.package.tslint&quot;: &quot;(autodetect)&quot;,
&quot;vue.rearranger.settings.migration&quot;: &quot;true&quot;
<component name="PropertiesComponent"><![CDATA[{
"keyToString": {
"ASKED_ADD_EXTERNAL_FILES": "true",
"RunOnceActivity.OpenProjectViewOnStart": "true",
"RunOnceActivity.ShowReadmeOnStart": "true",
"WebServerToolWindowFactoryState": "false",
"XThreadsFramesViewSplitterKey": "0.7287234",
"git-widget-placeholder": "main",
"node.js.detected.package.eslint": "true",
"node.js.detected.package.tslint": "true",
"node.js.selected.package.eslint": "(autodetect)",
"node.js.selected.package.tslint": "(autodetect)",
"vue.rearranger.settings.migration": "true"
},
&quot;keyToStringList&quot;: {
&quot;rider.external.source.directories&quot;: [
&quot;C:\\Users\\Janne\\AppData\\Roaming\\JetBrains\\Rider2023.2\\resharper-host\\DecompilerCache&quot;,
&quot;C:\\Users\\Janne\\AppData\\Roaming\\JetBrains\\Rider2023.2\\resharper-host\\SourcesCache&quot;,
&quot;C:\\Users\\Janne\\AppData\\Local\\Symbols\\src&quot;
"keyToStringList": {
"rider.external.source.directories": [
"C:\\Users\\Janne\\AppData\\Roaming\\JetBrains\\Rider2023.2\\resharper-host\\DecompilerCache",
"C:\\Users\\Janne\\AppData\\Roaming\\JetBrains\\Rider2023.2\\resharper-host\\SourcesCache",
"C:\\Users\\Janne\\AppData\\Local\\Symbols\\src"
]
}
}</component>
}]]></component>
<component name="RunManager">
<configuration name="kolikkogoblin" type="DotNetProject" factoryName=".NET Project">
<option name="EXE_PATH" value="" />
......@@ -91,6 +93,7 @@
<workItem from="1697970578826" duration="3648000" />
<workItem from="1697975844304" duration="9893000" />
<workItem from="1698002748003" duration="5266000" />
<workItem from="1698053833135" duration="8530000" />
</task>
<servers />
</component>
......@@ -98,6 +101,7 @@
<option name="version" value="3" />
</component>
<component name="VcsManagerConfiguration">
<option name="ADD_EXTERNAL_FILES_SILENTLY" value="true" />
<option name="CLEAR_INITIAL_COMMIT_MESSAGE" value="true" />
</component>
</project>
\ No newline at end of file
kolikkogoblin/kolikkogoblin/content/portaali.png

241 B

kolikkogoblin/kolikkogoblin/content/tasonkuva.png

8.06 KiB

kolikkogoblin/kolikkogoblin/content/tasonkuva1.png

611 KiB

......@@ -14,17 +14,23 @@ namespace Kolikkogoblin;
public class Kolikkogoblin : PhysicsGame
{
private static readonly String[] lines = {
" p ",
" ",
" m ",
" * * XXXX",
" XX X ",
" X ",
" X ",
" * ",
" X ",
" ",
" ",
" ",
" ",
" X X XX * ",
" X ",
" X ",
" X ",
" * ",
" XXX ",
" w w g ",
" * X ",
" XXX X ",
" X ",
" wwww g ",
};
private static readonly int tileWidth = 800 / lines[0].Length;
......@@ -33,15 +39,19 @@ public class Kolikkogoblin : PhysicsGame
public override void Begin()
{
Gravity = new Vector(0, -500);
Level.Background.CreateGradient(Color.Black, Color.Gray);
Image taustakuva = LoadImage("tasonkuva1");
Level.Background.Image = taustakuva;
TileMap tiles = TileMap.FromStringArray(lines);
tiles.SetTileMethod('X', LuoPalikka, Color.Wheat);
tiles.SetTileMethod('*', LuoKolikko, Color.Yellow);
tiles.SetTileMethod('g', LuoGoblin, Color.Green);
tiles.SetTileMethod('w', LuoPiikkeja, Color.DarkGray);
tiles.SetTileMethod('m', LuoMaali, Color.Blue);
tiles.SetTileMethod('p', LuoPistelaskuri, Color.Blue);
tiles.Execute(tileWidth, tileHeight);
Level.CreateBorders();
......@@ -54,65 +64,118 @@ public class Kolikkogoblin : PhysicsGame
private void LuoPalikka(Vector paikka, double leveys, double korkeus, Color vari)
{
PhysicsObject palikka = new PhysicsObject(leveys , korkeus);
PhysicsObject palikka = new PhysicsObject(leveys , korkeus / 2);
palikka.Position = paikka;
palikka.Color = vari;
palikka.Tag = "rakenne";
palikka.Image = LoadImage("palikka");
palikka.IgnoresPhysicsLogics = true;
palikka.Mass = 100000;
Add(palikka);
}
private void LuoKolikko(Vector paikka, double leveys, double korkeus, Color vari)
{
PhysicsObject kolikko = new PhysicsObject(leveys * 1.5, leveys, Shape.Circle);
PhysicsObject kolikko = new PhysicsObject(leveys / 2, leveys / 2, Shape.Circle);
kolikko.Position = paikka;
kolikko.Color = vari;
kolikko.Tag = "kolikko";
kolikko.Image = LoadImage("kolikko");
kolikko.IgnoresGravity = true;
Add(kolikko);
}
private void LuoGoblin(Vector paikka, double leveys, double korkeus, Color vari)
{
PlatformCharacter goblin = new PlatformCharacter(leveys*2 , korkeus *2);
PlatformCharacter goblin = new PlatformCharacter(leveys*1.5 , korkeus *1.5);
goblin.Position = paikka;
goblin.Color = vari;
goblin.Image = LoadImage("goblin1");
Add(goblin);
Keyboard.Listen(Key.Left, ButtonState.Down, LiikutaPelaajaa, null, new Vector(-20000, 0));
Keyboard.Listen(Key.Right, ButtonState.Down, LiikutaPelaajaa, null, new Vector(20000, 0));
Keyboard.Listen(Key.Up, ButtonState.Down, PelaajaHyppaa, null, new Vector(0, 500));
Keyboard.Listen(Key.Down, ButtonState.Down, LiikutaPelaajaa, null, new Vector(0, -7000));
Image[] goblinKavely = LoadImages( "goblin2");
Image[] goblinHyppy = LoadImages( "goblin3");
Image[] goblinPaikallaan = LoadImages( "goblin1");
goblin.AnimWalk = new Animation(goblinKavely);
goblin.AnimIdle = new Animation(goblinPaikallaan);
goblin.AnimJump = new Animation(goblinHyppy);
Keyboard.Listen(Key.Left, ButtonState.Down, LiikutaPelaajaaVasemmalle, null, new Vector(-30000, 0));
Keyboard.Listen(Key.Right, ButtonState.Down, LiikutaPelaajaaOikealle, null, new Vector(30000, 0));
Keyboard.Listen(Key.Up, ButtonState.Down, PelaajaHyppaa, null, new Vector(0, 2200));
Keyboard.Listen(Key.Down, ButtonState.Down, LiikutaPelaajaaAlas, null, new Vector(0, -7000));
AddCollisionHandler<PlatformCharacter, PhysicsObject>(goblin, LoytaaKolikon);
void PelaajaHyppaa(Vector vektori)
{
goblin.Jump(50);
goblin.Jump(110);
}
void LiikutaPelaajaaOikealle(Vector vektori)
{
goblin.Walk(80);
}
void LiikutaPelaajaa(Vector vektori)
void LiikutaPelaajaaVasemmalle(Vector vektori)
{
goblin.Walk(-80);
}
void LiikutaPelaajaaAlas(Vector vektori)
{
goblin.Push(vektori);
}
}
private void LoytaaKolikon(PlatformCharacter goblin, PhysicsObject kolikko)
private void LoytaaKolikon(PlatformCharacter goblin, PhysicsObject kohde)
{
//MessageDisplay.Add("Löysit Kolikon!");
//AddCollisionHandler(kolikko, goblin, CollisionHandler.DestroyObject);
if (kohde.Tag.ToString() == "kolikko")
{
AddCollisionHandler(kohde, goblin, CollisionHandler.DestroyObject);
pistelaskuri.Value += 1;
}
}
private void LuoPiikkeja(Vector paikka, double leveys, double korkeus, Color vari)
{
PhysicsObject piikkeja = new PhysicsObject(100, 30);
piikkeja.IgnoresCollisionResponse = true;
PhysicsObject piikkeja = new PhysicsObject(leveys, 30);
piikkeja.Position = paikka;
Image piikkienkuva = LoadImage("piikkeja");
piikkeja.Image = piikkienkuva;
piikkeja.Tag = "piikkeja";
piikkeja.IgnoresPhysicsLogics = true;
piikkeja.Mass = 100000;
Add(piikkeja);
}
private void LuoMaali(Vector paikka, double leveys, double korkeus, Color vari)
{
PhysicsObject Portaali = new PhysicsObject(leveys , korkeus / 3);
Portaali.Position = paikka;
Portaali.Color = vari;
Portaali.Tag = "Maali";
Portaali.Image = LoadImage("Portaali");
Add(Portaali);
}
IntMeter pistelaskuri;
private void LuoPistelaskuri(Vector paikka, double leveys, double korkeus, Color vari)
{
pistelaskuri = new IntMeter(0);
Label pistenaytto = new Label();
pistenaytto.X = Screen.Left + 100;
pistenaytto.Y = Screen.Top - 100;
pistenaytto.TextColor = Color.Black;
pistenaytto.Color = Color.Silver;
pistenaytto.Title = "Kolikot:";
pistenaytto.BindTo(pistelaskuri);
Add(pistenaytto);
}
}
......@@ -13,9 +13,6 @@
<ItemGroup>
<None Update="content\tasonkuva.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="content\piikkeja.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
......@@ -34,6 +31,12 @@
<None Update="content\goblin1.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="content\portaali.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="content\tasonkuva1.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
......
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