Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit ee5c996
Showing
33 changed files
with
458 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,8 @@ | |||
<?xml version="1.0" encoding="UTF-8"?> | |||
<classpath> | |||
<classpathentry kind="src" path="src"/> | |||
<classpathentry kind="src" path="gen"/> | |||
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/> | |||
<classpathentry kind="lib" path="/data/prg/discontinued/ipw/sensorsimulator-1.1.0-rc1/lib/sensorsimulator-lib-1.1.0-rc1.jar"/> | |||
<classpathentry kind="output" path="bin"/> | |||
</classpath> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,33 @@ | |||
<?xml version="1.0" encoding="UTF-8"?> | |||
<projectDescription> | |||
<name>KamikazeRace</name> | |||
<comment></comment> | |||
<projects> | |||
</projects> | |||
<buildSpec> | |||
<buildCommand> | |||
<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name> | |||
<arguments> | |||
</arguments> | |||
</buildCommand> | |||
<buildCommand> | |||
<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name> | |||
<arguments> | |||
</arguments> | |||
</buildCommand> | |||
<buildCommand> | |||
<name>org.eclipse.jdt.core.javabuilder</name> | |||
<arguments> | |||
</arguments> | |||
</buildCommand> | |||
<buildCommand> | |||
<name>com.android.ide.eclipse.adt.ApkBuilder</name> | |||
<arguments> | |||
</arguments> | |||
</buildCommand> | |||
</buildSpec> | |||
<natures> | |||
<nature>com.android.ide.eclipse.adt.AndroidNature</nature> | |||
<nature>org.eclipse.jdt.core.javanature</nature> | |||
</natures> | |||
</projectDescription> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,19 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | |||
package="mm.kamikaze" | |||
android:versionCode="1" | |||
android:versionName="1.0"> | |||
<application android:icon="@drawable/icon" android:label="@string/app_name"> | |||
<activity android:name=".Kamikaze" | |||
android:label="@string/app_name"> | |||
<intent-filter> | |||
<action android:name="android.intent.action.MAIN" /> | |||
<category android:name="android.intent.category.LAUNCHER" /> | |||
</intent-filter> | |||
</activity> | |||
|
|||
</application> | |||
|
|||
|
|||
<uses-permission android:name="android.permission.INTERNET"></uses-permission> | |||
</manifest> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,13 @@ | |||
Mihai Maruseac, 341C3 | |||
Kamikaze Race | |||
|
|||
Aplicația presupune că jucătorul este un șofer de mașină cam nenorocos: este pe | |||
autostradă în plin trafic cu accelerația la maxim și fără frâne. Ajută șoferul | |||
să supraviețuiască cât mai mult. | |||
|
|||
Aplicația folosește senzorul de orientare, contând valoarea lui roll | |||
(dreapta-stânga). Dacă testați pe calculator (singurul lor unde a fost testată) | |||
trebie să folosiți simulatorul de la open intents. | |||
|
|||
Pentru restart, se ține click lung pe ecran. Funcționează doar la game-over. | |||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,11 @@ | |||
# This file is automatically generated by Android Tools. | |||
# Do not modify this file -- YOUR CHANGES WILL BE ERASED! | |||
# | |||
# This file must be checked in Version Control Systems. | |||
# | |||
# To customize properties used by the Ant build system use, | |||
# "build.properties", and override values to adapt the script to your | |||
# project structure. | |||
|
|||
# Project target. | |||
target=android-8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,28 @@ | |||
/* AUTO-GENERATED FILE. DO NOT MODIFY. | |||
* | |||
* This class was automatically generated by the | |||
* aapt tool from the resource data it found. It | |||
* should not be modified by hand. | |||
*/ | |||
|
|||
package mm.kamikaze; | |||
|
|||
public final class R { | |||
public static final class attr { | |||
} | |||
public static final class drawable { | |||
public static final int hiscar=0x7f020000; | |||
public static final int icon=0x7f020001; | |||
public static final int mycar=0x7f020002; | |||
} | |||
public static final class id { | |||
public static final int canvas=0x7f050000; | |||
} | |||
public static final class layout { | |||
public static final int main=0x7f030000; | |||
} | |||
public static final class string { | |||
public static final int app_name=0x7f040001; | |||
public static final int hello=0x7f040000; | |||
} | |||
} |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,13 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |||
android:orientation="vertical" | |||
android:layout_width="fill_parent" | |||
android:layout_height="fill_parent" | |||
> | |||
<LinearLayout | |||
android:orientation="vertical" | |||
android:layout_width="fill_parent" | |||
android:layout_height="fill_parent" | |||
android:id="@+id/canvas" | |||
/> | |||
</LinearLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,5 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<resources> | |||
<string name="hello">Hello World, Kamikaze!</string> | |||
<string name="app_name">Kamikaze Race</string> | |||
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,19 @@ | |||
package mm.kamikaze; | |||
|
|||
public class Car { | |||
public int x, y, sp; | |||
public int h; | |||
public boolean active; | |||
|
|||
public Car() { | |||
defaultSettings(); | |||
} | |||
|
|||
private void defaultSettings(){ | |||
x = 0; | |||
y = 0; | |||
h = 20; | |||
sp = 0; | |||
active = false; | |||
} | |||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,216 @@ | |||
package mm.kamikaze; | |||
|
|||
import android.content.Context; | |||
import android.content.res.Resources; | |||
import android.graphics.Bitmap; | |||
import android.graphics.BitmapFactory; | |||
import android.graphics.Canvas; | |||
import android.graphics.Color; | |||
import android.graphics.Paint; | |||
import android.graphics.Rect; | |||
import android.graphics.Paint.Style; | |||
import android.view.View; | |||
import android.widget.Toast; | |||
|
|||
public class Draw extends View{ | |||
private static final int PAD = 10; | |||
private static final int SCOREPAD = 32; | |||
private Context context; | |||
private int w, h; | |||
private int xs, ys, xe, ye; | |||
|
|||
/* Road geometry */ | |||
private static final int STRIPELEN = 20; | |||
private static final int STRIPETOT = 56; | |||
private static final int STRIPEWID = 2; | |||
private static final int BLEN = 30; | |||
private int STRIPESTART = 0; | |||
private static final int STRIPES = 10; | |||
|
|||
/* Car geometry */ | |||
private final int HWCAR = 10; | |||
private final int HHCAR = 33; | |||
private final int YCAR = 325; | |||
private int XCAR = 295; | |||
private static final int XCARMAX = 295; | |||
private static final int XCARMIN = 25; | |||
|
|||
/* Speed values */ | |||
private final int STRIPSPEED = 1; | |||
private final int MAXSPEED = STRIPES * STRIPSPEED; | |||
private double sp = 0.5; | |||
private int BEHIND = 500; | |||
|
|||
/* random values */ | |||
private double CAR = .2; | |||
|
|||
/* cars */ | |||
private final int MAXCARS = 10; | |||
private Car []cars; | |||
private int activeCars = 0; | |||
private boolean gameover = false; | |||
private Bitmap mycar; | |||
private Bitmap hiscar; | |||
|
|||
public Draw(Context context) { | |||
super(context); | |||
this.context = context; | |||
|
|||
cars = new Car[MAXCARS]; | |||
for (int i = 0; i < MAXCARS; i++) | |||
cars[i] = new Car(); | |||
|
|||
Resources res = getResources(); | |||
mycar = BitmapFactory.decodeResource(res, R.drawable.mycar); | |||
hiscar = BitmapFactory.decodeResource(res, R.drawable.hiscar); | |||
} | |||
|
|||
public void reset(){ | |||
if (!gameover) return; | |||
sp = .5; | |||
activeCars = 0; | |||
XCAR = XCARMAX; | |||
gameover = false; | |||
postInvalidate(); | |||
} | |||
|
|||
@Override | |||
protected void onDraw(Canvas canvas){ | |||
int x, y, ytmp; | |||
|
|||
w = this.getWidth(); | |||
h = this.getHeight(); | |||
|
|||
xs = PAD; | |||
ys = PAD + SCOREPAD; | |||
xe = w - PAD; | |||
ye = h - PAD; | |||
|
|||
/* draw text */ | |||
Paint textp = new Paint(); | |||
textp.setColor(Color.MAGENTA); | |||
canvas.drawText("Score: " + (int)Math.round(10 * sp), xs + 12, ys - 12, textp); | |||
|
|||
/* draw border around terrain */ | |||
Paint bp = new Paint(); | |||
bp.setColor(Color.YELLOW); | |||
bp.setStyle(Style.STROKE); | |||
canvas.drawRect(xs, ys, xe, ye, bp); | |||
|
|||
/* draw marks on the road */ | |||
Paint sp = new Paint(); | |||
sp.setColor(Color.LTGRAY); | |||
x = xs + BLEN - STRIPEWID / 2; | |||
while (x < xe - 5){ | |||
y = ys + STRIPESTART; | |||
while (y < ye){ | |||
ytmp = y + STRIPELEN; | |||
if (ytmp > ye){ | |||
ytmp = ye; | |||
canvas.drawRect(x, y, x + STRIPEWID, ytmp, sp); | |||
break; | |||
} | |||
canvas.drawRect(x, y, x + STRIPEWID, ytmp, sp); | |||
y += STRIPETOT; | |||
} | |||
x += BLEN; | |||
} | |||
|
|||
/* draw my car */ | |||
canvas.drawBitmap(mycar, XCAR - HWCAR, YCAR - HHCAR, null); | |||
|
|||
/* draw other cars */ | |||
if (gameover){ | |||
Toast.makeText(context, "Game Over", Toast.LENGTH_SHORT).show(); | |||
} | |||
|
|||
canvas.clipRect(xs, ys, xe, ye); | |||
for (int i = 0; i < activeCars; i++){ | |||
Car c = cars[i]; | |||
canvas.drawBitmap(hiscar, c.x - HWCAR, c.y - c.h, null); | |||
} | |||
} | |||
|
|||
public void run() { | |||
if (gameover) return; | |||
|
|||
STRIPESTART = (int)Math.round(STRIPESTART + sp) % STRIPETOT; | |||
sp += .05; | |||
|
|||
/* car moves */ | |||
for (int i = 0; i < activeCars; i++){ | |||
cars[i].y -= (cars[i].sp - sp); | |||
} | |||
|
|||
for (int i = 0; i < activeCars; i++){ | |||
if (cars[i].y > BEHIND){ | |||
Car tmp = cars[(activeCars--)-1]; | |||
cars[activeCars] = cars[i]; | |||
cars[i--] = tmp; | |||
} | |||
} | |||
|
|||
/* check colision */ | |||
for (int i = 0; i < activeCars; i++){ | |||
if (Math.abs(XCAR - cars[i].x) < 2 * HWCAR){ | |||
if (Math.abs(YCAR - cars[i].y) < 2 * HHCAR){ | |||
gameover = true; | |||
} | |||
} | |||
} | |||
|
|||
/* get a new car */ | |||
if (activeCars < MAXCARS){ | |||
double x = Math.random(); | |||
if (x < CAR){ | |||
int speed = (int) Math.round(Math.random() * MAXSPEED); | |||
int band; | |||
|
|||
for (band = 0; band < STRIPES; band++){ | |||
if (speed < band * STRIPSPEED){ | |||
break; | |||
} | |||
} | |||
band--; | |||
|
|||
cars[activeCars].active = true; | |||
cars[activeCars].x = XCARMAX - band * BLEN; | |||
int s = 0, count = 0; | |||
for (int j = 0; j < activeCars; j++){ | |||
if (cars[j].x == cars[activeCars].x){ | |||
s += cars[j].sp; | |||
count++; | |||
} | |||
} | |||
if (count != 0){ | |||
speed = (int) Math.round((float)s/count); | |||
} | |||
if (speed > sp) | |||
cars[activeCars].y = BEHIND - 10; | |||
else | |||
cars[activeCars].y = 0; | |||
for (int j = 0; j < activeCars; j++){ | |||
if (cars[j].x == cars[activeCars].x && Math.abs(cars[activeCars].y - cars[j].y) <= 3*HHCAR){ | |||
cars[activeCars].active = false; | |||
break; | |||
} | |||
} | |||
if (cars[activeCars].active){ | |||
cars[activeCars].sp = speed; | |||
activeCars++; | |||
} | |||
} | |||
} | |||
|
|||
CAR += .05; | |||
postInvalidate(); | |||
} | |||
|
|||
public void moveLeft(int dx){ | |||
if (XCAR > XCARMIN) XCAR-=dx; | |||
} | |||
|
|||
public void moveRight(int dx){ | |||
if (XCAR < XCARMAX) XCAR+=dx; | |||
} | |||
} |
Oops, something went wrong.