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
jashokuu
esimerkit
Commits
c040d372
Commit
c040d372
authored
2 years ago
by
Vesa Lappalainen
Browse files
Options
Downloads
Patches
Plain Diff
pong poistetaan loputkin attribuutit
parent
32f7219c
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/luento09/Pong/Pong.cs
+10
-12
10 additions, 12 deletions
luennot/luento09/Pong/Pong.cs
with
10 additions
and
12 deletions
luennot/luento09/Pong/Pong.cs
+
10
−
12
View file @
c040d372
...
...
@@ -8,24 +8,20 @@ public class Pong : PhysicsGame
private
readonly
Vector
nopeusYlos
=
new
Vector
(
0
,
200
);
private
readonly
Vector
nopeusAlas
=
new
Vector
(
0
,
-
200
);
private
PhysicsObject
pallo
;
private
PhysicsObject
maila1
;
private
PhysicsObject
maila2
;
public
override
void
Begin
()
{
LuoKentta
();
PhysicsObject
pallo
=
LuoKentta
();
AsetaOhjaimet
();
AloitaPeli
();
AloitaPeli
(
pallo
);
}
private
void
LuoKentta
()
private
PhysicsObject
LuoKentta
()
{
Level
.
Background
.
Color
=
Color
.
Black
;
pallo
=
new
PhysicsObject
(
40.0
,
40.0
);
PhysicsObject
pallo
=
new
PhysicsObject
(
40.0
,
40.0
);
pallo
.
Shape
=
Shape
.
Circle
;
pallo
.
X
=
-
200.0
;
pallo
.
Y
=
0.0
;
...
...
@@ -34,9 +30,6 @@ public class Pong : PhysicsGame
pallo
.
MomentOfInertia
=
Double
.
PositiveInfinity
;
Add
(
pallo
);
maila1
=
LuoMaila
(
this
,
Level
.
Left
+
20.0
,
0.0
);
maila2
=
LuoMaila
(
this
,
Level
.
Right
-
20.0
,
0.0
);
PhysicsObject
vasenReuna
=
Level
.
CreateLeftBorder
();
vasenReuna
.
Restitution
=
1.0
;
vasenReuna
.
KineticFriction
=
0.0
;
...
...
@@ -64,6 +57,8 @@ public class Pong : PhysicsGame
alaReuna
.
KineticFriction
=
0.0
;
Camera
.
ZoomToLevel
();
return
pallo
;
}
...
...
@@ -98,7 +93,7 @@ public class Pong : PhysicsGame
}
private
void
AloitaPeli
()
private
void
AloitaPeli
(
PhysicsObject
pallo
)
{
Vector
impulssi
=
new
Vector
(
500.0
,
0.0
);
pallo
.
Hit
(
impulssi
*
pallo
.
Mass
);
...
...
@@ -107,6 +102,9 @@ public class Pong : PhysicsGame
private
void
AsetaOhjaimet
()
{
PhysicsObject
maila1
=
LuoMaila
(
this
,
Level
.
Left
+
20.0
,
0.0
);
PhysicsObject
maila2
=
LuoMaila
(
this
,
Level
.
Right
-
20.0
,
0.0
);
Keyboard
.
Listen
(
Key
.
A
,
ButtonState
.
Down
,
AsetaNopeus
,
"Pelaaja 1: Liikuta mailaa ylös"
,
this
,
maila1
,
nopeusYlos
);
Keyboard
.
Listen
(
Key
.
A
,
ButtonState
.
Released
,
AsetaNopeus
,
null
,
this
,
maila1
,
Vector
.
Zero
);
Keyboard
.
Listen
(
Key
.
Z
,
ButtonState
.
Down
,
AsetaNopeus
,
"Pelaaja 1: Liikuta mailaa alas"
,
this
,
maila1
,
nopeusAlas
);
...
...
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