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
fd058f4b
Commit
fd058f4b
authored
1 year ago
by
Vesa Lappalainen
Browse files
Options
Downloads
Patches
Plain Diff
AngryLego PudotaPallo ja rajahdys
parent
d1b69153
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/live14/AngryLego/AngryLego.cs
+37
-0
37 additions, 0 deletions
luennot/live14/AngryLego/AngryLego.cs
with
37 additions
and
0 deletions
luennot/live14/AngryLego/AngryLego.cs
+
37
−
0
View file @
fd058f4b
using
Jypeli
;
using
Jypeli.Assets
;
namespace
AngryLego
;
...
...
@@ -64,12 +65,48 @@ public class AngryLego : PhysicsGame
Keyboard
.
Listen
(
Key
.
F1
,
ButtonState
.
Pressed
,
ShowControlHelp
,
"Show help"
);
Keyboard
.
Listen
(
Key
.
Up
,
ButtonState
.
Pressed
,
KaannaMailaa
,
"Move up"
,
5.0
);
Keyboard
.
Listen
(
Key
.
Down
,
ButtonState
.
Pressed
,
KaannaMailaa
,
"Move down"
,
-
5.0
);
Keyboard
.
Listen
(
Key
.
Space
,
ButtonState
.
Pressed
,
PudotaPallo
,
"Drop ball"
);
PhoneBackButton
.
Listen
(
ConfirmExit
,
"Lopeta peli"
);
Keyboard
.
Listen
(
Key
.
Escape
,
ButtonState
.
Pressed
,
ConfirmExit
,
"Lopeta peli"
);
}
private
void
PudotaPallo
()
{
PhysicsObject
pallo
=
new
PhysicsObject
(
tileWidth
,
tileWidth
,
Shape
.
Circle
);
pallo
.
Position
=
maila
.
Position
+
new
Vector
(
tileWidth
,
maila
.
Height
+
tileWidth
);
pallo
.
Image
=
LoadImage
(
"Igor"
);
Add
(
pallo
);
AddCollisionHandler
(
pallo
,
"vihu"
,
PalloOsui
);
}
/// <summary>
/// Apualiohjlema vihollisen räjäyttämiseksi ja poistamiseksi
/// </summary>
/// <param name="vihu"></param>
private
void
PossautaVihu
(
IPhysicsObject
vihu
)
{
Explosion
rajahdys
=
new
Explosion
(
vihu
.
Width
*
10
);
rajahdys
.
Position
=
vihu
.
Position
;
rajahdys
.
UseShockWave
=
false
;
Add
(
rajahdys
);
Remove
(
vihu
);
}
/// <summary>
/// Tapahtuma kun pallo osuu viholliseen
/// </summary>
/// <param name="pallo">pallo joka osui</param>
/// <param name="vihu">vihollinen johon osuttiin</param>
private
void
PalloOsui
(
PhysicsObject
pallo
,
PhysicsObject
vihu
)
{
PossautaVihu
(
vihu
);
}
/// <summary>
/// Luodaan seinäelementti
/// </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