AI 144511: am: CL 144510 am: CL 144509 Checking in Sonivox' JetBoy code sample. The java code still has a FIXME for cleanup and review to be done before final SDK build.

Original author: jmtrivi
  Merged from: //branches/cupcake/...
  Original author: android-build

Automated import of CL 144511
This commit is contained in:
Jean-Michel Trivi
2009-04-03 15:04:27 -07:00
committed by The Android Open Source Project
parent 55ebbc4e1a
commit cfe4476f03
45 changed files with 2164 additions and 0 deletions

10
samples/JetBoy/Android.mk Executable file
View File

@@ -0,0 +1,10 @@
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE_TAGS := samples
LOCAL_SRC_FILES := $(call all-subdir-java-files)
LOCAL_PACKAGE_NAME := JETBoy
include $(BUILD_PACKAGE)

View File

@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2009 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!-- This file describes the code in the JetBoy package, which is
used by the system to determine how to start the application and
integrate it with the rest of the system. -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.android.jetboy"
android:versionCode="1"
android:versionName="1.0.0">
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".JetBoy"
android:label="@string/app_name"
android:screenOrientation="landscape">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 196 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 59 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 149 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 166 KiB

View File

@@ -0,0 +1,93 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<com.example.android.jetboy.JetBoyView
android:id="@+id/JetBoyView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
<LinearLayout
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:layout_gravity="top" android:gravity="center_horizontal"
android:orientation="horizontal">
<TextView
android:id="@+id/text"
android:text="@string/helpText"
style="@style/helpText"
android:visibility="invisible"
android:layout_width="300px"
android:layout_height="300px"
android:layout_centerInParent="true"
android:gravity="left"
android:background="#88ffffff"
/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:layout_gravity="bottom" android:gravity="center_horizontal"
android:orientation="horizontal">
<Button android:id="@+id/Button01"
android:text="@string/start"
style="@style/ButtonText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="true"
android:cursorVisible="true">
</Button>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:layout_gravity="bottom" android:gravity="center_horizontal"
android:orientation="horizontal">
<Button android:id="@+id/Button02"
android:text="@string/retry"
style="@style/ButtonText"
android:visibility="invisible"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="true"
android:cursorVisible="true">
</Button>
<!--Button android:id="@+id/Button03"
android:text="@string/restart"
style="@style/ButtonText"
android:visibility="invisible"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="true"
android:cursorVisible="true">
</Button-->
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:layout_gravity="top" android:gravity="right"
android:orientation="horizontal">
<TextView
android:id="@+id/timer"
android:text="@string/timer"
style="@style/timerText"
android:visibility="invisible"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="right"
android:background="#000000"
android:textSize="24sp"/>
</LinearLayout>
</FrameLayout>

BIN
samples/JetBoy/res/raw/level1.jet Executable file

Binary file not shown.

View File

@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">JetBoy</string>
<string name="start">START!</string>
<string name="retry">RETRY</string>
<string name="restart">RETURN</string>
<string name="helpText">Help JET BOY get through the asteroid field! Blast the asteroids in time with the beat and listen to the music respond!\n\nUse your FIRE button to explode each asteroid as it passes through the laser guide.</string>
<string name="winText">You win, You are the master of the Universe!\n\nJETBOY by SONiVOX®\n\nProduced by Jennifer Hruska\nMusic by Eric Barlaan\nGraphics by Randy OConnor\nProgramming by MageTech</string>
<string name="loseText">Sorry, you lose.</string>
<string name="timer">1:12</string>
</resources>

View File

@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2007 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!-- This file contains resource definitions for style. A style is
a collection of named values that can be applied as a group. Here,
we are using a style to define a common set of XML attributes that
will be used in multiple tags. -->
<resources>
<style name="ButtonText">
<item name="android:textSize">24sp</item>
</style>
<style name="helpText">
<item name="android:textSize">20sp</item>
<item name="android:textColor">#000000</item>>
</style>
<style name="timerText">
<item name="android:textSize">18sp</item>
<item name="android:textColor">#ffffff</item>>
</style>
</resources>

View File

