Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
ohj1ht matopeli
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
kopperp
ohj1ht matopeli
Commits
55a52737
Commit
55a52737
authored
1 year ago
by
Kopperoinen Paulus
Browse files
Options
Downloads
Patches
Plain Diff
Uusia aliohjelmia ja omenoille kenttään lisäämismekanismi
parent
0a0e43c7
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
Matopeli/Matopeli/Matopeli.cs
+66
-9
66 additions, 9 deletions
Matopeli/Matopeli/Matopeli.cs
with
66 additions
and
9 deletions
Matopeli/Matopeli/Matopeli.cs
+
66
−
9
View file @
55a52737
...
...
@@ -53,16 +53,22 @@ public class Matopeli : PhysicsGame
ClearAll
();
// Background.Image = LoadImage("kenttatausta");
//LuoTausta();
AloitaUusiPeli
();
}
public
void
AloitaUusiPeli
()
{
pisteet
.
Value
=
0
;
TileMap
seinat
=
TileMap
.
FromStringArray
(
kentta
);
seinat
.
SetTileMethod
(
'-'
,
LuoSeina
);
seinat
.
SetTileMethod
(
'm'
,
LuoMatopaa
);
seinat
.
SetTileMethod
(
'o'
,
LuoOmena
);
seinat
.
SetTileMethod
(
'k'
,
LuoMatokeho
);
//
seinat.SetTileMethod('k',LuoMatokeho);
seinat
.
Execute
(
seinaleveys
,
seinakorkeus
);
ArvotaanOmena
(
kentta
);
Matoliikkeelle
();
}
private
void
LuoSeina
(
Vector
paikka
,
double
leveys
,
double
korkeus
)
{
PhysicsObject
seina
=
new
PhysicsObject
(
leveys
,
korkeus
);
...
...
@@ -76,6 +82,7 @@ public class Matopeli : PhysicsGame
PhysicsObject
omena
=
new
PhysicsObject
(
leveys
,
korkeus
);
omena
.
Position
=
paikka
;
omena
.
Image
=
omenakuva
;
omena
.
Tag
=
"omena"
;
Add
(
omena
);
}
...
...
@@ -84,15 +91,65 @@ public class Matopeli : PhysicsGame
PhysicsObject
matopaa
=
new
PhysicsObject
(
leveys
,
korkeus
);
matopaa
.
Position
=
paikka
;
matopaa
.
Image
=
Matopeli
.
matopaakuva
;
matopaa
.
Tag
=
matopaa
;
AddCollisionHandler
(
matopaa
,
"omena"
,
delegate
(
IPhysicsObject
matopaa
,
IPhysicsObject
omena
)
{
MatosyoOmenan
(
omena
);
pisteet
.
Value
+=
1
;
});
Timer
lahtoaika
=
new
Timer
();
lahtoaika
.
Interval
=
1.5
;
Add
(
matopaa
);
lahtoaika
.
Timeout
+=
KaannyOikea
(
matopaa
);
}
//private void LuoMatokeho(Vector paikka, double leveys, double korkeus)
//{
// PhysicsObject matokeho = new PhysicsObject(leveys, korkeus);
//matokeho.Position = paikka;
//matokeho.Image = matokehokuva;
//Add(matokeho);
//})
private
void
AsetaOhjaimet
()
{
Keyboard
.
Listen
(
Key
.
Up
,
ButtonState
.
Down
,
KaannyYlos
,
"Turn upwards"
;
Keyboard
.
Listen
(
Key
.
Down
,
ButtonState
.
Down
,
KaannyAlas
,
"Turn downwards"
;
Keyboard
.
Listen
(
Key
.
Left
,
ButtonState
.
Down
,
KaannaVasen
,
"Turn left"
;
Keyboard
.
Listen
(
Key
.
Right
,
ButtonState
.
Down
,
KaannaOikea
,
"Turn right"
;
}
private
void
ArvotaanOmena
(
string
[]
t
)
{
int
x
=
t
.
GetLength
(
0
);
int
y
=
t
.
GetLength
(
1
);
int
ix
=
RandomGen
.
NextInt
(
1
,
x
-
1
);
int
iy
=
RandomGen
.
NextInt
(
1
,
y
-
1
);
Vector
paikka
=
(
ix
,
iy
);
LuoOmena
(
paikka
,
seinaleveys
,
seinakorkeus
);
}
private
void
LuoMatokeho
(
Vector
paikka
,
double
leveys
,
double
korkeus
)
private
void
MatosyoOmenan
(
IPhysicsObject
omena
)
{
PhysicsObject
matokeho
=
new
PhysicsObject
(
leveys
,
korkeus
);
matokeho
.
Position
=
paikka
;
matokeho
.
Image
=
matokehokuva
;
Add
(
matokeho
);
pisteet
+;
omena
.
Destroy
();
}
private
void
KaannyVasen
(
IPhysicsObject
matopaa
)
{
}
private
void
KaannyOikea
(
IPhysicsObject
matopaa
)
{
matopaa
.
Push
(
new
Vector
(
1000
,
0
));
pelaaja1
.
MaxVelocity
=
200
;
}
private
void
KaannyAlas
(
IPhysicsObject
matopaa
)
{
}
private
void
KaannyYlos
(
IPhysicsObject
matopaa
)
{
}
}
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