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
0e1eacdc
Commit
0e1eacdc
authored
3 years ago
by
Vesa Lappalainen
Browse files
Options
Downloads
Patches
Plain Diff
liitos
parent
0de6714c
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
luennot/luento17/Hirsipuu/Hirsipuu.cs
+53
-4
53 additions, 4 deletions
luennot/luento17/Hirsipuu/Hirsipuu.cs
luennot/luento17/Liitos/Liitos.cs
+9
-7
9 additions, 7 deletions
luennot/luento17/Liitos/Liitos.cs
with
62 additions
and
11 deletions
luennot/luento17/Hirsipuu/Hirsipuu.cs
+
53
−
4
View file @
0e1eacdc
...
...
@@ -7,6 +7,12 @@ using Jypeli.Controls;
using
Jypeli.Widgets
;
using
System.IO
;
using
FSJoint
=
FarseerPhysics
.
Dynamics
.
Joints
.
DistanceJoint
;
using
FarseerPhysics.Factories
;
using
FarseerPhysics.Dynamics
;
using
Jypeli.Farseer
;
/// @author vesal
/// @version 2.11.2014
/// <summary>
...
...
@@ -167,6 +173,49 @@ public class Hirsipuu : PhysicsGame
/// </summary>
public
class
Hirsi
:
PhysicsObject
{
public
class
AxleJoint
:
Jypeli
.
AxleJoint
{
internal
FSJoint
InnerJoint
{
get
{
return
(
FSJoint
)
innerJoint
;
}
set
{
innerJoint
=
value
;
}
}
/// <summary>
/// Luo uuden akseliliitoksen kahden olion välille.
/// </summary>
/// <param name="firstObject">Ensimmäinen olio</param>
/// <param name="secondObject">Toinen olio</param>
/// <param name="axlePosition">Liitoksen akselin paikka</param>
public
AxleJoint
(
PhysicsObject
firstObject
,
PhysicsObject
secondObject
,
Vector
axlePosition
)
:
base
(
firstObject
,
secondObject
,
axlePosition
)
{
World
world
=
PhysicsGame
.
Instance
.
Engine
as
World
;
var
first
=
firstObject
.
Body
as
PhysicsBody
;
var
second
=
secondObject
.
Body
as
PhysicsBody
;
var
ap2
=
firstObject
.
Position
+
axlePosition
-
secondObject
.
Position
;
InnerJoint
=
JointFactory
.
CreateDistanceJoint
(
world
,
first
.
FSBody
,
second
.
FSBody
,
axlePosition
*
FSConvert
.
DisplayToSim
,
ap2
*
FSConvert
.
DisplayToSim
);
// axlePosition2 * FSConvert.DisplayToSim);
InnerJoint
.
DampingRatio
=
0.5f
;
InnerJoint
.
Frequency
=
50
;
//InnerJoint.Enabled = false;
}
}
private
static
readonly
Image
Kuva
=
Game
.
LoadImage
(
"puupalikka"
);
private
readonly
PhysicsGame
peli
;
private
readonly
IntMeter
palikoita
=
new
IntMeter
(
0
);
...
...
@@ -247,14 +296,14 @@ public class Hirsi : PhysicsObject
PhysicsObject
torso
=
LuoOlio
(
peli
,
paa
.
Position
+
new
Vector
(
0
,
-
90
),
130
,
200
,
Game
.
LoadImage
(
"torso"
));
peli
.
Add
(
new
AxleJoint
(
torso
,
paa
,
new
Vector
(
7
,
torso
.
Height
/
2
-
10
)));
PhysicsObject
vasenKasi
=
LuoOlio
(
peli
,
paa
.
Position
+
new
Vector
(
50
+
75
,
-
20
),
150
,
40
,
Game
.
LoadImage
(
"kasi"
));
peli
.
Add
(
new
AxleJoint
(
vasenKasi
,
torso
,
new
Vector
(-
vasenKasi
.
Width
/
2
*
0
,
0
)));
vasenKasi
.
Angle
=
Angle
.
FromDegrees
(-
90
);
//
PhysicsObject vasenKasi = LuoOlio(peli, paa.Position + new Vector(50 + 75, -20), 150, 40, Game.LoadImage("kasi"));
//
peli.Add(new AxleJoint(vasenKasi, torso, new Vector(-vasenKasi.Width/2*0, 0)));
//
vasenKasi.Angle = Angle.FromDegrees(-90);
PhysicsObject
oikeaKasi
=
LuoOlio
(
peli
,
paa
.
Position
+
new
Vector
(-
50
+
-
65
,
-
20
),
150
,
40
,
Game
.
LoadImage
(
"kasi"
));
oikeaKasi
.
Angle
=
Angle
.
FromDegrees
(
180
);
peli
.
Add
(
new
AxleJoint
(
oikeaKasi
,
torso
,
new
Vector
(
oikeaKasi
.
Width
/
2
,
0
)));
peli
.
Add
(
new
AxleJoint
(
torso
,
oikeaKasi
,
new
Vector
(
-
torso
.
Width
/
2
,
-
torso
.
Height
/
2
)));
PhysicsObject
vasenJalka
=
LuoOlio
(
peli
,
torso
.
Position
+
new
Vector
(
40
,
-
110
-
75
),
75
,
190
,
Game
.
LoadImage
(
"jalka"
));
peli
.
Add
(
new
AxleJoint
(
vasenJalka
,
torso
,
new
Vector
(
0
,
vasenJalka
.
Height
)));
...
...
This diff is collapsed.
Click to expand it.
luennot/luento17/Liitos/Liitos.cs
+
9
−
7
View file @
0e1eacdc
using
Jypeli
;
using
Jypeli.Assets
;
using
Jypeli.Controls
;
using
Jypeli.Widgets
;
using
System
;
using
System.Collections.Generic
;
using
FSJoint
=
FarseerPhysics
.
Dynamics
.
Joints
.
DistanceJoint
;
using
FarseerPhysics.Factories
;
using
FarseerPhysics.Dynamics
;
using
Jypeli.Farseer
;
using
Jypeli.Physics
;
using
FarseerPhysics.Dynamics.Joints
;
public
class
Liitos
:
PhysicsGame
{
...
...
@@ -64,6 +57,7 @@ public class Liitos : PhysicsGame
osa1
.
MakeStatic
();
osa1
.
AddCollisionIgnoreGroup
(
1
);
Add
(
osa1
);
var
osa2
=
new
PhysicsObject
(
200
,
30
);
osa2
.
Position
=
new
Vector
(
osa1
.
Width
,
0
);
osa2
.
AddCollisionIgnoreGroup
(
1
);
...
...
@@ -71,6 +65,14 @@ public class Liitos : PhysicsGame
var
liitos
=
new
AxleJoint
(
osa1
,
osa2
,
new
Vector
(
osa1
.
Width
/
2
,
0
));
liitos
.
Softness
=
0
;
Add
(
liitos
);
var
osa3
=
new
PhysicsObject
(
200
,
30
);
osa3
.
Position
=
new
Vector
(
osa1
.
Width
+
osa2
.
Width
,
0
);
osa3
.
AddCollisionIgnoreGroup
(
1
);
Add
(
osa3
);
var
liitos2
=
new
AxleJoint
(
osa2
,
osa3
,
new
Vector
(
osa2
.
Width
/
2
,
0
));
Add
(
liitos2
);
Gravity
=
new
Vector
(
0
,
-
400
);
}
}
...
...
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