Main.java
package com.herocraftonline.rightlegred.minescroller;
import java.awt.Font;
import java.awt.Graphics;
import javax.swing.*;
import com.herocraftonline.rightlegred.minescroller.player.Player;
public class Main extends JFrame{
public Main(){
setTitle("MineScroller");
setSize(500,500);
setVisible(true);
setFont(new Font("Minecraft Regular",Font.PLAIN,20));
}
public void paint(Graphics g){
}
public static void main(String[]beans){
Main m = new Main();
Player p = new Player(60, 60, 3);
m.paint(p.getGraphics());
}
}
Player.java
package com.herocraftonline.rightlegred.minescroller.player;
import java.awt.Graphics;
import java.awt.Image;
import javax.swing.JComponent;
public class Player extends JComponent{
private int x, y;
private int width, height = 40;
private Image img;
private int Health;
public Player(int x,int y,int Health) {
this.x = x;
this.y = y;
this.Health = Health;
}
public void paint(Graphics g){
g.drawRect(x, y, width, height);
}
}
Player is what I'm trying to draw, but I can't seem to get it to work. I get no errors, while I do get a see through screen which isn't as pleasing as the player would be.
As well as the above, I must ask another question -
Fluid movement, how can I achieve this in my game? I know doing y++; won't give you fluid movement and that I'm going to have to use velocity to create this. Would it be something like this:
int yVel; int xVel; y += yVel; x += xVel;
I'm aiming to create smooth movement, which is pleasing to the eye and generally makes the game nicer to play. I've posted this thread here instead of Java because this is for a game I'm attempting to make. So I assumed it would probably be best to post this here. Sorry if this is wrong.
Please remember this is my first game. Please don't be harsh and yes, I'm attempting to copy the style of Minecraft. But in 2D side scroller. While this is a bad thing to do, this game is intended to help me get my foot in the door, nothing else.
This post has been edited by NemY: 09 April 2011 - 03:48 AM

New Topic/Question
Reply



MultiQuote












|