我正在尝试制作一个简单的Java游戏 - 通过轨道驾驶汽车.我的老师习惯使用矩形和类似的东西.我的问题是当我使用repaint()我的框架闪烁的方法时.我试图在汽车改变方向时放置重绘方法,但它没有任何好处.有什么建议?
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Rectangle;
import java.awt.Toolkit;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.net.URL;
import javax.swing.JFrame;
@SuppressWarnings("serial")
public class MAP extends JFrame
{
//the URL and Img designed for the images
URL cLeft,cRight,cUp;
Image img1,img2,img3;
//these will keep track of each player’s speed:
double p1Speed =.5, p2Speed =.5;
//constant for the screen size and used for the drawing the terrain
final int WIDTH = 900, HEIGHT = 650;
//these are ints that represent …Run Code Online (Sandbox Code Playgroud)