Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
Glazastik committed Oct 7, 2013
2 parents f66f2cc + c3abb1e commit c48d3ee
Show file tree
Hide file tree
Showing 44 changed files with 1,612 additions and 179 deletions.
2 changes: 2 additions & 0 deletions AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

<application android:label="@string/app_name" android:icon="@drawable/ic_launcher">
<activity
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
SegwaySimulator
===============
[Download latest APK (0.2.5)](http://glaz.se/MainActivity0.2.5.apk)
##Changelog:
###v0.2
+ Added gyro support
Expand Down
Binary file added assets/gfx/background/back.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/gfx/background/front.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/gfx/background/front2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/gfx/game/cookie_sheet.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/gfx/game/curvyPlatform.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed assets/gfx/game/curvyPlatform1.png
Binary file not shown.
Binary file removed assets/gfx/game/curvyPlatform2.png
Binary file not shown.
Binary file added assets/gfx/game/gastank.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/gfx/game/goldcookie2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/gfx/game/testPlatform.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/gfx/menu/levelselect_background.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/gfx/menu/levelselect_button.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/gfx/menu/levelselect_button_green.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/gfx/menu/levelselect_lock.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions assets/level/1.lvl
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@
<entity x="620" y="150" type="coin"/>
<entity x="670" y="150" type="coin"/>
<entity x="720" y="150" type="coin"/>
<entity x="1300" y="150" type="golden_cookie"/>
</level>
1 change: 1 addition & 0 deletions assets/level/2.lvl
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<entity x="800" y="420" type="platform1"/>
<entity x="1100" y="440" type="platform1"/>
<entity x="1310" y="570" type="platform2"/>
<entity x="1200" y="500" type="golden_cookie"/>
<entity x="1350" y="530" type="platform2"/>
<entity x="1700" y="440" type="platform1"/>
<entity x="2000" y="465" type="platform1"/>
Expand Down
10 changes: 8 additions & 2 deletions assets/level/3.lvl
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<level width="3000" height="780">
<entity x="260" y="100" type="curvyPlatform1"/>
<entity x="50" y="300" type="player"/>
<entity x="50" y="200" type="platform1"/>
<entity x="0" y="100" type="curvyPlatform"/>
<entity x="170" y="100" type="curvyPlatform"/>
<entity x="330" y="120" type="curvyPlatform"/>
<entity x="490" y="140" type="curvyPlatform"/>
<entity x="650" y="160" type="curvyPlatform"/>
<entity x="840" y="100" type="testPlatform"/>
<entity x="50" y="300" type="player"/>
</level>
3 changes: 2 additions & 1 deletion assets/level/4.lvl
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
<entity x="12700" y="800" type="platform2"/>
<entity x="13000" y="700" type="platform2"/>
<entity x="13300" y="600" type="platform2"/>
<entity x="13600" y="700" type="golden_cookie"/>
<entity x="13500" y="750" type="golden_cookie"/>
<entity x="100" y="5050" type="coin"/>
<entity x="50" y="5200" type="player"/>
</level>
59 changes: 59 additions & 0 deletions assets/level/5.lvl
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?xml version="1.0" encoding="UTF-8"?>
<level width="10000" height="780">
<entity x="0" y="100" type="platform1"/>
<entity x="250" y="100" type="platform1"/>
<entity x="500" y="100" type="platform1"/>
<entity x="750" y="100" type="platform1"/>
<entity x="1000" y="100" type="platform1"/>
<entity x="1250" y="100" type="platform1"/>
<entity x="1500" y="100" type="platform1"/>
<entity x="1750" y="100" type="platform1"/>
<entity x="2000" y="100" type="platform1"/>
<entity x="2250" y="100" type="platform1"/>
<entity x="2500" y="100" type="platform1"/>
<entity x="2750" y="100" type="platform1"/>
<entity x="3000" y="100" type="platform1"/>
<entity x="3250" y="100" type="platform1"/>
<entity x="3500" y="100" type="platform1"/>
<entity x="3750" y="100" type="platform1"/>
<entity x="4000" y="100" type="platform1"/>
<entity x="4250" y="100" type="platform1"/>
<entity x="4500" y="100" type="platform1"/>
<entity x="4750" y="100" type="platform1"/>
<entity x="5000" y="100" type="platform1"/>
<entity x="5250" y="100" type="platform1"/>
<entity x="5500" y="100" type="platform1"/>
<entity x="5750" y="100" type="platform1"/>
<entity x="6000" y="100" type="platform1"/>
<entity x="6250" y="100" type="platform1"/>
<entity x="6500" y="100" type="platform1"/>
<entity x="6750" y="100" type="platform1"/>
<entity x="7000" y="100" type="platform1"/>
<entity x="7250" y="100" type="platform1"/>
<entity x="7500" y="100" type="platform1"/>
<entity x="7750" y="100" type="platform1"/>
<entity x="8000" y="100" type="platform1"/>
<entity x="8250" y="100" type="platform1"/>
<entity x="8500" y="100" type="platform1"/>
<entity x="8750" y="100" type="platform1"/>
<entity x="9000" y="100" type="platform1"/>
<entity x="9250" y="100" type="platform1"/>
<entity x="9500" y="100" type="platform1"/>
<entity x="9750" y="100" type="platform1"/>
<entity x="10000" y="100" type="platform1"/>
<entity x="100" y="150" type="coin"/>
<entity x="300" y="150" type="coin"/>
<entity x="500" y="150" type="coin"/>
<entity x="700" y="150" type="coin"/>
<entity x="900" y="150" type="coin"/>
<entity x="1100" y="150" type="coin"/>
<entity x="1300" y="150" type="coin"/>
<entity x="1500" y="150" type="coin"/>
<entity x="1700" y="150" type="coin"/>
<entity x="450" y="150" type="gastank" />
<entity x="850" y="150" type="gastank" />
<entity x="1250" y="150" type="gastank" />
<entity x="1650" y="150" type="gastank" />
<entity x="2050" y="150" type="gastank" />
<entity x="10" y="140" type="player"/>
</level>
Binary file added assets/sfx/bone_crack_1.ogg
Binary file not shown.
Binary file added assets/sfx/cliffsofdover.ogg
Binary file not shown.
107 changes: 107 additions & 0 deletions assets/shapes/curvyPlatform.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- created with http://www.physicseditor.de -->
<bodydef version="1.0">
<bodies numBodies="1">

<body name="curvyPlatform" dynamic="true" numFixtures="1">

<fixture
density="2"
friction="0"
restitution="0"
filter_categoryBits="1"
filter_groupIndex="0"
filter_maskBits="65535"
isSensor="false"
type="POLYGON"
numPolygons="7"
>


<polygon numVertexes="4">

<vertex x="-74.0000" y="-38.5000" />

<vertex x="-70.0000" y="-38.5000" />

<vertex x="74.0000" y="38.5000" />

<vertex x="-74.0000" y="38.5000" />

</polygon>

<polygon numVertexes="4">

<vertex x="74.0000" y="-38.5000" />

<vertex x="74.0000" y="38.5000" />

<vertex x="70.0000" y="-36.5000" />

<vertex x="71.0000" y="-38.5000" />

</polygon>

<polygon numVertexes="4">

<vertex x="70.0000" y="-36.5000" />

<vertex x="74.0000" y="38.5000" />

<vertex x="57.0000" y="-29.5000" />

<vertex x="58.0000" y="-31.5000" />

</polygon>

<polygon numVertexes="3">

<vertex x="74.0000" y="38.5000" />

<vertex x="24.0000" y="-14.5000" />

<vertex x="57.0000" y="-29.5000" />

</polygon>

<polygon numVertexes="3">

<vertex x="74.0000" y="38.5000" />

<vertex x="15.0000" y="-12.5000" />

<vertex x="24.0000" y="-14.5000" />

</polygon>

<polygon numVertexes="3">

<vertex x="74.0000" y="38.5000" />

<vertex x="-7.0000" y="-12.5000" />

<vertex x="15.0000" y="-12.5000" />

</polygon>

<polygon numVertexes="3">

<vertex x="74.0000" y="38.5000" />

<vertex x="-33.0000" y="-19.5000" />

<vertex x="-7.0000" y="-12.5000" />

</polygon>


</fixture>

</body>

</bodies>
<metadata>
<format>1</format>
<ptm_ratio></ptm_ratio>
</metadata>
</bodydef>
67 changes: 67 additions & 0 deletions assets/shapes/testPlatform.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- created with http://www.physicseditor.de -->
<bodydef version="1.0">
<bodies numBodies="1">

<body name="testPlatform" dynamic="true" numFixtures="1">

<fixture
density="2"
friction="0"
restitution="0"
filter_categoryBits="1"
filter_groupIndex="0"
filter_maskBits="65535"
isSensor="false"
type="POLYGON"
numPolygons="3"
>


<polygon numVertexes="4">

<vertex x="201.0000" y="-126.0000" />

<vertex x="201.0000" y="126.0000" />

<vertex x="99.0000" y="34.0000" />

<vertex x="99.0000" y="-126.0000" />

</polygon>

<polygon numVertexes="4">

<vertex x="-100.0000" y="34.0000" />

<vertex x="-201.0000" y="126.0000" />

<vertex x="-201.0000" y="-126.0000" />

<vertex x="-100.0000" y="-126.0000" />

</polygon>

<polygon numVertexes="4">

<vertex x="99.0000" y="34.0000" />

<vertex x="201.0000" y="126.0000" />

<vertex x="-201.0000" y="126.0000" />

<vertex x="-100.0000" y="34.0000" />

</polygon>


</fixture>

</body>

</bodies>
<metadata>
<format>1</format>
<ptm_ratio></ptm_ratio>
</metadata>
</bodydef>
3 changes: 3 additions & 0 deletions lint.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<lint>
<issue id="WrongCall">
<ignore path="src/se/chalmers/segway/scenes/ParallaxLayer.java" />
</issue>
</lint>
40 changes: 34 additions & 6 deletions src/se/chalmers/segway/entities/Player.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.andengine.extension.physics.box2d.PhysicsWorld;
import org.andengine.opengl.vbo.VertexBufferObjectManager;

import se.chalmers.segway.game.Upgrades;
import se.chalmers.segway.resources.ResourcesManager;

import com.badlogic.gdx.math.Vector2;
Expand All @@ -19,6 +20,7 @@ public abstract class Player extends AnimatedSprite {
private boolean hasContact = false;
final long[] PLAYER_SLOW_ANIMATE = new long[] { 100, 100, 100 };
final long[] PLAYER_FAST_ANIMATE = new long[] { 50, 50, 50 };
final int PIXELS_TO_METERS = 32;
private Vector2 speed;

public Player(float pX, float pY, VertexBufferObjectManager vbo,
Expand All @@ -45,7 +47,7 @@ public void onUpdate(float pSecondsElapsed) {
if (getY() <= 0) {
onDie();
}

movePlayer(pSecondsElapsed);

if (Math.abs(body.getLinearVelocity().x) < 0.5) {
Expand All @@ -55,18 +57,31 @@ public void onUpdate(float pSecondsElapsed) {
});
}

public void movePlayer(float pSecondsElapsed){
/**
* Reads the latest data from the accelerometer and moves Player accordingly.
* @param pSecondsElapsed the delta since last update, to compensate.
*/
public void movePlayer(float pSecondsElapsed) {
if (speed != null) {
body.applyForce(speed.mul(50*pSecondsElapsed),
body.getPosition());
body.applyForce(speed.mul(50 * pSecondsElapsed), body.getPosition());
if (Math.abs(body.getLinearVelocity().x) >= 15) {
body.setLinearVelocity(
Math.signum(body.getLinearVelocity().x) * 15,
body.getLinearVelocity().y);
}
}
}


/**
* Moves to appropriate place, described in pixels.
* @param x position x in pixels.
* @param y position x in pixels.
*/
public void setRealPosition(int x, int y) {
body.setTransform(x / PIXELS_TO_METERS, y / PIXELS_TO_METERS,
body.getAngle());
}

public void setContact(boolean b) {
hasContact = b;
}
Expand All @@ -75,14 +90,27 @@ public void setSpeed(Vector2 v) {
speed = v;
}

/**
* Makes the Player jump if it has contact with the ground.
*/
public void jump() {
if (hasContact == false) {
return;
}
hasContact = false;
body.setLinearVelocity(new Vector2(body.getLinearVelocity().x, 6));
if(Upgrades.AntigravityWheels.isActivated()){
body.setLinearVelocity(new Vector2(body.getLinearVelocity().x, 14));
} else {
body.setLinearVelocity(new Vector2(body.getLinearVelocity().x, 7));
}

}

public void stop(){

body.setType(BodyType.StaticBody);

}

public abstract void onDie();

Expand Down
Loading

0 comments on commit c48d3ee

Please sign in to comment.