@@ -0,0 +1,31 @@
/*
* Copyright (C) 2009 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// FIXME: review and cleanup
package com.example.android.jetboy;
public class Asteroid {
public int mAniIndex = 0;
public int mDrawY = 0;
public int mDrawX = 0;
public boolean mExploding = false;
public boolean mMissed = false;
public long mStartTime = 0;
}

View File

@@ -0,0 +1,26 @@
/*
* Copyright (C) 2009 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// FIXME: review and cleanup
package com.example.android.jetboy;
public class Explosion {
public int mAniIndex = 0;
public int mDrawY = 0;
public int mDrawX = 0;
}

View File

@@ -0,0 +1,161 @@
/*
* Copyright (C) 2009 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// FIXME: review and cleanup
package com.example.android.jetboy;
import com.example.android.jetboy.JetBoyView.JetBoyThread;
import com.example.android.jetboy.JetBoyView;
import com.example.android.jetboy.R;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.KeyEvent;
import android.view.Window;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
public class JetBoy extends Activity implements View.OnClickListener{
/** A handle to the thread that's actually running the animation. */
private JetBoyThread mJetBoyThread;
/** A handle to the View in which the game is running. */
private JetBoyView mJetBoyView;
//the play start button
private Button mButton;
//used to hit retry
private Button mButtonRetry;
//the window for instructions and such
private TextView mTextView;
//game window timer
private TextView mTimerView;
/**
* Required method from parent class
* @param savedInstanceState - The previous instance of this app
*/
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// turn off the window's title bar
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.main);
// get handles to the JetView from XML and the JET thread.
mJetBoyView = (JetBoyView) findViewById(R.id.JetBoyView);
mJetBoyThread = mJetBoyView.getThread();
//look up the happy shiny button
mButton = (Button)findViewById(R.id.Button01);
mButton.setOnClickListener(this);
mButtonRetry = (Button)findViewById(R.id.Button02);
mButtonRetry.setOnClickListener(this);
//set up handles for instruction text and game timer text
mTextView = (TextView) findViewById(R.id.text);
mTimerView = (TextView) findViewById(R.id.timer);
mJetBoyView.setTimerView(mTimerView);
mJetBoyView.SetButtonView(mButtonRetry);
mJetBoyView.SetTextView(mTextView);
}
/**
* Handles component interaction
*
* @param v The object which has been clicked
*/
public void onClick(View v) {
//this is the first screen
if (mJetBoyThread.getGameState()==mJetBoyThread.STATE_START){
mButton.setText("PLAY!");
mTextView.setVisibility(View.VISIBLE);
mTextView.setText(R.string.helpText);
mJetBoyThread.setGameState(JetBoyThread.STATE_PLAY);
}
//we have entered game play, now we about to start running
else if (mJetBoyThread.getGameState()==mJetBoyThread.STATE_PLAY){
mButton.setVisibility(View.INVISIBLE);
mTextView.setVisibility(View.INVISIBLE);
mTimerView.setVisibility(View.VISIBLE);
mJetBoyThread.setGameState(JetBoyThread.STATE_RUNNING);
}
//this is a retry button
else if (mButtonRetry.equals(v) ){
mTextView.setText(R.string.helpText);
mButton.setText("PLAY!");
mButtonRetry.setVisibility(View.INVISIBLE);
//mButtonRestart.setVisibility(View.INVISIBLE);
mTextView.setVisibility(View.VISIBLE);
mButton.setText("PLAY!");
mButton.setVisibility(View.VISIBLE);
mJetBoyThread.setGameState(JetBoyThread.STATE_PLAY);
}
else
{
Log.d("JB VIEW", "unknown click " + v.getId());
Log.d("JB VIEW", "state is " + mJetBoyThread.mState);
}
}
/**
* Standard override to get key-press events.
*/
@Override
public boolean onKeyDown(int keyCode, KeyEvent msg) {
if (keyCode == 4) super.onKeyDown(keyCode,msg);
return mJetBoyThread.doKeyDown(keyCode, msg);
}
/**
* Standard override for key-up. We actually care about these, so we can
* turn off the engine or stop rotating.
*/
@Override
public boolean onKeyUp(int keyCode, KeyEvent msg) {
return mJetBoyThread.doKeyUp(keyCode, msg);
}
}

File diff suppressed because it is too large Load Diff