Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » not showing the background image(error line 31)
not showing the background image [message #1730024] Thu, 21 April 2016 02:48 Go to next message
anthony rodelo is currently offline anthony rodeloFriend
Messages: 1
Registered: April 2016
Junior Member
HI I'm working a project before school starts in june to reduce my tuition by 5k so I decided to do this tutorial on youtube as my project but
I copied every thing that the guy said to write but on his page he is not getting the same error I do not no why I am getting this error i tried to run in debug mode to show the background picture but I think this error is stopping it can you help please its line 30 setVector
package GameState;

import TileMap.Background;
import java.awt.*;
import java.awt.event.KeyEvent;

public class MenuState  extends GameState {
	
	private Background bg;
	
	private int currentChoice = 0;
	private String[] options = {
			"Start",
			"Help",
			"Quit",
			
	};
	
	private Color titleColor;
	private Font titleFont;
	
	private Font font;

	public MenuState(GameStateManager gsm) {
		this.gsm = gsm;
		
		try {
			
			bg = new Background("/Backgrounds/menubg.gif", 1);
			bg.setVector(-0.1, 0);
			
			titleColor = new Color(120, 0, 0);
			titleFont = new Font("Century Gothic", font.PLAIN, 28);
			font = new Font("Arial", Font.PLAIN, 12);
			}
		
		catch(Exception e){
			e.printStackTrace();
			
		}
	}
	
	public void init(){}
	public void update(){
		bg.update();
	}
	public void draw(Graphics2D g){
		// draw bg
		bg.draw(g);
		
		// draw title
		g.setColor(titleColor);
		g.setFont(titleFont);
		g.drawString("Dragon Tale", 80, 70);
		
		// draw menu options
		g.setFont(font);
		for(int i = 0; i < options.length; i++) {
			if(i == currentChoice) {
				g.setColor(Color.BLACK);
			}
			else{
				g.setColor(Color.RED);
			}
			g.drawString(options[i], 145, 140 + i * 15);
		}
	}
	
	private void select(){
		if(currentChoice == 0) {
			// start
		}
		if(currentChoice == 1) {
			//help
		}
		if(currentChoice == 2){
			System.exit(0);
		}
	}
	public void keyPressed(int k){
		if(k == KeyEvent.VK_ENTER) {
			select();
		}
		if(k == KeyEvent.VK_UP) {
			currentChoice--;
			if(currentChoice == -1) {
				currentChoice = options.length - 1;
				
			}
			
		}
		if(k == KeyEvent.VK_DOWN) {
			currentChoice++;
			if(currentChoice == options.length) {
				currentChoice = 0;
			}
		}
	}
	public void keyReleased(int k){}
	
	
}
Re: not showing the background image [message #1730119 is a reply to message #1730024] Thu, 21 April 2016 13:34 Go to previous message
Russell Bateman is currently offline Russell BatemanFriend
Messages: 3798
Registered: July 2009
Location: Provo, Utah, USA
Senior Member

On 04/21/2016 06:53 AM, anthony rodelo wrote:
> HI I'm working a project before school starts in june to reduce my
> tuition by 5k so I decided to do this tutorial on youtube as my project
> but I copied every thing that the guy said to write but on his page he
> is not getting the same error I do not no why I am getting this error i
> tried to run in debug mode to show the background picture but I think
> this error is stopping it can you help please its line 30 setVector
> package GameState;
>
> [snip]

The purpose of this forum is to answer questions on the set-up and use
of the Eclipse IDE. It's not to answer beginning programming or even
general programming questions.

I would suggest a) that you step through in the debugger, b) figure out
how better to state your question and c) try a forum such as
javaranch.com or stackoverflow.com.

Best of luck.
Previous Topic:How to make my IDE looks native on windows 10?
Next Topic:declare git repository as a photran project
Goto Forum:
  


Current Time: Fri Apr 26 00:57:31 GMT 2024

Powered by FUDForum. Page generated in 0.08390 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top