1

Can a good coder help me PLEASE?

GetVape's Avatar GetVape12/2/13 8:47 pm
1 emeralds 112 2
12/2/2013 8:48 pm
GetVape's Avatar GetVape
Can a good coder help me I am trying to make a 2d game and my 2 lines of code
private void start() { and

public synchronized void start() {
Posted by GetVape's Avatar
GetVape
Level 11 : Journeyman Modder
12

Create an account or sign in to comment.

2

1
12/02/2013 8:48 pm
Level 11 : Journeyman Modder
GetVape
GetVape's Avatar
if you need my full line of code is

package ca.yossie.pixelmine;

import java.awt.BorderLayout;
import java.awt.Canvas;
import java.awt.Dimension;

import javax.swing.JFrame;

public class pixelmine2DGame extends Canvas implements Runnable{

private static final long serialVersionUID = 1L;

public static final int WIDTH = 160;
public static final int HEIGHT = WIDTH / 12*9;
public static final int SCALE = 3;
public static final String NAME = "Pixelmine2D";

private JFrame frame;

public boolean running = false;

public pixelmine2DGame() {
setMinimumSize(new Dimension(WIDTH*SCALE, HEIGHT*SCALE));
setMaximumSize(new Dimension(WIDTH*SCALE, HEIGHT*SCALE));
setPreferredSize(new Dimension(WIDTH*SCALE, HEIGHT*SCALE));
frame = new JFrame(NAME);

frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setLayout(new BorderLayout());

frame.add(this, BorderLayout.CENTER);
frame.pack();

frame.setResizable(false);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}

public synchronized void start() {
running = true;
new Thread(this).start();

}

public synchronized void stop() {
running = false;

}

public void run() {
long lastTime = System.nanoTime();
double nsPerTick = 1000000000D/60D;

int ticks = 0;
int frames = 0;

long lastTimer = System.currentTimeMillis();
double delta = 0;
while(running) {
long now = System.nanoTime();
delta += (now = lastTime) / nsPerTick;
lastTime = now;
boolean shouldRender=false;

while (delta >= 1) {
ticks++;
tick();
delta -= 1;
shouldRender = true;
}
if (shouldRender) {
frames++;
render();
}

if (System.currentTimeMillis() - lastTimer >= 1000) {
lastTimer +=1000;
System.out.println(frames +","+ ticks);

}
}
}

public void tick() {

}

public void render() {

}

public static void main(String[] args) {
new pixelmine2DGame().start();

}
private void start() {

}
}
1
12/02/2013 8:47 pm
Level 11 : Journeyman Modder
GetVape
GetVape's Avatar
can anyone please help
Planet Minecraft

Website

© 2010 - 2024
www.planetminecraft.com

Welcome