java dude.java

dude.java

import java.awt.*;
import java.awt.event.KeyEvent;
import java.util.ArrayList;

import javax.swing.ImageIcon;

public class Dude {
	int x, dx, y,nx,nx2,left, dy;
	Image still,jump,reverse;
	
	int ammo = 10;
	
	ImageIcon s = new ImageIcon("motorbike.png");
	ImageIcon j= new ImageIcon("motorbike.png");
	ImageIcon l = new ImageIcon("motorbikeleft.png");
	
	static ArrayList bullets;
	
	public Dude() {
		x = 75;
		left = 150;
		nx = 0;
		nx2= 685;
		y = 172;
		still = s.getImage();
		bullets = new ArrayList();
	
	}
	
	public Rectangle getBounds()
	{
		return new Rectangle(left,y, 63, 154);
	}  
	
	public static ArrayList getBullets()
	{
		return bullets;
	}
	
	public void fire()
	{
		if (ammo > 0)
		{
		ammo--;
		//The v is from the board class, which corresponds to the character's
		//position when it is jumping, resulting in the bullet being formed 
		//at a higher position when the character is at the peak of its jump
			Bullet z = new Bullet((left + 60), (Board.v + 154/2));
		bullets.add(z);
	}}
	public void move() {
		if (dx != -1){
			if (left + dx <= 150)
				left+=dx;
			else{
		x = x + dx;
		
		nx2= nx2+dx;
			nx = nx + dx;
	}}
		else
	{
		if (left+dx >0)
		left = left + dx;
	}
		}

	public int getX() {
		return x;
	}
	
	public int getLeft(){
		return left;
	}

	public int getnX() {
		return nx;
	}
	
	public int getnX2() {
		return nx2;
	}

	public int getdx() {
		return dx;
	}
	
	public Image getImage() {
		return still;
	}

	public void keyPressed(KeyEvent e) {
		int key = e.getKeyCode();
		if (key == KeyEvent.VK_LEFT)
		{		dx = -1;
		still = l.getImage();		}
		
		if (key == KeyEvent.VK_RIGHT)
			{dx = 1;
		still = s.getImage();	
			}
		
		if (key == KeyEvent.VK_SPACE)
		{
			fire();
		}
		
		if (key == KeyEvent.VK_UP)
			{dy = 1;
			still = j.getImage();
			}			}

	public void keyReleased(KeyEvent e) {
		int key = e.getKeyCode();

		if (key == KeyEvent.VK_LEFT)
			dx = 0;

		if (key == KeyEvent.VK_RIGHT)
			dx = 0;
		
		if (key == KeyEvent.VK_UP)
			{dy = 0;
			still = s.getImage();}
			}
	}

java Enemy.java

Enemy.java

import java.awt.*;

import javax.swing.ImageIcon;

public class Enemy {

	Image img;
	int x, y;
	boolean isAlive = true;
	
	public Enemy(int startX, int startY, String location)
	{
		x = startX;
		y = startY;
		ImageIcon l = new ImageIcon(location);
		img = l.getImage();
	}
	
	public int getX()
	{
		return x;
	}
	public int getY()
	{
		return y;
	}
	public boolean Alive()
	{
		return isAlive;
	}
	public Image getImage()
	{
		return img;
	}
	
	public void move(int dx, int left)
	{
		if (dx == 1 && !((left + dx )< 150))//Added this to only move enemy when character moves forward (not back)
		x = x - dx;
	}

	public Rectangle getBounds()
	{
		return new Rectangle(x,y, 19, 23);
	}
	
}

java Android - google maps v2 - 从字符串/ coor加载地址的任务。

Android - google maps v2 - 从字符串/ coor加载地址的任务。

AddressFromStringTask.java
public class AddressFromStringTask extends AsyncTask<String, Void, android.location.Address> {

    private WeakReference<AddressCallback> mWeakListener;
    private Exception exception;

    public AddressFromStringTask(AddressCallback listener) {
        mWeakListener = new WeakReference<>(listener);
    }

    // Decode image in background.
    @Override protected Address doInBackground(String... params) {
        Geocoder coder = new Geocoder(App.getInstance().getApplicationContext(), Locale.getDefault());

        try {
            ArrayList<android.location.Address> addresses = (ArrayList<android.location.Address>)
                    coder.getFromLocationName(params[0], 1);

            if (addresses != null && addresses.size() > 0) {
                return addresses.get(0);
            }
            exception = new IOException("No valid locations found for that address");
        } catch (IOException e) {
            exception = e;
        }
        return null;
    }

    @Override protected void onPostExecute(Address address) {
        AddressCallback listener = mWeakListener.get();
        if (listener != null) {
            if (exception == null){
                listener.onLoad(address);
            } else{
                listener.onError(exception);
            }
        }
    }
}
AddressFromLocationTask.java
public class AddressFromLocationTask extends AsyncTask<LatLng, Void, android.location.Address> {

    private WeakReference<AddressCallback> mWeakCallback;
    private Exception exception;

    public AddressFromLocationTask(AddressCallback callback) {
        mWeakCallback = new WeakReference<>(callback);
    }

    // Decode image in background.
    @Override protected android.location.Address doInBackground(LatLng... params) {
        Geocoder coder = new Geocoder(App.getInstance().getApplicationContext(), Locale.getDefault());

        try {
            LatLng latLng = params[0];
            ArrayList<android.location.Address> addresses = (ArrayList<android.location.Address>)
                    coder.getFromLocation(latLng.latitude, latLng.longitude, 1);

            if (addresses != null && addresses.size() > 0) {
                return addresses.get(0);
            }
            exception = new IOException("No valid locations found for that address");
        } catch (IOException e) {
            exception = e;
        }
        return null;
    }

    @Override protected void onPostExecute(android.location.Address address) {
        AddressCallback callback = mWeakCallback.get();
        if (callback != null) {
            if (exception == null){
                callback.onLoad(address);
            } else{
                callback.onError(exception);
            }
        }
    }
}
AddressCallback.java
public interface AddressCallback {
    void onLoad(android.location.Address address);
    void onError(Exception e);
}

java Android - google maps v2 - 从字符串/ coor加载地址的任务。

Android - google maps v2 - 从字符串/ coor加载地址的任务。

AddressFromStringTask.java
public class AddressFromStringTask extends AsyncTask<String, Void, android.location.Address> {

    private WeakReference<AddressCallback> mWeakListener;
    private Exception exception;

    public AddressFromStringTask(AddressCallback listener) {
        mWeakListener = new WeakReference<>(listener);
    }

    // Decode image in background.
    @Override protected Address doInBackground(String... params) {
        Geocoder coder = new Geocoder(App.getInstance().getApplicationContext(), Locale.getDefault());

        try {
            ArrayList<android.location.Address> addresses = (ArrayList<android.location.Address>)
                    coder.getFromLocationName(params[0], 1);

            if (addresses != null && addresses.size() > 0) {
                return addresses.get(0);
            }
            exception = new IOException("No valid locations found for that address");
        } catch (IOException e) {
            exception = e;
        }
        return null;
    }

    @Override protected void onPostExecute(Address address) {
        AddressCallback listener = mWeakListener.get();
        if (listener != null) {
            if (exception == null){
                listener.onLoad(address);
            } else{
                listener.onError(exception);
            }
        }
    }
}
AddressFromLocationTask.java
public class AddressFromLocationTask extends AsyncTask<LatLng, Void, android.location.Address> {

    private WeakReference<AddressCallback> mWeakCallback;
    private Exception exception;

    public AddressFromLocationTask(AddressCallback callback) {
        mWeakCallback = new WeakReference<>(callback);
    }

    // Decode image in background.
    @Override protected android.location.Address doInBackground(LatLng... params) {
        Geocoder coder = new Geocoder(App.getInstance().getApplicationContext(), Locale.getDefault());

        try {
            LatLng latLng = params[0];
            ArrayList<android.location.Address> addresses = (ArrayList<android.location.Address>)
                    coder.getFromLocation(latLng.latitude, latLng.longitude, 1);

            if (addresses != null && addresses.size() > 0) {
                return addresses.get(0);
            }
            exception = new IOException("No valid locations found for that address");
        } catch (IOException e) {
            exception = e;
        }
        return null;
    }

