Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
ohj1ht
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pepihlaj
ohj1ht
Commits
8de2bcb2
Commit
8de2bcb2
authored
2 years ago
by
Pekka Pihlajamaa
Browse files
Options
Downloads
Patches
Plain Diff
viimeiset viilaukset
parent
c88e9abe
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Hiko/Hiko/Hiko.cs
+54
-27
54 additions, 27 deletions
Hiko/Hiko/Hiko.cs
with
54 additions
and
27 deletions
Hiko/Hiko/Hiko.cs
+
54
−
27
View file @
8de2bcb2
...
...
@@ -3,11 +3,12 @@ using Jypeli.Assets;
using
Jypeli.Controls
;
using
Jypeli.Widgets
;
using
System
;
using
System.Collections.Generic
;
using
System.Runtime.CompilerServices
;
using
System.Security.Cryptography
;
using
System.Threading
;
/// @author pepihlaj
/// @version 15.11.2022
/// <summary>
/// HIKO peli
/// </summary>
namespace
Hiko
{
/// <summary>
...
...
@@ -20,24 +21,29 @@ namespace Hiko
public
Vihu
(
double
leveys
,
double
korkeus
)
:
base
(
leveys
,
korkeus
)
{
elamalaskuri
.
LowerLimit
+=
delegate
{
this
.
Destroy
();
};
elamalaskuri
.
LowerLimit
+=
delegate
{
this
.
Destroy
();
};
//kun vihun hp tippuu nolliin se poistetaan
}
}
/// <summary>
/// Peli
/// </summary>
public
class
Hiko
:
PhysicsGame
{
PhysicsObject
pelaaja
;
GameObject
tahtain
;
Image
taustakuva
=
LoadImage
(
"Testitaustakuva"
);
IntMeter
pistelaskuri
;
Label
aikanaytto
;
int
jaljellaOlevatVihut
;
private
ScoreList
topLista
=
new
ScoreList
(
10
,
false
,
0
);
bool
temp
=
true
;
PhysicsObject
pelaaja
;
//varsinainen kontrolloitava pelaaja
GameObject
tahtain
;
//tähtäin jota käyttäjä voi kontrolloida
Image
taustakuva
=
LoadImage
(
"Testitaustakuva"
);
//taustakuva peliin
IntMeter
pistelaskuri
;
//piste laskuri jota käytetään käyttäjän tehokkuuden laskemiseen
Label
aikanaytto
;
//tällä saadaan aika käytettävään muotoon
int
jaljellaOlevatVihut
;
//vihujen lkm kentässä, pelaaja voittaa pelin kun niitä on nolla
private
ScoreList
topLista
=
new
ScoreList
(
10
,
false
,
0
);
bool
tarkistin
=
true
;
/// <summary>
///
L
uodaan peliin kenttä
///
Tällä taulukolla l
uodaan peliin kenttä
/// </summary>
private
static
readonly
String
[]
lines
=
{
...
...
@@ -67,6 +73,13 @@ namespace Hiko
};
private
static
readonly
int
tileWidth
=
800
/
lines
[
0
].
Length
;
private
static
readonly
int
tileHeight
=
480
/
lines
.
Length
;
/// <summary>
/// Tämä funktio laskee vihollisten lukumäärän taulukosta silmukalla
/// </summary>
/// <param name="vihutaulukko">Annettu taulukko josta vihut lasketaan</param>
/// <returns></returns>
public
static
int
LaskeVihollistenMaara
(
String
[]
vihutaulukko
)
{
int
vihujenLkm
=
0
;
...
...
@@ -80,9 +93,13 @@ namespace Hiko
return
vihujenLkm
;
}
/// <summary>
/// Begin metodi avaa alkuvalikon
/// </summary>
public
override
void
Begin
()
{
if
(
t
emp
)
if
(
t
arkistin
)
{
// Kirjoita ohjelmakoodisi tähän
...
...
@@ -97,7 +114,7 @@ namespace Hiko
alkuvalikko
.
SetButtonTextColor
(
Color
.
Blue
);
Add
(
alkuvalikko
);
}
t
emp
=
false
;
t
arkistin
=
false
;
}
...
...
@@ -134,17 +151,16 @@ namespace Hiko
}
/// <summary>
/// Tämä aliohjelma avaa parhaat pisteet alkuvalikkoon
/// </summary>
void
ParhaatPisteet
()
{
t
emp
=
true
;
t
arkistin
=
true
;
topLista
=
DataStorage
.
TryLoad
<
ScoreList
>(
topLista
,
"pisteet.xml"
);
HighScoreWindow
topIkkuna
=
new
HighScoreWindow
(
"Tehokkaimmat nukkujat"
,
topLista
);
Add
(
topIkkuna
);
Mouse
.
Listen
(
MouseButton
.
Left
,
ButtonState
.
Down
,
Begin
,
null
);
}
...
...
@@ -169,8 +185,8 @@ namespace Hiko
/// <summary>
/// Kun pelaaja törmää vihuun aliohjelma
/// </summary>
/// <param name="tormaaja"></param>
/// <param name="kohde"></param>
/// <param name="tormaaja">
pelaaja törmää
</param>
/// <param name="kohde">
kohde johon pelaaja törmää
</param>
void
PelaajaTormasi
(
PhysicsObject
tormaaja
,
Vihu
kohde
)
{
PelaajaKuolee
();
...
...
@@ -203,12 +219,13 @@ namespace Hiko
Add
(
topIkkuna
);
}
/// <summary>
///
Luo vihollisolion
///
Tämä luo maavihun kentälle
/// </summary>
/// <param name="paikka"></param>
/// <param name="leveys"></param>
/// <param name="korkeus"></param>
/// <param name="paikka">
mihin kohtaan kentälle sen luo
</param>
/// <param name="leveys">
vihun hitboxin leveys
</param>
/// <param name="korkeus">
vihun hitboxin korkeus
</param>
void
LuoMaavihu
(
Vector
paikka
,
double
leveys
,
double
korkeus
)
{
//PlatformCharacter maavihu = new PlatformCharacter(leveys, korkeus);
...
...
@@ -335,6 +352,9 @@ namespace Hiko
}
/// <summary>
/// Tätä aliohjelmaa kutsutaan kun pelaaja voittaa pelin
/// </summary>
void
VoitaPeli
()
{
MessageDisplay
.
Add
(
Double
.
Parse
(
aikanaytto
.
Text
).
ToString
());
...
...
@@ -354,6 +374,10 @@ namespace Hiko
}
/// <summary>
/// Tämä aliohjelma tallentaa pisteet pisteet.xml tiedostoon
/// </summary>
/// <param name="sender">mitkä pisteet tallennetaan</param>
private
void
TallennaPisteet
(
Window
sender
)
{
DataStorage
.
Save
<
ScoreList
>(
topLista
,
"pisteet.xml"
);
...
...
@@ -394,6 +418,7 @@ namespace Hiko
}
/// <summary>
/// Tämä aliohjelma luo pistelaskurin
/// </summary>
...
...
@@ -410,5 +435,7 @@ namespace Hiko
pistenaytto
.
BindTo
(
pistelaskuri
);
Add
(
pistenaytto
);
}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment