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
f710101f
Commit
f710101f
authored
1 year ago
by
Vesa Lappalainen
Browse files
Options
Downloads
Patches
Plain Diff
pong muutetaan käyttämään C# ominaisuuksia, ei välttämättä hyötyä
parent
f2cd4990
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
+25
-19
25 additions, 19 deletions
luennot/luento09/Pong/Pong.cs
with
25 additions
and
19 deletions
luennot/luento09/Pong/Pong.cs
+
25
−
19
View file @
f710101f
...
@@ -5,8 +5,8 @@ namespace Pong;
...
@@ -5,8 +5,8 @@ namespace Pong;
public
class
Pong
:
PhysicsGame
public
class
Pong
:
PhysicsGame
{
{
private
readonly
Vector
nopeusYlos
=
new
Vector
(
0
,
200
);
private
readonly
Vector
nopeusYlos
=
new
(
0
,
200
);
private
readonly
Vector
nopeusAlas
=
new
Vector
(
0
,
-
200
);
private
readonly
Vector
nopeusAlas
=
new
(
0
,
-
200
);
public
override
void
Begin
()
public
override
void
Begin
()
...
@@ -21,13 +21,15 @@ public class Pong : PhysicsGame
...
@@ -21,13 +21,15 @@ public class Pong : PhysicsGame
{
{
Level
.
BackgroundColor
=
Color
.
Black
;
Level
.
BackgroundColor
=
Color
.
Black
;
PhysicsObject
pallo
=
new
PhysicsObject
(
40.0
,
40.0
);
PhysicsObject
pallo
=
new
(
40.0
,
40.0
)
pallo
.
Shape
=
Shape
.
Circle
;
{
pallo
.
X
=
-
200.0
;
Shape
=
Shape
.
Circle
,
pallo
.
Y
=
0.0
;
X
=
-
200.0
,
pallo
.
Restitution
=
1.0
;
Y
=
0.0
,
pallo
.
KineticFriction
=
0.0
;
Restitution
=
1.0
,
pallo
.
MomentOfInertia
=
Double
.
PositiveInfinity
;
KineticFriction
=
0.0
,
MomentOfInertia
=
Double
.
PositiveInfinity
};
Add
(
pallo
);
Add
(
pallo
);
PhysicsObject
vasenReuna
=
Level
.
CreateLeftBorder
();
PhysicsObject
vasenReuna
=
Level
.
CreateLeftBorder
();
...
@@ -77,16 +79,20 @@ public class Pong : PhysicsGame
...
@@ -77,16 +79,20 @@ public class Pong : PhysicsGame
public
static
IntMeter
LuoPisteLaskuri
(
PhysicsGame
peli
,
double
x
,
double
y
)
public
static
IntMeter
LuoPisteLaskuri
(
PhysicsGame
peli
,
double
x
,
double
y
)
{
{
IntMeter
laskuri
=
new
IntMeter
(
0
);
IntMeter
laskuri
=
new
(
0
)
laskuri
.
MaxValue
=
10
;
{
MaxValue
=
10
Label
naytto
=
new
Label
();
};
Label
naytto
=
new
()
{
X
=
x
,
Y
=
y
,
TextColor
=
Color
.
White
,
BorderColor
=
peli
.
Level
.
BackgroundColor
,
Color
=
peli
.
Level
.
BackgroundColor
,
};
naytto
.
BindTo
(
laskuri
);
naytto
.
BindTo
(
laskuri
);
naytto
.
X
=
x
;
naytto
.
Y
=
y
;
naytto
.
TextColor
=
Color
.
White
;
naytto
.
BorderColor
=
peli
.
Level
.
BackgroundColor
;
naytto
.
Color
=
peli
.
Level
.
BackgroundColor
;
peli
.
Add
(
naytto
);
peli
.
Add
(
naytto
);
return
laskuri
;
return
laskuri
;
...
@@ -95,7 +101,7 @@ public class Pong : PhysicsGame
...
@@ -95,7 +101,7 @@ public class Pong : PhysicsGame
private
void
AloitaPeli
(
PhysicsObject
pallo
)
private
void
AloitaPeli
(
PhysicsObject
pallo
)
{
{
Vector
impulssi
=
new
Vector
(
500.0
,
0.0
);
Vector
impulssi
=
new
(
500.0
,
0.0
);
pallo
.
Hit
(
impulssi
*
pallo
.
Mass
);
pallo
.
Hit
(
impulssi
*
pallo
.
Mass
);
}
}
...
...
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