    @Override protected void onPostExecute(android.location.Address address) {
        AddressCallback callback = mWeakCallback.get();
        if (callback != null) {
            if (exception == null){
                callback.onLoad(address);
            } else{
                callback.onError(exception);
            }
        }
    }
}
AddressCallback.java
public interface AddressCallback {
    void onLoad(android.location.Address address);
    void onError(Exception e);
}

java Android - google maps v2 - 从字符串/ coor加载地址的任务。

Android - google maps v2 - 从字符串/ coor加载地址的任务。

AddressFromStringTask.java
public class AddressFromStringTask extends AsyncTask<String, Void, android.location.Address> {

    private WeakReference<AddressCallback> mWeakListener;
    private Exception exception;

    public AddressFromStringTask(AddressCallback listener) {
        mWeakListener = new WeakReference<>(listener);
    }

    // Decode image in background.
    @Override protected Address doInBackground(String... params) {
        Geocoder coder = new Geocoder(App.getInstance().getApplicationContext(), Locale.getDefault());

        try {
            ArrayList<android.location.Address> addresses = (ArrayList<android.location.Address>)
                    coder.getFromLocationName(params[0], 1);

            if (addresses != null && addresses.size() > 0) {
                return addresses.get(0);
            }
            exception = new IOException("No valid locations found for that address");
        } catch (IOException e) {
            exception = e;
        }
        return null;
    }

    @Override protected void onPostExecute(Address address) {
        AddressCallback listener = mWeakListener.get();
        if (listener != null) {
            if (exception == null){
                listener.onLoad(address);
            } else{
                listener.onError(exception);
            }
        }
    }
}
AddressFromLocationTask.java
public class AddressFromLocationTask extends AsyncTask<LatLng, Void, android.location.Address> {

    private WeakReference<AddressCallback> mWeakCallback;
    private Exception exception;

    public AddressFromLocationTask(AddressCallback callback) {
        mWeakCallback = new WeakReference<>(callback);
    }

    // Decode image in background.
    @Override protected android.location.Address doInBackground(LatLng... params) {
        Geocoder coder = new Geocoder(App.getInstance().getApplicationContext(), Locale.getDefault());

        try {
            LatLng latLng = params[0];
            ArrayList<android.location.Address> addresses = (ArrayList<android.location.Address>)
                    coder.getFromLocation(latLng.latitude, latLng.longitude, 1);

            if (addresses != null && addresses.size() > 0) {
                return addresses.get(0);
            }
            exception = new IOException("No valid locations found for that address");
        } catch (IOException e) {
            exception = e;
        }
        return null;
    }

    @Override protected void onPostExecute(android.location.Address address) {
        AddressCallback callback = mWeakCallback.get();
        if (callback != null) {
            if (exception == null){
                callback.onLoad(address);
            } else{
                callback.onError(exception);
            }
        }
    }
}
AddressCallback.java
public interface AddressCallback {
    void onLoad(android.location.Address address);
    void onError(Exception e);
}

java Android - google maps v2 - 从字符串/ coor加载地址的任务。

Android - google maps v2 - 从字符串/ coor加载地址的任务。

AddressFromStringTask.java
public class AddressFromStringTask extends AsyncTask<String, Void, android.location.Address> {

    private WeakReference<AddressCallback> mWeakListener;
    private Exception exception;

    public AddressFromStringTask(AddressCallback listener) {
        mWeakListener = new WeakReference<>(listener);
    }

    // Decode image in background.
    @Override protected Address doInBackground(String... params) {
        Geocoder coder = new Geocoder(App.getInstance().getApplicationContext(), Locale.getDefault());

        try {
            ArrayList<android.location.Address> addresses = (ArrayList<android.location.Address>)
                    coder.getFromLocationName(params[0], 1);

            if (addresses != null && addresses.size() > 0) {
                return addresses.get(0);
            }
            exception = new IOException("No valid locations found for that address");
        } catch (IOException e) {
            exception = e;
        }
        return null;
    }

