Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
ohj1ht
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
Model registry
Operate
Environments
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
sailyts
ohj1ht
Commits
da5e1348
Commit
da5e1348
authored
4 years ago
by
sailyts
Browse files
Options
Downloads
Patches
Plain Diff
Viimeinen päivitys, peli tarkastettu 100%
parent
da6856bc
Branches
master
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Harjoitustyö/Harjoitustyö/Fysiikkapeli.cs
+16
-12
16 additions, 12 deletions
Harjoitustyö/Harjoitustyö/Fysiikkapeli.cs
with
16 additions
and
12 deletions
Harjoitustyö/Harjoitustyö/Fysiikkapeli.cs
+
16
−
12
View file @
da5e1348
...
...
@@ -31,11 +31,15 @@ public class Vihollinen : PhysicsObject
}
}
///@author Teemu Säily
///@version 23.4.2020
/// <summary>
///
/// </summary>
public
class
Harjoitustyo
:
PhysicsGame
{
private
const
int
koko
=
80
;
private
const
int
panoksenKoko
=
20
;
private
const
int
KOKO
=
80
;
private
const
int
PANOKSEN_KOKO
=
20
;
private
IntMeter
pisteLaskuri
;
private
Vector
[]
vihuSpawnit
=
new
Vector
[
5
];
private
Vector
[]
tykkiSpawnit
=
new
Vector
[
20
];
...
...
@@ -50,7 +54,7 @@ public class Harjoitustyo : PhysicsGame
/// </summary>
public
override
void
Begin
()
{
TeeKentt
ä
();
TeeKentt
a
();
MultiSelectWindow
alkuValikko
=
new
MultiSelectWindow
(
"Pelin alkuvalikko"
,
"Aloita peli"
,
"Lopeta"
);
Add
(
alkuValikko
);
alkuValikko
.
AddItemHandler
(
0
,
AloitaPeli
);
...
...
@@ -113,7 +117,7 @@ public class Harjoitustyo : PhysicsGame
{
if
(
tykkiLuku
>
0
)
{
PhysicsObject
tykki
=
new
PhysicsObject
(
koko
,
koko
,
Shape
.
Rectangle
);
PhysicsObject
tykki
=
new
PhysicsObject
(
KOKO
,
KOKO
,
Shape
.
Rectangle
);
tykki
.
Position
=
LahinTykkiSpawn
();
tykki
.
Color
=
Color
.
ForestGreen
;
tykki
.
Image
=
LoadImage
(
"tykki"
);
...
...
@@ -144,7 +148,7 @@ public class Harjoitustyo : PhysicsGame
/// <param name="tykki">Ampuva tykki</param>
private
void
AmmuTykill
ä
(
PhysicsObject
tykki
)
{
PhysicsObject
panos
=
new
PhysicsObject
(
panoksenKoko
,
panoksenKoko
);
PhysicsObject
panos
=
new
PhysicsObject
(
PANOKSEN_KOKO
,
PANOKSEN_KOKO
);
panos
.
IgnoresGravity
=
true
;
panos
.
Shape
=
Shape
.
Circle
;
panos
.
Color
=
Color
.
BloodRed
;
...
...
@@ -206,7 +210,7 @@ public class Harjoitustyo : PhysicsGame
/// <summary>
/// Tekee peliin kentän tekstitiedostosta
/// </summary>
private
void
TeeKentt
ä
()
private
void
TeeKentt
a
()
{
TileMap
kentta
=
TileMap
.
FromLevelAsset
(
"Leveli"
);
kentta
.
SetTileMethod
(
'l'
,
LuoLattia
,
"lattia"
);
...
...
@@ -214,7 +218,7 @@ public class Harjoitustyo : PhysicsGame
kentta
.
SetTileMethod
(
'p'
,
LuoSpawni
,
"tykkien spawnipisteet"
,
'p'
);
kentta
.
SetTileMethod
(
'k'
,
LuoPisteLaskuri
,
"pistelaskuri"
);
kentta
.
SetTileMethod
(
's'
,
LuoTakaSeina
,
"takaseinä"
);
kentta
.
Execute
(
koko
,
koko
);
kentta
.
Execute
(
KOKO
,
KOKO
);
kentta
.
Optimize
(
'l'
);
Level
.
Size
=
new
Vector
(
1000
,
800
);
Level
.
Background
.
Image
=
LoadImage
(
"taustakuva"
);
...
...
@@ -234,7 +238,7 @@ public class Harjoitustyo : PhysicsGame
/// <param name="kuvanNimi">Lattian haluttu kuva</param>
private
void
LuoLattia
(
Vector
paikka
,
double
korkeus
,
double
leveys
,
string
kuvanNimi
)
{
PhysicsObject
lattia
=
new
PhysicsObject
(
koko
,
koko
);
PhysicsObject
lattia
=
new
PhysicsObject
(
KOKO
,
KOKO
);
lattia
.
Position
=
paikka
;
lattia
.
Image
=
LoadImage
(
"tiili"
);
lattia
.
MakeStatic
();
...
...
@@ -254,7 +258,7 @@ public class Harjoitustyo : PhysicsGame
/// <param name="kuvanNimi">Seinän kuva</param>
private
void
LuoTakaSeina
(
Vector
paikka
,
double
korkeus
,
double
leveys
,
string
kuvanNimi
)
{
PhysicsObject
takaSeina
=
new
PhysicsObject
(
koko
,
koko
);
PhysicsObject
takaSeina
=
new
PhysicsObject
(
KOKO
,
KOKO
);
takaSeina
.
Position
=
paikka
;
takaSeina
.
Color
=
Color
.
Blue
;
takaSeina
.
MakeStatic
();
...
...
@@ -291,7 +295,7 @@ public class Harjoitustyo : PhysicsGame
/// <param name="tunniste">Viholliselle vai tykille</param>
private
void
LuoSpawni
(
Vector
paikka
,
double
korkeus
,
double
leveys
,
string
kuvanNimi
,
char
tunniste
)
{
PhysicsObject
spawn
=
new
PhysicsObject
(
koko
,
koko
);
PhysicsObject
spawn
=
new
PhysicsObject
(
KOKO
,
KOKO
);
spawn
.
IgnoresCollisionResponse
=
true
;
spawn
.
IgnoresGravity
=
true
;
spawn
.
Position
=
paikka
;
...
...
@@ -376,7 +380,7 @@ public class Harjoitustyo : PhysicsGame
/// </summary>
private
void
LuoVihu
()
{
Vihollinen
vihu
=
new
Vihollinen
(
koko
,
koko
);
Vihollinen
vihu
=
new
Vihollinen
(
KOKO
,
KOKO
);
vihu
.
Color
=
Color
.
BloodRed
;
vihu
.
Shape
=
Shape
.
Circle
;
vihu
.
Mass
=
1000
;
...
...
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