Initial Version
This commit is contained in:
57
src/com/droidquest/decorations/Arrow.java
Normal file
57
src/com/droidquest/decorations/Arrow.java
Normal file
@@ -0,0 +1,57 @@
|
||||
package com.droidquest.decorations;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics;
|
||||
import java.io.Serializable;
|
||||
|
||||
public class Arrow implements Serializable
|
||||
{
|
||||
public static int DIR_UP = 0;
|
||||
public static int DIR_RIGHT = 1;
|
||||
public static int DIR_DOWN = 2;
|
||||
public static int DIR_LEFT = 3;
|
||||
public int direction;
|
||||
public int length;
|
||||
public int x;
|
||||
public int y;
|
||||
public Color color;
|
||||
|
||||
public Arrow() {}
|
||||
|
||||
public Arrow(int X, int Y, int dir, int len, Color c)
|
||||
{
|
||||
x=X; y=Y;
|
||||
direction = dir;
|
||||
length = len;
|
||||
color = c;
|
||||
}
|
||||
|
||||
public void Draw(Graphics g)
|
||||
{
|
||||
g.setColor(color);
|
||||
switch(direction)
|
||||
{
|
||||
case 0:
|
||||
g.drawLine(x,y,x-8,y+8);
|
||||
g.drawLine(x,y,x+8,y+8);
|
||||
g.drawLine(x,y,x,y+length);
|
||||
break;
|
||||
case 1:
|
||||
g.drawLine(x,y,x-8,y-8);
|
||||
g.drawLine(x,y,x-8,y+8);
|
||||
g.drawLine(x,y,x-length,y);
|
||||
break;
|
||||
case 2:
|
||||
g.drawLine(x,y,x-8,y-8);
|
||||
g.drawLine(x,y,x+8,y-8);
|
||||
g.drawLine(x,y,x,y-length);
|
||||
break;
|
||||
case 3:
|
||||
g.drawLine(x,y,x+8,y-8);
|
||||
g.drawLine(x,y,x+8,y+8);
|
||||
g.drawLine(x,y,x+length,y);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
132
src/com/droidquest/decorations/Graphix.java
Normal file
132
src/com/droidquest/decorations/Graphix.java
Normal file
@@ -0,0 +1,132 @@
|
||||
package com.droidquest.decorations;
|
||||
|
||||
import java.awt.Graphics;
|
||||
import java.io.Serializable;
|
||||
|
||||
import javax.swing.ImageIcon;
|
||||
|
||||
import com.droidquest.RoomDisplay;
|
||||
|
||||
public class Graphix implements Serializable
|
||||
{
|
||||
public String[] filenames;
|
||||
transient protected ImageIcon[] icons; // Array of images for this item
|
||||
transient ImageIcon icon;
|
||||
int animationState;
|
||||
public int x; // Current position
|
||||
int y;
|
||||
int behavior; // Overall behavior (SIT, CYCLE, BOUNCE)
|
||||
int current=1; // Current behavior; 1=move forward, -1=move backward
|
||||
int dx, dy; // Direction of "forward"
|
||||
public int count;
|
||||
int length; // Number of times the Graphix moves forward
|
||||
public static int SIT=0;
|
||||
public static int CYCLE=1;
|
||||
public static int BOUNCE=2;
|
||||
|
||||
public Graphix() {}
|
||||
|
||||
public Graphix(int X, int Y)
|
||||
{
|
||||
x=X; y=Y;
|
||||
GenerateIcons();
|
||||
}
|
||||
|
||||
public Graphix(String file, int X, int Y)
|
||||
{
|
||||
filenames = new String[1];
|
||||
filenames[0] = new String(file);
|
||||
behavior = SIT;
|
||||
x=X; y=Y;
|
||||
GenerateIcons();
|
||||
}
|
||||
|
||||
public Graphix(String[] files, int X, int Y)
|
||||
{
|
||||
x=X; y=Y;
|
||||
filenames = files;
|
||||
behavior = SIT;
|
||||
GenerateIcons();
|
||||
}
|
||||
|
||||
public Graphix(String file, int X, int Y, int b, int DX, int DY, int L)
|
||||
{
|
||||
filenames = new String[1];
|
||||
filenames[0] = new String(file);
|
||||
x=X; y=Y;
|
||||
behavior = b;
|
||||
dx=DX; dy=DY;
|
||||
length = L;
|
||||
GenerateIcons();
|
||||
}
|
||||
|
||||
public Graphix(String[] files, int X, int Y, int b, int DX, int DY, int L)
|
||||
{
|
||||
filenames = files;
|
||||
x=X; y=Y;
|
||||
behavior = b;
|
||||
dx=DX; dy=DY;
|
||||
length = L;
|
||||
GenerateIcons();
|
||||
}
|
||||
|
||||
public void GenerateIcons()
|
||||
{
|
||||
int numfiles = filenames.length;
|
||||
icons = new ImageIcon[numfiles];
|
||||
for (int a=0; a< numfiles; a++)
|
||||
icons[a] = new ImageIcon("images/"+ filenames[a]);
|
||||
icon = icons[0];
|
||||
}
|
||||
|
||||
public void Draw(Graphics g, RoomDisplay rd)
|
||||
{
|
||||
if (icon != null)
|
||||
g.drawImage(icon.getImage(), x, y, rd);
|
||||
}
|
||||
|
||||
public void Animate()
|
||||
{
|
||||
int numfiles = filenames.length;
|
||||
animationState++;
|
||||
if (animationState==numfiles)
|
||||
animationState=0;
|
||||
icon = icons[animationState];
|
||||
if (behavior==CYCLE)
|
||||
{
|
||||
if (count==length)
|
||||
{
|
||||
x-=dx*length;
|
||||
y-=dy*length;
|
||||
count=0;
|
||||
}
|
||||
else
|
||||
{
|
||||
x+=dx; y+=dy;
|
||||
count++;
|
||||
}
|
||||
}
|
||||
if (behavior==BOUNCE)
|
||||
if (current==1)
|
||||
{
|
||||
if (count==length)
|
||||
current=-1;
|
||||
else
|
||||
{
|
||||
x+=dx; y+=dy;
|
||||
count++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (count==0)
|
||||
current=1;
|
||||
else
|
||||
{
|
||||
x-=dx; y-=dy;
|
||||
count--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
44
src/com/droidquest/decorations/Spark.java
Normal file
44
src/com/droidquest/decorations/Spark.java
Normal file
@@ -0,0 +1,44 @@
|
||||
package com.droidquest.decorations;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics;
|
||||
import java.io.Serializable;
|
||||
|
||||
import com.droidquest.Room;
|
||||
|
||||
public class Spark implements Serializable
|
||||
{
|
||||
public int x,y;
|
||||
public int dx,dy;
|
||||
public int age;
|
||||
public Room room;
|
||||
|
||||
public Spark() {}
|
||||
|
||||
public Spark(int X, int Y, int Dx, int Dy, Room r)
|
||||
{
|
||||
x=X; y=Y;
|
||||
dx = Dx; dy= Dy;
|
||||
room = r;
|
||||
age=0;
|
||||
}
|
||||
|
||||
public void Age()
|
||||
{
|
||||
x += dx; y+= dy;
|
||||
if (x<0 || x>560 || y<0 || y>384) room=null;
|
||||
age++;
|
||||
}
|
||||
|
||||
public void Draw(Graphics g)
|
||||
{
|
||||
if (age<2)
|
||||
g.setColor(Color.white);
|
||||
else if (age>=2 && age<4)
|
||||
g.setColor(Color.yellow);
|
||||
else
|
||||
g.setColor(Color.red);
|
||||
g.fillRect(x,y,2,2);
|
||||
}
|
||||
|
||||
}
|
||||
27
src/com/droidquest/decorations/TextBox.java
Normal file
27
src/com/droidquest/decorations/TextBox.java
Normal file
@@ -0,0 +1,27 @@
|
||||
package com.droidquest.decorations;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class TextBox implements Serializable
|
||||
{
|
||||
public String textString;
|
||||
public int x; // Position
|
||||
public int y;
|
||||
public int width; // Size
|
||||
|
||||
public TextBox() {}
|
||||
|
||||
public TextBox(String t, int X, int Y, int W)
|
||||
{
|
||||
textString = t;
|
||||
x=X; y=Y; width=W;
|
||||
}
|
||||
|
||||
public TextBox(String t, int X, int Y)
|
||||
{
|
||||
textString = t;
|
||||
x=X; y=Y;
|
||||
width=500;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user