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
suvleean
ohj1ht
Commits
16db8ba2
Commit
16db8ba2
authored
2 weeks ago
by
Salonen Leo Sakari
Browse files
Options
Downloads
Patches
Plain Diff
Lisäsin pistelaskurin, muutamia dokumentointeja ja yleistä siivoilua
parent
bd766a03
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
peli/harkkatyö/pomppu possu/Megaporkkanat.cs
+16
-4
16 additions, 4 deletions
peli/harkkatyö/pomppu possu/Megaporkkanat.cs
peli/harkkatyö/pomppu possu/pomppu possu.cs
+40
-2
40 additions, 2 deletions
peli/harkkatyö/pomppu possu/pomppu possu.cs
with
56 additions
and
6 deletions
peli/harkkatyö/pomppu possu/Megaporkkanat.cs
+
16
−
4
View file @
16db8ba2
...
@@ -9,19 +9,30 @@ public class Megaporkkanat : PhysicsObject
...
@@ -9,19 +9,30 @@ public class Megaporkkanat : PhysicsObject
{
{
_osumat
=
0
;
_osumat
=
0
;
}
}
/// <summary>
/// Aliohjelma, joka käsittelee osumat megaporkkanoihin.
/// Havaitessaan osuman, aliohjema kutsuu toista aliohjelmaa,
/// joka tuhoaa porkkanan.
/// </summary>
public
void
OtaVastaanOsuma
()
public
void
OtaVastaanOsuma
()
{
{
_osumat
++;
_osumat
++;
if
(
_osumat
==
1
)
if
(
_osumat
==
1
)
{
{
TuhoaPalikka
();
TuhoaPorkkana
();
}
}
}
}
/// <summary>
public
void
TuhoaPalikka
()
/// Aliohjelma, joka tuhoaa megaporkkanan.
/// </summary>
public
void
TuhoaPorkkana
()
{
{
this
.
Destroy
();
this
.
Destroy
();
}
}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
peli/harkkatyö/pomppu possu/pomppu possu.cs
+
40
−
2
View file @
16db8ba2
...
@@ -23,6 +23,8 @@ public class PomppuPossu : PhysicsGame
...
@@ -23,6 +23,8 @@ public class PomppuPossu : PhysicsGame
private
Image
_porkkanaKuva
=
LoadImage
(
"porkkananKuva3.png"
);
private
Image
_porkkanaKuva
=
LoadImage
(
"porkkananKuva3.png"
);
private
SoundEffect
_pisteAani
=
LoadSoundEffect
(
"maali.wav"
);
private
SoundEffect
_pisteAani
=
LoadSoundEffect
(
"maali.wav"
);
private
IntMeter
pelaajanPisteet
;
/// <summary>
/// <summary>
/// Pääohjelma luo kentän ja näppäinkomennot.
/// Pääohjelma luo kentän ja näppäinkomennot.
/// </summary>
/// </summary>
...
@@ -31,6 +33,7 @@ public class PomppuPossu : PhysicsGame
...
@@ -31,6 +33,7 @@ public class PomppuPossu : PhysicsGame
Gravity
=
new
Vector
(
0
,
-
1000
);
Gravity
=
new
Vector
(
0
,
-
1000
);
LuoKentta
();
LuoKentta
();
LisaaLaskuri
();
Camera
.
Follow
(
pomppuPossu
);
Camera
.
Follow
(
pomppuPossu
);
Camera
.
ZoomFactor
=
1.2
;
Camera
.
ZoomFactor
=
1.2
;
...
@@ -92,7 +95,7 @@ public class PomppuPossu : PhysicsGame
...
@@ -92,7 +95,7 @@ public class PomppuPossu : PhysicsGame
/// <param name="korkeus">korkeus</param>
/// <param name="korkeus">korkeus</param>
private
void
LisaaPelaaja
(
Vector
paikka
,
double
leveys
,
double
korkeus
)
private
void
LisaaPelaaja
(
Vector
paikka
,
double
leveys
,
double
korkeus
)
{
{
pomppuPossu
=
new
PlatformCharacter
(
10
0
,
100
);
pomppuPossu
=
new
PlatformCharacter
(
8
0
,
100
);
pomppuPossu
.
Position
=
paikka
;
pomppuPossu
.
Position
=
paikka
;
pomppuPossu
.
Mass
=
4.0
;
pomppuPossu
.
Mass
=
4.0
;
pomppuPossu
.
Image
=
_pomppuPossunKuva
;
pomppuPossu
.
Image
=
_pomppuPossunKuva
;
...
@@ -119,6 +122,9 @@ public class PomppuPossu : PhysicsGame
...
@@ -119,6 +122,9 @@ public class PomppuPossu : PhysicsGame
}
}
/// <summary>
/// <summary>
/// Funktio käsittelee törmäykset.
/// Funktio käsittelee törmäykset.
/// Törmäyksen yhteydessä tuhotaan porkkana,
/// soitetaan äänimerkki, näytetään viesti onnistuneesta
/// keräyksestä, sekä lisätään yksi piste pistelaskuriin
/// </summary>
/// </summary>
/// <param name="tormaaja">pelaaja</param>
/// <param name="tormaaja">pelaaja</param>
/// <param name="kohde">kerättävät pisteet</param>
/// <param name="kohde">kerättävät pisteet</param>
...
@@ -126,7 +132,9 @@ public class PomppuPossu : PhysicsGame
...
@@ -126,7 +132,9 @@ public class PomppuPossu : PhysicsGame
{
{
kohde
.
OtaVastaanOsuma
();
kohde
.
OtaVastaanOsuma
();
_pisteAani
.
Play
();
_pisteAani
.
Play
();
MessageDisplay
.
Add
(
"Megaporkkana kerätty!"
);
//Lisäsin viestin
MessageDisplay
.
Add
(
"Megaporkkana kerätty!"
);
pelaajanPisteet
.
Value
+=
1
;
}
}
/// <summary>
/// <summary>
...
@@ -138,7 +146,37 @@ public class PomppuPossu : PhysicsGame
...
@@ -138,7 +146,37 @@ public class PomppuPossu : PhysicsGame
{
{
liikuteltava
.
Push
(
suunta
);
liikuteltava
.
Push
(
suunta
);
}
}
/// <summary>
/// Aliohjelma luo pistelaskurin
/// </summary>
/// <param name="x">laskurin x-koordinaatti näytöllä</param>
/// <param name="y">laskurin y-koordinaatti näytöllä</param>
/// <returns>Laskuri</returns>
IntMeter
LuoPisteLaskuri
(
double
x
,
double
y
)
{
IntMeter
laskuri
=
new
IntMeter
(
0
);
laskuri
.
MaxValue
=
13
;
Label
naytto
=
new
Label
();
naytto
.
BindTo
(
laskuri
);
naytto
.
X
=
x
;
naytto
.
Y
=
y
;
naytto
.
TextColor
=
Color
.
Black
;
naytto
.
BorderColor
=
Level
.
Background
.
Color
;
naytto
.
Color
=
Level
.
Background
.
Color
;
Add
(
naytto
);
return
laskuri
;
}
/// <summary>
/// Lisää Laskurin peliin ja määrittää sen sijainnin näytöllä
/// </summary>
void
LisaaLaskuri
()
{
pelaajanPisteet
=
LuoPisteLaskuri
(
Screen
.
Right
-
100.0
,
Screen
.
Top
-
100.0
);
}
}
}
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