Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Sammakkopeli
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
snelvjxz
Sammakkopeli
Commits
a5d3044c
Commit
a5d3044c
authored
2 years ago
by
Snellman Väinö Juhani
Browse files
Options
Downloads
Patches
Plain Diff
paranneltiin pelihahmon liikkuvuutta
parent
d339266a
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
Sammakkopeli/Sammakkopeli/Sammakkopeli.cs
+69
-10
69 additions, 10 deletions
Sammakkopeli/Sammakkopeli/Sammakkopeli.cs
with
69 additions
and
10 deletions
Sammakkopeli/Sammakkopeli/Sammakkopeli.cs
+
69
−
10
View file @
a5d3044c
...
...
@@ -9,12 +9,18 @@ namespace Sammakkopeli
{
public
class
Sammakkopeli
:
PhysicsGame
{
Vector
sammakkoVasen
=
new
Vector
(-
500
,
-
400
);
Vector
sammakkoOikea
=
new
Vector
(
500
,
-
400
);
Vector
sammakkoPainovoima
=
new
Vector
(
0
,
-
400
);
Vector
suunta
;
PhysicsObject
sammakko
;
Timer
hyppyLaskuri
;
Timer
tarkastaLiike
;
int
sammakkoTippuuKertoja
=
8
;
bool
onkoHypannut
=
false
;
double
nopeusX
=
0.0
;
double
nopeusY
=
-
800.0
;
public
override
void
Begin
()
{
...
...
@@ -26,11 +32,25 @@ namespace Sammakkopeli
public
void
AsetaOhjaimet
()
{
Keyboard
.
Listen
(
Key
.
Left
,
ButtonState
.
Down
,
LiikutaPelihahmoa
,
null
,
sammakkoVasen
);
Keyboard
.
Listen
(
Key
.
Left
,
ButtonState
.
Released
,
LiikutaPelihahmoa
,
null
,
sammakkoPainovoima
);
Keyboard
.
Listen
(
Key
.
Left
,
ButtonState
.
Down
,
AsetaNopeus
,
null
,
-
1
);
Keyboard
.
Listen
(
Key
.
Left
,
ButtonState
.
Released
,
PysaytaSammakko
,
null
);
Keyboard
.
Listen
(
Key
.
Right
,
ButtonState
.
Down
,
LiikutaPelihahmoa
,
null
,
sammakkoOikea
);
Keyboard
.
Listen
(
Key
.
Right
,
ButtonState
.
Released
,
LiikutaPelihahmoa
,
null
,
sammakkoPainovoima
);
Keyboard
.
Listen
(
Key
.
Right
,
ButtonState
.
Down
,
AsetaNopeus
,
null
,
1
);
Keyboard
.
Listen
(
Key
.
Right
,
ButtonState
.
Released
,
PysaytaSammakko
,
null
);
Keyboard
.
Listen
(
Key
.
Space
,
ButtonState
.
Pressed
,
SammakkoHyppaa
,
null
);
}
void
AsetaNopeus
(
int
suunta
)
{
nopeusX
=
suunta
*
600.0
;
}
void
PysaytaSammakko
()
{
nopeusX
=
0.0
;
}
...
...
@@ -40,26 +60,65 @@ namespace Sammakkopeli
LuoPelihahmo
(
0
,
0
);
Level
.
CreateBottomBorder
(
0.0
,
true
);
hyppyLaskuri
=
new
Timer
();
hyppyLaskuri
.
Interval
=
0.05
;
hyppyLaskuri
.
Timeout
+=
SammakkoTippuu
;
tarkastaLiike
=
new
Timer
();
tarkastaLiike
.
Interval
=
0.05
;
tarkastaLiike
.
Timeout
+=
LiikutaPelihahmoa
;
tarkastaLiike
.
Start
();
}
public
void
LuoPelihahmo
(
double
x
,
double
y
)
{
sammakko
=
new
PhysicsObject
(
40.0
,
26.0
);
//sammakko = LoadImage("VainSammakko");
sammakko
.
Shape
=
Shape
.
Rectangle
;
sammakko
.
X
=
x
;
sammakko
.
Y
=
y
;
sammakko
.
Color
=
Color
.
Green
;
sammakko
.
Velocity
=
sammakkoPainovoima
;
Add
(
sammakko
);
AddCollisionHandler
(
sammakko
,
KasitteleSammakonTormays
);
}
public
void
LiikutaPelihahmoa
(
Vector
suunta
)
public
void
LiikutaPelihahmoa
()
{
suunta
=
new
Vector
(
nopeusX
,
nopeusY
);
sammakko
.
Velocity
=
suunta
;
}
public
void
SammakkoHyppaa
()
{
if
(
onkoHypannut
==
false
)
{
onkoHypannut
=
true
;
hyppyLaskuri
.
Start
(
16
);
}
}
void
SammakkoTippuu
()
{
sammakkoTippuuKertoja
-=
1
;
if
(
sammakkoTippuuKertoja
<
-
7
)
{
nopeusY
=
-
800.0
;
sammakkoTippuuKertoja
=
8
;
return
;
}
nopeusY
=
sammakkoTippuuKertoja
*
100
;
}
void
KasitteleSammakonTormays
(
PhysicsObject
tormaaja
,
PhysicsObject
kohde
)
{
onkoHypannut
=
false
;
}
}
}
\ No newline at end of file
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