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
salmatel
ohj1ht
Commits
4deb4123
Commit
4deb4123
authored
1 year ago
by
Salonen Matteus Elmeri
Browse files
Options
Downloads
Patches
Plain Diff
Lisätty pistelaskurit
parent
309190c0
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Harjoitustyo/HyttysPeli/HyttysPeli.cs
+51
-5
51 additions, 5 deletions
Harjoitustyo/HyttysPeli/HyttysPeli.cs
with
51 additions
and
5 deletions
Harjoitustyo/HyttysPeli/HyttysPeli.cs
+
51
−
5
View file @
4deb4123
...
...
@@ -3,6 +3,7 @@ using System.Collections.Generic;
using
Jypeli
;
using
Jypeli.Assets
;
using
Jypeli.Controls
;
using
Jypeli.Effects
;
using
Jypeli.Widgets
;
namespace
HyttysPeli
;
...
...
@@ -15,15 +16,19 @@ namespace HyttysPeli;
public
class
HyttysPeli
:
PhysicsGame
{
Image
taustaKuva
=
LoadImage
(
"taustakuva"
);
private
IntMeter
pistelaskuri
;
private
IntMeter
helttilaskuri
;
public
override
void
Begin
()
{
MasterVolume
=
0.05
;
SetWindowSize
(
1920
,
1080
,
true
);
Level
.
Background
.
Image
=
taustaKuva
;
LuoPistelaskuri
();
LuoHelttilaskuri
();
BoundingRectangle
alaosa
=
new
BoundingRectangle
(
new
Vector
(
-
100
,
1
),
Level
.
BoundingRect
.
BottomRight
);
BoundingRectangle
ylaosa
=
new
BoundingRectangle
(
new
Vector
(-
960
,
0
),
new
Vector
(
960
,
54
0
));
BoundingRectangle
alaosa
=
new
BoundingRectangle
(
new
Vector
(
Level
.
Left
,
0
),
Level
.
BoundingRect
.
BottomRight
);
BoundingRectangle
ylaosa
=
new
BoundingRectangle
(
Level
.
BoundingRect
.
TopLeft
,
new
Vector
(
Level
.
Right
,
0
));
Level
.
CreateBorders
();
PhysicsObject
pelaaja
=
new
PhysicsObject
(
25
,
100
,
Shape
.
Rectangle
);
pelaaja
.
Position
=
RandomGen
.
NextVector
(
alaosa
);
...
...
@@ -68,6 +73,7 @@ public class HyttysPeli : PhysicsGame
rajahdys
.
UseShockWave
=
false
;
this
.
Add
(
rajahdys
);
Remove
(
hyttynen
);
pistelaskuri
.
Value
+=
1
;
}
...
...
@@ -79,8 +85,13 @@ public class HyttysPeli : PhysicsGame
/// <param name="ampiainen">ampiainen johon pelaaja törmäsi</param>
private
void
PelaajaTormasiAmpiaiseen
(
PhysicsObject
pelaaja
,
PhysicsObject
ampiainen
)
{
ClearAll
();
Begin
();
Remove
(
ampiainen
);
helttilaskuri
.
Value
-=
1
;
if
(
helttilaskuri
.
Value
==
0
)
{
ClearAll
();
Begin
();
}
}
...
...
@@ -139,4 +150,39 @@ public class HyttysPeli : PhysicsGame
peli
.
Add
(
ampiainen
);
return
ampiainen
;
}
void
LuoPistelaskuri
()
{
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
.
White
;
pistenaytto
.
Title
=
"Pisteitä: "
;
pistenaytto
.
BindTo
(
pistelaskuri
);
Add
(
pistenaytto
);
}
void
LuoHelttilaskuri
()
{
helttilaskuri
=
new
IntMeter
(
3
);
Label
helttinaytto
=
new
Label
();
helttinaytto
.
X
=
Screen
.
Right
-
100
;
helttinaytto
.
Y
=
Screen
.
Top
-
100
;
helttinaytto
.
TextColor
=
Color
.
Black
;
helttinaytto
.
Color
=
Color
.
Red
;
helttinaytto
.
Title
=
"Elämät: "
;
helttinaytto
.
BindTo
(
helttilaskuri
);
Add
(
helttinaytto
);
}
}
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