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
17c10d79
Commit
17c10d79
authored
1 week ago
by
Salonen Leo Sakari
Browse files
Options
Downloads
Patches
Plain Diff
Lisättiin linkit funktion, silmukan ja taulukon osaamisen osoittavaan tehtävään
parent
155daca4
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
peli/harkkatyö/pomppu possu/pomppu possu.cs
+23
-24
23 additions, 24 deletions
peli/harkkatyö/pomppu possu/pomppu possu.cs
with
23 additions
and
24 deletions
peli/harkkatyö/pomppu possu/pomppu possu.cs
+
23
−
24
View file @
17c10d79
using
System
;
using
System.Collections.Generic
;
using
Jypeli
;
using
Jypeli
;
using
Jypeli.Assets
;
using
Jypeli.Controls
;
using
Jypeli.Widgets
;
namespace
pomppu_possu
;
namespace
pomppu_possu
;
// TODO: Taulukko, silmukka ja funktio, Leo, ks: https://tim.jyu.fi/answers/kurssit/tie/ohj1/v/2025/kevat/demot/demo6?answerNumber=1&task=TeeTaulukko&user=leosaksa
// TODO: Taulukko, silmukka ja funktio, Suvi, ks: https://tim.jyu.fi/answers/kurssit/tie/ohj1/v/2025/kevat/demot/demo6?answerNumber=2&task=TeeTaulukko&user=suvleean
/// @author suvitoivanen, leosaksa
/// @author suvitoivanen, leosaksa
/// @version 02.04.2025
/// @version 02.04.2025
/// <summary>
/// <summary>
/// Eeppinen tasohyppely peli, jossa pelaajan tehtävä on kerätä kaikki
/// Eeppinen tasohyppely peli, jossa pelaajan tehtävä on kerätä kaikki
/// kartalta löytyvät megaporkkanat
(13kpl)
/// kartalta löytyvät megaporkkanat
/// </summary>
/// </summary>
public
class
PomppuPossu
:
PhysicsGame
public
class
PomppuPossu
:
PhysicsGame
{
{
private
const
double
N
OPEUS
=
200
;
private
const
double
N
opeus
=
200
;
private
const
double
H
YPPYNOPEUS
=
750
;
private
const
double
H
yppynopeus
=
750
;
private
const
int
R
UUDUN_KOKO
=
60
;
private
const
int
R
uudunKoko
=
60
;
private
PlatformCharacter
pomppuPossu
;
private
PlatformCharacter
_
pomppuPossu
;
private
Image
_pomppuPossunKuva
=
LoadImage
(
"pomppupossu.png"
);
private
Image
_pomppuPossunKuva
=
LoadImage
(
"pomppupossu.png"
);
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
;
private
IntMeter
_
pelaajanPisteet
;
/// <summary>
/// <summary>
...
@@ -37,16 +36,16 @@ public class PomppuPossu : PhysicsGame
...
@@ -37,16 +36,16 @@ public class PomppuPossu : PhysicsGame
LuoKentta
();
LuoKentta
();
LisaaLaskuri
();
LisaaLaskuri
();
Camera
.
Follow
(
pomppuPossu
);
Camera
.
Follow
(
_
pomppuPossu
);
Camera
.
ZoomFactor
=
1.2
;
Camera
.
ZoomFactor
=
1.2
;
Camera
.
StayInLevel
=
true
;
Camera
.
StayInLevel
=
true
;
MasterVolume
=
0.5
;
MasterVolume
=
0.5
;
Level
.
CreateBorders
();
Level
.
CreateBorders
();
Keyboard
.
Listen
(
Key
.
Up
,
ButtonState
.
Pressed
,
Hyppaa
,
"Pelaaja hyppää"
,
pomppuPossu
,
H
YPPYNOPEUS
);
Keyboard
.
Listen
(
Key
.
Up
,
ButtonState
.
Pressed
,
Hyppaa
,
"Pelaaja hyppää"
,
_
pomppuPossu
,
H
yppynopeus
);
Keyboard
.
Listen
(
Key
.
Left
,
ButtonState
.
Down
,
Liikuta
,
"Liikuttaa pelaajaa vasemmalle"
,
pomppuPossu
,
-
N
OPEUS
);
Keyboard
.
Listen
(
Key
.
Left
,
ButtonState
.
Down
,
Liikuta
,
"Liikuttaa pelaajaa vasemmalle"
,
_
pomppuPossu
,
-
N
opeus
);
Keyboard
.
Listen
(
Key
.
Right
,
ButtonState
.
Down
,
Liikuta
,
"Liikuttaa pelaajaa oikealle"
,
pomppuPossu
,
N
OPEUS
);
Keyboard
.
Listen
(
Key
.
Right
,
ButtonState
.
Down
,
Liikuta
,
"Liikuttaa pelaajaa oikealle"
,
_
pomppuPossu
,
N
opeus
);
Keyboard
.
Listen
(
Key
.
Escape
,
ButtonState
.
Pressed
,
ConfirmExit
,
"Lopeta peli"
);
Keyboard
.
Listen
(
Key
.
Escape
,
ButtonState
.
Pressed
,
ConfirmExit
,
"Lopeta peli"
);
}
}
...
@@ -62,7 +61,7 @@ public class PomppuPossu : PhysicsGame
...
@@ -62,7 +61,7 @@ public class PomppuPossu : PhysicsGame
kentta
.
SetTileMethod
(
'#'
,
LisaaTaso
);
kentta
.
SetTileMethod
(
'#'
,
LisaaTaso
);
kentta
.
SetTileMethod
(
'N'
,
LisaaPelaaja
);
kentta
.
SetTileMethod
(
'N'
,
LisaaPelaaja
);
kentta
.
SetTileMethod
(
'*'
,
LisaaPorkkana
);
kentta
.
SetTileMethod
(
'*'
,
LisaaPorkkana
);
kentta
.
Execute
(
R
UUDUN_KOKO
,
RUUDUN_KOKO
);
kentta
.
Execute
(
R
uudunKoko
,
RuudunKoko
);
Level
.
Background
.
CreateGradient
(
Color
.
White
,
Color
.
SkyBlue
);
Level
.
Background
.
CreateGradient
(
Color
.
White
,
Color
.
SkyBlue
);
}
}
...
@@ -107,12 +106,12 @@ public class PomppuPossu : PhysicsGame
...
@@ -107,12 +106,12 @@ 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
(
80
,
100
);
_
pomppuPossu
=
new
PlatformCharacter
(
80
,
100
);
pomppuPossu
.
Position
=
paikka
;
_
pomppuPossu
.
Position
=
paikka
;
pomppuPossu
.
Mass
=
4.0
;
_
pomppuPossu
.
Mass
=
4.0
;
pomppuPossu
.
Image
=
_pomppuPossunKuva
;
_
pomppuPossu
.
Image
=
_pomppuPossunKuva
;
AddCollisionHandler
<
PhysicsObject
,
Megaporkkanat
>(
pomppuPossu
,
TormattiinEsineeseen
);
AddCollisionHandler
<
PhysicsObject
,
Megaporkkanat
>(
_
pomppuPossu
,
TormattiinEsineeseen
);
Add
(
pomppuPossu
);
Add
(
_
pomppuPossu
);
}
}
...
@@ -151,7 +150,7 @@ public class PomppuPossu : PhysicsGame
...
@@ -151,7 +150,7 @@ public class PomppuPossu : PhysicsGame
kohde
.
OtaVastaanOsuma
();
kohde
.
OtaVastaanOsuma
();
_pisteAani
.
Play
();
_pisteAani
.
Play
();
MessageDisplay
.
Add
(
"Megaporkkana kerätty!"
);
MessageDisplay
.
Add
(
"Megaporkkana kerätty!"
);
pelaajanPisteet
.
Value
+=
1
;
_
pelaajanPisteet
.
Value
+=
1
;
}
}
...
@@ -196,7 +195,7 @@ public class PomppuPossu : PhysicsGame
...
@@ -196,7 +195,7 @@ public class PomppuPossu : PhysicsGame
/// </summary>
/// </summary>
void
LisaaLaskuri
()
void
LisaaLaskuri
()
{
{
pelaajanPisteet
=
LuoPisteLaskuri
(
Screen
.
Right
-
100.0
,
Screen
.
Top
-
100.0
);
_
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