Dream Game room, RPG game open Source Development lectures (JAVA) [2]--trample on the red dust __java

Source: Internet
Author: User

"Peng" last book said, the Java game map construction is an extremely simple thing, this book to connect the previous article, explore the role of the game in the mobile problem.

As we all know, [role] is the soul of a game, there is no role in the game, is no soul of the game.

So, how to let this important role [move] up.

Now "The ROC" first demonstrated a simple example, thinking of the use of the.

file Example2.java

 

package Org.loon.chair.example2;

import Java.awt.Container;

import javax.swing.JFrame;

/**

*

* @author Chenpeng

*

* Loon Framework in Game

*

*/

Public class Example2 extends JFrame {

Public Example2 () {

The default form name

Settitle ("movement and limitation of roles in Example2[java game");

Get an example of our custom panel [map Panel]

Mypanel panel = new mypanel ();

Container ContentPane = Getcontentpane ();

Contentpane.add (panel);

Execute and build the form setup

Pack ();

}

Public Static void Main (string[] args) {

Example2 e1 = new Example2 ();

Set Allow form close operation

E1.setdefaultcloseoperation (Jframe.exit_on_close);

Show form

E1.setvisible (true);

}

}

file Mypanel.java

 

package Org.loon.chair.example2;

import java.awt.Dimension;

import java.awt.Graphics;

import java.awt.Image;

import java.awt.event.KeyEvent;

import Java.awt.event.KeyListener;

import Javax.swing.ImageIcon;

import Javax.swing.JPanel;

/**

* Custom panel in Example1 to depict the underlying map.

*

* @author Chenpeng

*

* Loon Framework in Game

*

* PS: Please note that this is different from the previous precedent, new keyboard event monitoring

*/

Public class Mypanel extends JPanel implements KeyListener {

Width and height of the form

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.