    @Override protected void onPostExecute(Address address) {
        AddressCallback listener = mWeakListener.get();
        if (listener != null) {
            if (exception == null){
                listener.onLoad(address);
            } else{
                listener.onError(exception);
            }
        }
    }
}
AddressFromLocationTask.java
public class AddressFromLocationTask extends AsyncTask<LatLng, Void, android.location.Address> {

    private WeakReference<AddressCallback> mWeakCallback;
    private Exception exception;

    public AddressFromLocationTask(AddressCallback callback) {
        mWeakCallback = new WeakReference<>(callback);
    }

    // Decode image in background.
    @Override protected android.location.Address doInBackground(LatLng... params) {
        Geocoder coder = new Geocoder(App.getInstance().getApplicationContext(), Locale.getDefault());

        try {
            LatLng latLng = params[0];
            ArrayList<android.location.Address> addresses = (ArrayList<android.location.Address>)
                    coder.getFromLocation(latLng.latitude, latLng.longitude, 1);

            if (addresses != null && addresses.size() > 0) {
                return addresses.get(0);
            }
            exception = new IOException("No valid locations found for that address");
        } catch (IOException e) {
            exception = e;
        }
        return null;
    }

    @Override protected void onPostExecute(android.location.Address address) {
        AddressCallback callback = mWeakCallback.get();
        if (callback != null) {
            if (exception == null){
                callback.onLoad(address);
            } else{
                callback.onError(exception);
            }
        }
    }
}
AddressCallback.java
public interface AddressCallback {
    void onLoad(android.location.Address address);
    void onError(Exception e);
}

java Android - google maps v2 - 从字符串/ coor加载地址的任务。

Android - google maps v2 - 从字符串/ coor加载地址的任务。

AddressFromStringTask.java
public class AddressFromStringTask extends AsyncTask<String, Void, android.location.Address> {

    private WeakReference<AddressCallback> mWeakListener;
    private Exception exception;

    public AddressFromStringTask(AddressCallback listener) {
        mWeakListener = new WeakReference<>(listener);
    }

    // Decode image in background.
    @Override protected Address doInBackground(String... params) {
        Geocoder coder = new Geocoder(App.getInstance().getApplicationContext(), Locale.getDefault());

        try {
            ArrayList<android.location.Address> addresses = (ArrayList<android.location.Address>)
                    coder.getFromLocationName(params[0], 1);

            if (addresses != null && addresses.size() > 0) {
                return addresses.get(0);
            }
            exception = new IOException("No valid locations found for that address");
        } catch (IOException e) {
            exception = e;
        }
        return null;
    }

    @Override protected void onPostExecute(Address address) {
        AddressCallback listener = mWeakListener.get();
        if (listener != null) {
            if (exception == null){
                listener.onLoad(address);
            } else{
                listener.onError(exception);
            }
        }
    }
}
AddressFromLocationTask.java
public class AddressFromLocationTask extends AsyncTask<LatLng, Void, android.location.Address> {

    private WeakReference<AddressCallback> mWeakCallback;
    private Exception exception;

    public AddressFromLocationTask(AddressCallback callback) {
        mWeakCallback = new WeakReference<>(callback);
    }

    // Decode image in background.
    @Override protected android.location.Address doInBackground(LatLng... params) {
        Geocoder coder = new Geocoder(App.getInstance().getApplicationContext(), Locale.getDefault());

        try {
            LatLng latLng = params[0];
            ArrayList<android.location.Address> addresses = (ArrayList<android.location.Address>)
                    coder.getFromLocation(latLng.latitude, latLng.longitude, 1);

            if (addresses != null && addresses.size() > 0) {
                return addresses.get(0);
            }
            exception = new IOException("No valid locations found for that address");
        } catch (IOException e) {
            exception = e;
        }
        return null;
    }

