Beginner's journey to j2-2d games (1) game framework

Source: Internet
Author: User

In response to the call of www.j2medev.com webmaster mingjava, I would like to share my experience with you. At the same time, www.j2medev.com welcomes original articles from experts.
A few days ago, he saw tony publish his learning work on csdn "60 s for a man". He thought that although his creativity was simple, he was very playable. He was an entry-level classic in learning how to create mobile games, as a result, tony's image is still used for learning. If you are interested in this game, contact tony or visit his blog.
In terms of development trends, midp2.0 is a trend. The cheapest midp2.0 mobile phone, such as ot735i, is already about 1700 yuan. The Siemens high-end machine cx65 a year ago is only about 2500 yuan; in addition, the price of-midp2.0 mobile phone has a variety of options, Siemens, se, N machines are available. I personally like cx65. If the costs of mobile phone manufacturers keep decreasing in the future, I believe that 1500 yuan of midp will not be a dream... Of course, it depends on whether the application is rich.
To put it bluntly, we will use midp 2.0 to develop our game code: fly. Development Tool jbulider. After the article is fully written, the src download will be provided.
Directory:
I. Game framework
2. Improve peripheral tools (images, GameObject, and Font)
Iii. control plane movement
4. Add a bullet group for collision calculation
5. Implement the explosive effect and add a prop Missile
6. What do you think?
VII. Source Code
I. Game framework
Our games require a general game framework for future development, but implementing an engine is complicated. As a beginner, if you want to think too much about it, I am afraid it will lead you away from the main line. Here we only provide the canvas code, if you do not understand it, you can refer to another series of articles on this site, "using MIDP2.0 to develop Games".
Use singlon, because each gamecanvas requires a lot of memory space. In addition, we only need to rewrite gameInit (), gameMain (), and write the code initialized at one time in the constructor.
Public class MyGameCanvas extends GameCanvas
Implements Runnable, CommandListener {
Private static MyGameCanvas instance;
Graphics g;
Boolean running;
Thread t;
Command startcmd, exitcmd, restartcmd;
Int keystate;
Boolean keyevent;
Boolean key_up, key_down, key_left, key_right, key_fire;
Private boolean allowinput;
Public int screenwidth;
Public int screenheight;
Boolean gameover;
// Define your variable here
// Define your variable end
Protected MyGameCanvas (){
Super (true );

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.