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
84b8ae91
Commit
84b8ae91
authored
1 year ago
by
Vesa Lappalainen
Browse files
Options
Downloads
Patches
Plain Diff
loputkin attribuutit pois
parent
92b4047a
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
luennot/live09/Pisin3/Pisin3.cs
+16
-1
16 additions, 1 deletion
luennot/live09/Pisin3/Pisin3.cs
luennot/live09/Pong/Pong.cs
+11
-14
11 additions, 14 deletions
luennot/live09/Pong/Pong.cs
with
27 additions
and
15 deletions
luennot/live09/Pisin3/Pisin3.cs
+
16
−
1
View file @
84b8ae91
using
System
;
using
System.Text
;
public
class
Pisin3
{
public
static
void
Main
()
{
string
pisin
=
PisinJono
(
"Kissa"
,
"Kana"
,
"Krokotiili"
);
System
.
Console
.
WriteLine
(
pisin
);
Console
.
WriteLine
(
pisin
);
int
a
=
5
;
Console
.
WriteLine
(
$"Kissa pituus on
{
a
}
"
);
char
k
=
'A'
;
char
pieni
=
Char
.
ToLower
(
k
);
// 0123456
StringBuilder
sb
=
new
StringBuilder
(
"Krokotiili"
);
string
s
=
sb
.
ToString
();
int
i
=
s
.
IndexOf
(
't'
);
sb
.
Remove
(
0
,
i
);
Console
.
WriteLine
(
sb
);
sb
.
Append
(
"talo"
);
Console
.
WriteLine
(
sb
);
}
// BYCODEBEGIN
...
...
This diff is collapsed.
Click to expand it.
luennot/live09/Pong/Pong.cs
+
11
−
14
View file @
84b8ae91
...
...
@@ -8,21 +8,19 @@ public class Pong : PhysicsGame
private
readonly
Vector
nopeusYlos
=
new
Vector
(
0
,
200
);
private
readonly
Vector
nopeusAlas
=
new
Vector
(
0
,
-
200
);
private
PhysicsObject
pallo
;
// attribuutti
private
PhysicsObject
maila1
;
private
PhysicsObject
maila2
;
public
override
void
Begin
()
{
LuoKentta
();
PhysicsObject
pallo
=
LuoKentta
();
AsetaOhjaimet
();
AloitaPeli
();
AloitaPeli
(
pallo
);
}
private
void
LuoKentta
()
private
PhysicsObject
LuoKentta
()
{
pallo
=
new
PhysicsObject
(
40.0
,
40.0
);
Level
.
BackgroundColor
=
Color
.
Black
;
PhysicsObject
pallo
=
new
PhysicsObject
(
40.0
,
40.0
);
pallo
.
Shape
=
Shape
.
Circle
;
pallo
.
X
=
-
200.0
;
pallo
.
Y
=
0.0
;
...
...
@@ -31,9 +29,6 @@ public class Pong : PhysicsGame
pallo
.
MomentOfInertia
=
Double
.
PositiveInfinity
;
Add
(
pallo
);
maila1
=
LuoMaila
(
Level
.
Left
+
20.0
,
0.0
);
maila2
=
LuoMaila
(
Level
.
Right
-
20.0
,
0.0
);
PhysicsObject
vasenReuna
=
Level
.
CreateLeftBorder
();
vasenReuna
.
Restitution
=
1.0
;
vasenReuna
.
KineticFriction
=
0.0
;
...
...
@@ -60,9 +55,8 @@ public class Pong : PhysicsGame
alaReuna
.
IsVisible
=
false
;
alaReuna
.
KineticFriction
=
0.0
;
Level
.
BackgroundColor
=
Color
.
Black
;
Camera
.
ZoomToLevel
();
return
pallo
;
}
...
...
@@ -97,7 +91,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
);
...
...
@@ -106,6 +100,9 @@ public class Pong : PhysicsGame
private
void
AsetaOhjaimet
()
{
PhysicsObject
maila1
=
LuoMaila
(
Level
.
Left
+
20.0
,
0.0
);
PhysicsObject
maila2
=
LuoMaila
(
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