|
|
|
package sig;
|
|
|
|
|
|
|
|
import sig.engine.AnimatedSprite;
|
|
|
|
import sig.engine.Color;
|
|
|
|
import sig.engine.Font;
|
|
|
|
import sig.engine.Key;
|
|
|
|
import sig.engine.Mouse;
|
|
|
|
import sig.engine.Panel;
|
|
|
|
import sig.engine.Point;
|
|
|
|
import sig.engine.Sprite;
|
|
|
|
import sig.engine.Transform;
|
|
|
|
|
|
|
|
import java.awt.event.KeyEvent;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
class Player{
|
|
|
|
AnimatedSprite spr=new AnimatedSprite("player.png",32,32);
|
|
|
|
double x=200,y=200;
|
|
|
|
|
|
|
|
double animationFrame=0;
|
|
|
|
double animationSpd=2;
|
|
|
|
}
|
|
|
|
|
|
|
|
public class JavaProjectTemplate {
|
|
|
|
public static final String PROGRAM_NAME="Sig's Java Project Template";
|
|
|
|
public static int WINDOW_WIDTH=1280;
|
|
|
|
public static int WINDOW_HEIGHT=720;
|
|
|
|
public static Panel game;
|
|
|
|
|
|
|
|
Player pl = new Player();
|
|
|
|
Sprite bookSpr = new Sprite("book.png");
|
|
|
|
|
|
|
|
JavaProjectTemplate(){
|
|
|
|
//Initialize your game here.
|
|
|
|
}
|
|
|
|
|
|
|
|
public void updateGame(double fElapsedTime) {
|
|
|
|
//Put game update logic in here.
|
|
|
|
|
|
|
|
pl.animationFrame+=pl.animationSpd*fElapsedTime;
|
|
|
|
|
|
|
|
if (Key.isKeyHeld(KeyEvent.VK_A)) {
|
|
|
|
pl.x-=200*fElapsedTime;
|
|
|
|
}
|
|
|
|
if (Key.isKeyHeld(KeyEvent.VK_D)) {
|
|
|
|
pl.x+=200*fElapsedTime;
|
|
|
|
}
|
|
|
|
if (Key.isKeyHeld(KeyEvent.VK_W)) {
|
|
|
|
pl.y-=200*fElapsedTime;
|
|
|
|
}
|
|
|
|
if (Key.isKeyHeld(KeyEvent.VK_S)) {
|
|
|
|
pl.y+=200*fElapsedTime;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void drawGame() {
|
|
|
|
//Put rendering logic in here.
|
|
|
|
|
|
|
|
game.Clear(Color.BRIGHT_BLUE);
|
|
|
|
|
|
|
|
game.Draw(100,20,Color.BLACK); //That's not a dead pixel, it's a black one!
|
|
|
|
game.Draw_Line(10,10,35,35,Color.BLACK); //Line Drawing
|
|
|
|
|
|
|
|
game.Draw_Sprite(450,75,bookSpr,Color.GREEN); //Sprite drawing (with green tint)
|
|
|
|
game.Draw_Sprite(450,75+bookSpr.getHeight(),bookSpr,Transform.VERTICAL); //Sprite drawing with vertical flip
|
|
|
|
|
|
|
|
game.Draw_Animated_Sprite(pl.x,pl.y,pl.spr,pl.animationFrame); //Animated Sprite drawing
|
|
|
|
|
|
|
|
game.Draw_Text(10,40,"Mouse X: "+Mouse.x+" Mouse Y:"+Mouse.y,Font.PROFONT_12); //Draw Mouse coordinates in tiny font
|
|
|
|
game.Draw_Text_Ext(10,52,"Hello World 2!",Font.PROFONT_36,Color.MAGENTA); //Draw in larger font
|
|
|
|
|
|
|
|
game.Fill_Triangle(160,160,190,190,50,250,new Color(255,0,0,150)); //Draw a colored triangle
|
|
|
|
|
|
|
|
game.FillTexturedTriangle( //Define the uv tex coords of a triangle and a sprite and draw a texture onto it
|
|
|
|
List.of(
|
|
|
|
new Point<Double>(400d,400d),
|
|
|
|
new Point<Double>(400d,550d),
|
|
|
|
new Point<Double>(550d,550d)
|
|
|
|
),
|
|
|
|
List.of(
|
|
|
|
new Point<Double>(0d,0d),
|
|
|
|
new Point<Double>(0d,1d),
|
|
|
|
new Point<Double>(1d,1d)
|
|
|
|
)
|
|
|
|
,
|
|
|
|
List.of(
|
|
|
|
new Color(0,0,0,0),
|
|
|
|
Color.WHITE,
|
|
|
|
Color.RED
|
|
|
|
), bookSpr);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void main(String[] args) {
|
|
|
|
JavaProjectTemplate gameInstance=new JavaProjectTemplate();
|
|
|
|
Panel.InitializeEngine(gameInstance);
|
|
|
|
}
|
|
|
|
}
|