Java中的动画...使用Java秋千和图像

问题描述:

大家好,谁能告诉我,我如何使用any包启动Java中的基本动画.我想制作自己的蛇游戏,这意味着他可以吃东西并成长.

需要建议.
谢谢,
Akkywadhwa

Hi everyone can anyone tell me that how can i start the basic animation in java using its any package. I want to make my own snake game which means he eats his food and grows.

Suggestion required.
Thanks,
Akkywadhwa

检查此链接

简单的动画和线程 [ Java小程序中的动画 [使用Java Applet的Snake游戏 [ ^ ]
蛇游戏 [ ^ ]
Check This Links

Simple Animation and Threads [^]
Animation in Java applets[^]

A Snake Game using Java Applet[^]
Snake Game[^]


这与动画无关.

您需要重画蛇正在奔跑的田野.每次您更改某些内容时都要重新粉刷一次.每次添加苹果或石头时都重新粉刷一次(?-那里有吗?).

您可以将参数传递给Component,以指定蛇和对象:

This is not about animation.

You need to repaint the Field the snake is running on. repainting it every time you change something. Repainting it every time you add an apple or stone(? - where those in there?).

You can pass arguments to your Component that specify the snake and the obsticales:

public class PanelPlayGround extends JPanel{

 private Snake oSnake;
 private Obesticales oObsticales;

 public PanelPlayGround(final Snake oSnake, final Obsticales oObsticales){
   super():
   setSnake(oSnake);
   setObsticales(oObsticales);
   ignition();
 }

 private void ignition(){
   // let the fun begin
 }

 public void renewPanel(final Snake oNewSnake, final Obsticales oNewObsticales){
   setSnake(oNewSnake);
   setObsticales(oNewObsticales);
   this.dolayout(); // to repaint the Jpanel
 }

}



对象Snake 基本上包含x/y值的列表,用于指定蛇占用网格的哪些字段.
对象Obsticales包含一个Obstical列表.
Obstical 包含一个x/y值和一个枚举ObsticalType.



The Object Snake contains basically a list of x/y-values to specify which fields of the grid are occupied by the snake.
The Object Obsticales contains a List of Obstical.
Obstical contains one x/y value and one Enum ObsticalType.