Provides a screen to draw pixels to with a basic rendering update loop and accepts user input
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
PixelEngine/src/sig/JavaProjectTemplate.java

77 lines
1.8 KiB

2 years ago
package sig;
import sig.engine.AnimatedSprite;
import sig.engine.Color;
import sig.engine.Font;
import sig.engine.Key;
2 years ago
import sig.engine.Panel;
import sig.engine.Sprite;
import sig.engine.Transform;
import java.awt.event.KeyEvent;
class Player{
AnimatedSprite spr=new AnimatedSprite("player.png",32,32);
double x=200,y=200;
double animationFrame=0;
double animationSpd=2;
}
2 years ago
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);
game.Draw_Line(10,10,35,35,Color.BLACK);
game.Draw_Sprite(450,75,bookSpr);
game.Draw_Sprite(450,75+bookSpr.getHeight(),bookSpr,Transform.VERTICAL);
game.Draw_Animated_Sprite(pl.x,pl.y,pl.spr,pl.animationFrame);
game.Draw_Text(10,40,new sig.engine.String("Hello World!"),Font.PROFONT_12);
game.Draw_Text_Ext(10,52,new sig.engine.String("Hello World 2!"),Font.PROFONT_36,Color.MAGENTA);
game.Fill_Triangle(160,160,190,190,50,250,Color.RED);
}
2 years ago
public static void main(String[] args) {
JavaProjectTemplate gameInstance=new JavaProjectTemplate();
Panel.InitializeEngine(gameInstance);
2 years ago
}
}