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
2021s
esimerkit
Commits
2341280b
Commit
2341280b
authored
3 years ago
by
Vesa Lappalainen
Browse files
Options
Downloads
Patches
Plain Diff
muutkin elementit
parent
3a417f11
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
luennot/live13/AngryLego/AngryLego.cs
+50
-2
50 additions, 2 deletions
luennot/live13/AngryLego/AngryLego.cs
with
50 additions
and
2 deletions
luennot/live13/AngryLego/AngryLego.cs
+
50
−
2
View file @
2341280b
...
...
@@ -50,8 +50,13 @@ public class AngryLego : PhysicsGame
Level
.
Background
.
CreateGradient
(
Color
.
Blue
,
Color
.
White
);
TileMap
tiles
=
TileMap
.
FromStringArray
(
lines
);
tiles
.
SetTileMethod
(
'X'
,
LuoSeina
,
Color
.
Wheat
)
;
Color
oletus
=
Color
.
Yellow
;
tiles
.
SetTileMethod
(
'X'
,
LuoSeina
,
Color
.
Wheat
);
tiles
.
SetTileMethod
(
'Y'
,
LuoSeina
,
Color
.
Wheat
);
tiles
.
SetTileMethod
(
'='
,
LuoKatto
,
Color
.
Red
);
tiles
.
SetTileMethod
(
'/'
,
LuoMaila
,
Color
.
Black
);
tiles
.
SetTileMethod
(
'*'
,
LuoVihollinen
,
Color
.
Pink
);
tiles
.
Execute
(
tileWidth
,
tileHeight
);
...
...
@@ -67,10 +72,53 @@ public class AngryLego : PhysicsGame
{
PhysicsObject
seina
=
new
PhysicsObject
(
leveys
,
korkeus
);
seina
.
Position
=
paikka
;
seina
.
Color
=
Color
.
Wheat
;
seina
.
Color
=
vari
;
seina
.
Tag
=
"rakenne"
;
Add
(
seina
);
}
/// <summary>
/// Luodaan kattoelementti. Luodaan hieman ylisuureksi, jolloin liimautuu
/// naapuriin kiinni.
/// </summary>
private
void
LuoKatto
(
Vector
paikka
,
double
leveys
,
double
korkeus
,
Color
vari
)
{
PhysicsObject
katto
=
new
PhysicsObject
(
leveys
,
korkeus
);
katto
.
Position
=
paikka
;
katto
.
Color
=
vari
;
katto
.
Tag
=
"rakenne"
;
Add
(
katto
);
}
/// <summary>
/// Luodaan maila, jolla palloja lyödään
/// </summary>
private
void
LuoMaila
(
Vector
paikka
,
double
leveys
,
double
korkeus
,
Color
vari
)
{
PhysicsObject
maila
=
PhysicsObject
.
CreateStaticObject
(
leveys
*
6
,
korkeus
);
maila
.
Position
=
paikka
;
maila
.
Color
=
vari
;
// maila.Image = LoadImage("maila3");
Add
(
maila
);
}
/// <summary>
/// Luodaan vihollinen, joka hajoaa osuessaan rekenteeseen
/// </summary>
private
void
LuoVihollinen
(
Vector
paikka
,
double
leveys
,
double
korkeus
,
Color
vari
)
{
PhysicsObject
vihu
=
new
PhysicsObject
(
leveys
/
2
,
leveys
/
2
,
Shape
.
Circle
);
vihu
.
Position
=
paikka
;
vihu
.
Color
=
vari
;
// vihu.Collided += new NewCollisionHandler(VihuunOsui);
//AddCollisionHandler(vihu, "rakenne", VihuunOsui);
vihu
.
Tag
=
"vihu"
;
// vihu.Image = LoadImage("Baby");
Add
(
vihu
);
}
}
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