    @Override protected void onPostExecute(android.location.Address address) {
        AddressCallback callback = mWeakCallback.get();
        if (callback != null) {
            if (exception == null){
                callback.onLoad(address);
            } else{
                callback.onError(exception);
            }
        }
    }
}
AddressCallback.java
public interface AddressCallback {
    void onLoad(android.location.Address address);
    void onError(Exception e);
}

java Android - google maps v2 - 从字符串/ coor加载地址的任务。

Android - google maps v2 - 从字符串/ coor加载地址的任务。

AddressFromStringTask.java
public class AddressFromStringTask extends AsyncTask<String, Void, android.location.Address> {

    private WeakReference<AddressCallback> mWeakListener;
    private Exception exception;

    public AddressFromStringTask(AddressCallback listener) {
        mWeakListener = new WeakReference<>(listener);
    }

    // Decode image in background.
    @Override protected Address doInBackground(String... params) {
        Geocoder coder = new Geocoder(App.getInstance().getApplicationContext(), Locale.getDefault());

        try {
            ArrayList<android.location.Address> addresses = (ArrayList<android.location.Address>)
                    coder.getFromLocationName(params[0], 1);

            if (addresses != null && addresses.size() > 0) {
                return addresses.get(0);
            }
            exception = new IOException("No valid locations found for that address");
        } catch (IOException e) {
            exception = e;
        }
        return null;
    }

    @Override protected void onPostExecute(Address address) {
        AddressCallback listener = mWeakListener.get();
        if (listener != null) {
            if (exception == null){
                listener.onLoad(address);
            } else{
                listener.onError(exception);
            }
        }
    }
}
AddressFromLocationTask.java
public class AddressFromLocationTask extends AsyncTask<LatLng, Void, android.location.Address> {

    private WeakReference<AddressCallback> mWeakCallback;
    private Exception exception;

    public AddressFromLocationTask(AddressCallback callback) {
        mWeakCallback = new WeakReference<>(callback);
    }

    // Decode image in background.
    @Override protected android.location.Address doInBackground(LatLng... params) {
        Geocoder coder = new Geocoder(App.getInstance().getApplicationContext(), Locale.getDefault());

        try {
            LatLng latLng = params[0];
            ArrayList<android.location.Address> addresses = (ArrayList<android.location.Address>)
                    coder.getFromLocation(latLng.latitude, latLng.longitude, 1);

            if (addresses != null && addresses.size() > 0) {
                return addresses.get(0);
            }
            exception = new IOException("No valid locations found for that address");
        } catch (IOException e) {
            exception = e;
        }
        return null;
    }

    @Override protected void onPostExecute(android.location.Address address) {
        AddressCallback callback = mWeakCallback.get();
        if (callback != null) {
            if (exception == null){
                callback.onLoad(address);
            } else{
                callback.onError(exception);
            }
        }
    }
}
AddressCallback.java
public interface AddressCallback {
    void onLoad(android.location.Address address);
    void onError(Exception e);
}

java Android - google maps v2 - 从字符串/ coor加载地址的任务。

Android - google maps v2 - 从字符串/ coor加载地址的任务。

AddressFromStringTask.java
public class AddressFromStringTask extends AsyncTask<String, Void, android.location.Address> {

    private WeakReference<AddressCallback> mWeakListener;
    private Exception exception;

    public AddressFromStringTask(AddressCallback listener) {
        mWeakListener = new WeakReference<>(listener);
    }

    // Decode image in background.
    @Override protected Address doInBackground(String... params) {
        Geocoder coder = new Geocoder(App.getInstance().getApplicationContext(), Locale.getDefault());

        try {
            ArrayList<android.location.Address> addresses = (ArrayList<android.location.Address>)
                    coder.getFromLocationName(params[0], 1);

            if (addresses != null && addresses.size() > 0) {
                return addresses.get(0);
            }
            exception = new IOException("No valid locations found for that address");
        } catch (IOException e) {
            exception = e;
        }
        return null;
    }

