Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » Help color wont turn random
Help color wont turn random [message #1856955] Tue, 10 January 2023 22:26 Go to next message
matti matti is currently offline matti mattiFriend
Messages: 1
Registered: January 2023
Junior Member
Hi so basically im doing a rectangular game when the box hit the corners it changes color and the random is marked red in eclipse and i dont know why

package main;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.util.Random;

import javax.swing.JPanel;

import inputs.KeyboardInputs;
import inputs.MouseInputs;

public class GamePanel extends JPanel{

private MouseInputs mouseInputs;
private float xDelta = 100, yDelta = 100;
private float xDir = 0.01f, yDir = 0.01f;
private int frames = 0;
private long lastCheck =0;
private Color color = new Color(150,20,90);
private Random random;

public GamePanel() {
random = new Random;
mouseInputs = new MouseInputs(this);
addKeyListener(new KeyboardInputs(this));
addMouseListener(mouseInputs);
addMouseMotionListener(mouseInputs);
Re: Help color wont turn random [message #1856958 is a reply to message #1856955] Wed, 11 January 2023 02:09 Go to previous message
Nitin Dahyabhai is currently offline Nitin DahyabhaiFriend
Messages: 4493
Registered: July 2009
Senior Member

This isn't a forum for Java programming, but you didn't have parentheses when calling the constructor for Random.

_
Nitin Dahyabhai
Eclipse Web Tools Platform
Previous Topic:eclipse fails to start after windows laptop restart
Next Topic:org.eclipse.jetty(9.4.48.v20220622) failed to start
Goto Forum:
  


Current Time: Fri Oct 11 21:50:15 GMT 2024

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

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

Back to the top