Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
esimerkit
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
tie
ohj1
2023s
esimerkit
Commits
c06913ba
Commit
c06913ba
authored
1 year ago
by
Vesa Lappalainen
Browse files
Options
Downloads
Patches
Plain Diff
Nappaimistoohjaus
parent
41e0ede9
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
luennot/live07/KolmionMetsastys/KolmionMetsastys.cs
+19
-2
19 additions, 2 deletions
luennot/live07/KolmionMetsastys/KolmionMetsastys.cs
with
19 additions
and
2 deletions
luennot/live07/KolmionMetsastys/KolmionMetsastys.cs
+
19
−
2
View file @
c06913ba
using
System
;
using
System.Collections.Generic
;
using
Jypeli
;
using
Jypeli.Assets
;
using
Jypeli.Controls
;
...
...
@@ -17,6 +15,8 @@ public class KolmionMetsastys : PhysicsGame
public
override
void
Begin
()
{
Level
.
Background
.
Color
=
Color
.
Black
;
Level
.
CreateBorders
();
BoundingRectangle
alaosa
=
new
BoundingRectangle
(
new
Vector
(
Level
.
Left
,
0
),
Level
.
BoundingRect
.
BottomRight
);
BoundingRectangle
ylaosa
=
new
BoundingRectangle
(
Level
.
BoundingRect
.
TopLeft
,
new
Vector
(
Level
.
Right
,
0
));
...
...
@@ -28,11 +28,28 @@ public class KolmionMetsastys : PhysicsGame
PhysicsObject
pelaaja
=
LuoSattunnainenKolmio
(
this
,
ylaosa
,
50
);
pelaaja
.
Color
=
Color
.
Red
;
Keyboard
.
Listen
(
Key
.
F1
,
ButtonState
.
Pressed
,
ShowControlHelp
,
"Näytä avustus"
);
Keyboard
.
Listen
(
Key
.
Up
,
ButtonState
.
Pressed
,
LyoKolmiota
,
"Pelaaja ylös"
,
pelaaja
,
new
Vector
(
0
,
200
));
Keyboard
.
Listen
(
Key
.
Down
,
ButtonState
.
Pressed
,
LyoKolmiota
,
"Pelaaja alas"
,
pelaaja
,
new
Vector
(
0
,
-
200
));
Keyboard
.
Listen
(
Key
.
Left
,
ButtonState
.
Pressed
,
LyoKolmiota
,
"Pelaaja vasemmalle"
,
pelaaja
,
new
Vector
(-
200
,
0
));
Keyboard
.
Listen
(
Key
.
Right
,
ButtonState
.
Pressed
,
LyoKolmiota
,
"Pelaaja oikealle"
,
pelaaja
,
new
Vector
(
200
,
0
));
PhoneBackButton
.
Listen
(
ConfirmExit
,
"Lopeta peli"
);
Keyboard
.
Listen
(
Key
.
Escape
,
ButtonState
.
Pressed
,
ConfirmExit
,
"Lopeta peli"
);
}
/// <summary>
/// Lyödään kolmiota voimavektorilla
/// </summary>
/// <param name="kolmio">lyötävä kolmio</param>
/// <param name="suunta">voimavektori</param>
public
static
void
LyoKolmiota
(
PhysicsObject
kolmio
,
Vector
suunta
)
{
kolmio
.
Hit
(
suunta
);
}
/// <summary>
/// Luodaan satunnainen kolmio suorakaiteen sisälle. Myös väri ja kulma arvotaan.
/// </summary>
...
...
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