Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
ohj1ht2
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
saadmikk
ohj1ht2
Commits
d65d1f0e
Commit
d65d1f0e
authored
1 year ago
by
Mikkola Saara
Browse files
Options
Downloads
Patches
Plain Diff
dokumentaatiot ja loppuviilaukset
parent
eb135556
Branches
main
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
FGR/FGR/FGR.cs
+56
-22
56 additions, 22 deletions
FGR/FGR/FGR.cs
with
56 additions
and
22 deletions
FGR/FGR/FGR.cs
+
56
−
22
View file @
d65d1f0e
...
...
@@ -11,18 +11,18 @@ namespace FGR;
/// </summary>
public
class
Fgr
:
PhysicsGame
{
Vector
_nopeusOikea
=
new
Vector
(
500
,
0
);
Vector
_nopeusVasen
=
new
Vector
(-
500
,
0
);
private
Vector
_nopeusOikea
=
new
Vector
(
500
,
0
);
private
Vector
_nopeusVasen
=
new
Vector
(-
500
,
0
);
PhysicsObject
_pallo
;
PhysicsObject
_palikat
;
private
PhysicsObject
_pallo
;
private
PhysicsObject
_palikat
;
int
_scrollausnopeus
=
-
8
;
//bool _peliPaattynyt = false;
private
int
_scrollausnopeus
=
-
8
;
List
<
GameObject
>
_taustakuvat
;
Timer
_taustaAjastin
=
new
Timer
();
GameObject
_ekaTaustakuva
;
private
List
<
GameObject
>
_taustakuvat
;
private
Timer
_taustaAjastin
=
new
Timer
();
private
GameObject
_ekaTaustakuva
;
private
Image
_hiutaleet
=
LoadImage
(
"Lumihiutaleet"
);
public
override
void
Begin
()
...
...
@@ -34,6 +34,7 @@ public class Fgr : PhysicsGame
LuoTaustakuvat
();
}
/// <summary>
/// luodaan pelikenttä
/// </summary>
...
...
@@ -52,15 +53,24 @@ public class Fgr : PhysicsGame
AddCollisionHandler
(
_pallo
,
Osuma
);
Camera
.
Zoom
(
1
);
//Camera.ZoomToAllObjects();
Camera
.
Y
=
Level
.
Bottom
+
390
;
}
/// <summary>
/// pelaajan ja lumipallon osumasta peli alkaa alusta
/// </summary>
/// <param name="pelaaja"></param>
/// <param name="lumipallo"></param>
public
void
Osuma
(
PhysicsObject
pelaaja
,
PhysicsObject
lumipallo
)
{
AloitaAlusta
();
}
/// <summary>
/// luodaan AloitaAlusta pohja
/// </summary>
public
void
AloitaAlusta
()
{
{
...
...
@@ -73,13 +83,15 @@ public class Fgr : PhysicsGame
}
}
/// <summary>
/// Luodaan kentän yläpuolella syntyviä satunnaisia palikoita
/// </summary>
public
void
LisaaPalikka
()
{
int
monta
=
1
;
int
i
=
0
;
while
(
i
<
1
)
while
(
i
<
monta
)
{
int
leveys
=
RandomGen
.
NextInt
(
70
,
150
);
double
x
=
RandomGen
.
NextDouble
(
Level
.
Left
,
Level
.
Right
);
...
...
@@ -90,6 +102,7 @@ public class Fgr : PhysicsGame
}
}
/// <summary>
/// Luodaan pelin pelaaja-objektiksi pallo
/// </summary>
...
...
@@ -97,14 +110,14 @@ public class Fgr : PhysicsGame
{
_pallo
=
new
PhysicsObject
(
60.0
,
60.0
);
_pallo
.
Shape
=
Shape
.
Circle
;
_pallo
.
Y
=
-
320.0
;
_pallo
.
Y
=
x
;
_pallo
.
Color
=
Color
.
Charcoal
;
Gravity
=
new
Vector
(
0
,
-
50
);
//
Gravity = new Vector(0, -50);
Add
(
_pallo
);
return
_pallo
;
}
/// <summary>
/// Määrittää syntyvän palikan
/// </summary>
...
...
@@ -118,8 +131,12 @@ public class Fgr : PhysicsGame
_palikat
.
Mass
=
1000
;
Gravity
=
new
Vector
(
0
,
-
40
);
return
_palikat
;
}
/// <summary>
/// Aloitetaan peli
/// </summary>
public
void
AloitaPeli
()
{
Vector
impulssi
=
new
Vector
(
200.0
,
0.0
);
...
...
@@ -155,11 +172,19 @@ public class Fgr : PhysicsGame
Keyboard
.
Listen
(
Key
.
Escape
,
ButtonState
.
Pressed
,
ConfirmExit
,
"Lopeta peli"
);
}
/// <summary>
/// Asetetaan nopeus pelaajalle.
/// </summary>
/// <param name="pallo"></param>
/// <param name="nopeus"></param>
public
void
AsetaNopeus
(
PhysicsObject
pallo
,
Vector
nopeus
)
{
pallo
.
Velocity
=
nopeus
;
}
/// <summary>
/// Pelinkentä taustan luominen kuvien avulla.
/// </summary>
...
...
@@ -171,16 +196,22 @@ public class Fgr : PhysicsGame
_taustaAjastin
.
Start
();
_taustakuvat
=
new
List
<
GameObject
>();
LisaaTaustakuva
(
"Lumihiutaleet"
,
1024
,
1024
);
LisaaTaustakuva
(
"Lumihiutaleet"
,
1024
,
1024
);
LisaaTaustakuva
(
"Lumihiutaleet"
,
1024
,
1024
);
LisaaTaustakuva
(
"Lumihiutaleet"
,
1024
,
1024
);
LisaaTaustakuva
(
1024
,
1024
);
LisaaTaustakuva
(
1024
,
1024
);
LisaaTaustakuva
(
1024
,
1024
);
LisaaTaustakuva
(
1024
,
1024
);
}
public
void
LisaaTaustakuva
(
string
taustakuva
,
double
leveys
,
double
korkeus
)
/// <summary>
/// Lisätään taustakuvat.
/// </summary>
/// <param name="leveys"></param>
/// <param name="korkeus"></param>
public
void
LisaaTaustakuva
(
double
leveys
,
double
korkeus
)
{
GameObject
olio
=
new
GameObject
(
leveys
,
korkeus
);
olio
.
Image
=
LoadImage
(
"Lumi
hiutaleet
"
)
;
olio
.
Image
=
_
hiutaleet
;
olio
.
X
=
0
;
Add
(
olio
,
-
2
);
...
...
@@ -194,10 +225,13 @@ public class Fgr : PhysicsGame
olio
.
Top
=
Level
.
Top
;
if
(
_scrollausnopeus
<
0
)
_ekaTaustakuva
=
olio
;
}
_taustakuvat
.
Add
(
olio
);
}
/// <summary>
/// Luodaan ohjelma, jolla liikutetaan taustaa.
/// </summary>
public
void
LiikutaTaustaa
()
{
foreach
(
GameObject
taustakuva
in
_taustakuvat
)
...
...
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