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
c46d871e
Commit
c46d871e
authored
1 year ago
by
Vesa Lappalainen
Browse files
Options
Downloads
Patches
Plain Diff
Luodaan pelaaja ylapuoliskoon
parent
f031f94d
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
luennot/live07/KolmionMetsastys/KolmionMetsastys.cs
+8
-2
8 additions, 2 deletions
luennot/live07/KolmionMetsastys/KolmionMetsastys.cs
with
8 additions
and
2 deletions
luennot/live07/KolmionMetsastys/KolmionMetsastys.cs
+
8
−
2
View file @
c46d871e
...
...
@@ -18,12 +18,17 @@ public class KolmionMetsastys : PhysicsGame
{
Level
.
Background
.
Color
=
Color
.
Black
;
BoundingRectangle
alaosa
=
new
BoundingRectangle
(
new
Vector
(
Level
.
Left
,
0
),
Level
.
BoundingRect
.
BottomRight
);
BoundingRectangle
ylaosa
=
new
BoundingRectangle
(
Level
.
BoundingRect
.
TopLeft
,
new
Vector
(
Level
.
Right
,
0
));
for
(
int
i
=
0
;
i
<
50
;
i
++)
{
LuoSattunnainenKolmio
(
this
,
alaosa
,
200
);
}
PhysicsObject
pelaaja
=
LuoSattunnainenKolmio
(
this
,
ylaosa
,
50
);
pelaaja
.
Color
=
Color
.
Red
;
PhoneBackButton
.
Listen
(
ConfirmExit
,
"Lopeta peli"
);
Keyboard
.
Listen
(
Key
.
Escape
,
ButtonState
.
Pressed
,
ConfirmExit
,
"Lopeta peli"
);
}
...
...
@@ -34,7 +39,7 @@ public class KolmionMetsastys : PhysicsGame
/// <param name="peli">Mihin peliin kolmio luodaan</param>
/// <param name="rect">Minkä suorakaiteen sisälle luodaan</param>
/// <param name="vauhti">Kolmion vauhti alkutilanteessa</param>
public
static
void
LuoSattunnainenKolmio
(
PhysicsGame
peli
,
BoundingRectangle
rect
,
double
vauhti
=
0
)
public
static
PhysicsObject
LuoSattunnainenKolmio
(
PhysicsGame
peli
,
BoundingRectangle
rect
,
double
vauhti
=
0
)
{
double
leveys
=
RandomGen
.
NextDouble
(
10
,
100
);
double
korkeus
=
RandomGen
.
NextDouble
(
10
,
100
);
...
...
@@ -45,6 +50,7 @@ public class KolmionMetsastys : PhysicsGame
Vector
suunta
=
RandomGen
.
NextVector
(
0
,
vauhti
);
kolmio
.
Hit
(
suunta
);
peli
.
Add
(
kolmio
);
return
kolmio
;
}
}
\ 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