Hello, Gravity Games here! Recently, I've been playing apps on my new Android Galaxy Player, and have been having a lot of fun, which motivated me to start developing android apps. Apparently, android apps are coded in Java, so I made the decision o finally move up from game maker and start using Java. I was following a YouTube tutorial in Java game coding, and everything was going swell, until I got to the point of rendering a rectangle. Here's the code I have in the file that's giving me trouble.
package main.cww.gravitygames; import java.awt.Color; import java.awt.Graphics; import java.awt.geom.Rectangle2D; import javax.swing.*; public class Ac extends JPanel{ public int characterWidth=12; public int characterHeight=20; public Rectangle character; public boolean objectsDefined=false; public Ac() { setBackground(Color.BLACK); defineObjects(); } public void defineObjects() { character = new Rectangle((Aa.width/2) - (characterWidth/2), (Aa.height/2) - (characterHeight/2), characterWidth, characterHeight); objectsDefined=true; } public void paintComponent(Graphics g) { super.paintComponent(g); if(objectsDefined){ g.setColor(Color.WHITE); g.fillRect(character.x, character.y, character.width, character.height); } } }
Help is REALLY appreciated, I've been trying 2 days to fix this but to no avail.
EDIT: ...okay? I had originally used Rectangle, but I changed it to Rectangle2d at the request of Eclipse, then I hover over Rectangle2d and it requests a change to Rectangle. When I tried running it again, it somehow worked... is it just me, or is Eclipse just weird sometimes?...