    @Override protected void onPostExecute(Address address) {
        AddressCallback listener = mWeakListener.get();
        if (listener != null) {
            if (exception == null){
                listener.onLoad(address);
            } else{
                listener.onError(exception);
            }
        }
    }
}
AddressFromLocationTask.java
public class AddressFromLocationTask extends AsyncTask<LatLng, Void, android.location.Address> {

    private WeakReference<AddressCallback> mWeakCallback;
    private Exception exception;

    public AddressFromLocationTask(AddressCallback callback) {
        mWeakCallback = new WeakReference<>(callback);
    }

    // Decode image in background.
    @Override protected android.location.Address doInBackground(LatLng... params) {
        Geocoder coder = new Geocoder(App.getInstance().getApplicationContext(), Locale.getDefault());

        try {
            LatLng latLng = params[0];
            ArrayList<android.location.Address> addresses = (ArrayList<android.location.Address>)
                    coder.getFromLocation(latLng.latitude, latLng.longitude, 1);

            if (addresses != null && addresses.size() > 0) {
                return addresses.get(0);
            }
            exception = new IOException("No valid locations found for that address");
        } catch (IOException e) {
            exception = e;
        }
        return null;
    }

    @Override protected void onPostExecute(android.location.Address address) {
        AddressCallback callback = mWeakCallback.get();
        if (callback != null) {
            if (exception == null){
                callback.onLoad(address);
            } else{
                callback.onError(exception);
            }
        }
    }
}
AddressCallback.java
public interface AddressCallback {
    void onLoad(android.location.Address address);
    void onError(Exception e);
}

java Android - google maps v2 - 从字符串/ coor加载地址的任务。

Android - google maps v2 - 从字符串/ coor加载地址的任务。

AddressFromStringTask.java
public class AddressFromStringTask extends AsyncTask<String, Void, android.location.Address> {

    private WeakReference<AddressCallback> mWeakListener;
    private Exception exception;

    public AddressFromStringTask(AddressCallback listener) {
        mWeakListener = new WeakReference<>(listener);
    }

    // Decode image in background.
    @Override protected Address doInBackground(String... params) {
        Geocoder coder = new Geocoder(App.getInstance().getApplicationContext(), Locale.getDefault());

        try {
            ArrayList<android.location.Address> addresses = (ArrayList<android.location.Address>)
                    coder.getFromLocationName(params[0], 1);

            if (addresses != null && addresses.size() > 0) {
                return addresses.get(0);
            }
            exception = new IOException("No valid locations found for that address");
        } catch (IOException e) {
            exception = e;
        }
        return null;
    }

    @Override protected void onPostExecute(Address address) {
        AddressCallback listener = mWeakListener.get();
        if (listener != null) {
            if (exception == null){
                listener.onLoad(address);
            } else{
                listener.onError(exception);
            }
        }
    }
}
AddressFromLocationTask.java
public class AddressFromLocationTask extends AsyncTask<LatLng, Void, android.location.Address> {

    private WeakReference<AddressCallback> mWeakCallback;
    private Exception exception;

    public AddressFromLocationTask(AddressCallback callback) {
        mWeakCallback = new WeakReference<>(callback);
    }

    // Decode image in background.
    @Override protected android.location.Address doInBackground(LatLng... params) {
        Geocoder coder = new Geocoder(App.getInstance().getApplicationContext(), Locale.getDefault());

        try {
            LatLng latLng = params[0];
            ArrayList<android.location.Address> addresses = (ArrayList<android.location.Address>)
                    coder.getFromLocation(latLng.latitude, latLng.longitude, 1);

            if (addresses != null && addresses.size() > 0) {
                return addresses.get(0);
            }
            exception = new IOException("No valid locations found for that address");
        } catch (IOException e) {
            exception = e;
        }
        return null;
    }

    @Override protected void onPostExecute(android.location.Address address) {
        AddressCallback callback = mWeakCallback.get();
        if (callback != null) {
            if (exception == null){
                callback.onLoad(address);
            } else{
                callback.onError(exception);
            }
        }
    }
}
AddressCallback.java
public interface AddressCallback {
    void onLoad(android.location.Address address);
    void onError(Exception e);
}