Dream Games, RPG games open Source Development lectures (JAVA) [6]--__java

Source: Internet
Author: User
Tags gety rar

In the game it is not always possible to allow a scene to go through all the way, which brings up the requirements of the scene change, based on the implementation of this requirement, we will have the following effect of Java code implementation.


Download Address Http://www.3adisk.com/?onlinezero[filename: Rpgchair0to6.rar]

or save the following x (GIF) files as rar


Since the amount of code has started to increase, starting from this back to give only a partial code implementation, detailed download:

In this example, I take the bitmap offset algorithm as follows:

The Mypanle is implemented as follows:

X Offset Position

int OffsetX = mypanel.width/2-Role.getx () * CS;

Calculate x Offset

OffsetX = math.min (OffsetX, 0);

OffsetX = Math.max (OffsetX, mypanel.width-gamemap.width);

Y offset position

int OffsetY = MYPANEL.HEIGHT/2-Role.gety () * CS;

Calculate y Offset

OffsetY = math.min (OffsetY, 0);

OffsetY = Math.max (OffsetY, mypanel.height-gamemap.height);

System.out.print (Role.getx () + ":" +role.gety ());

Draw a map that can be offset

Map.draw (g, OffsetX, OffsetY);

To draw the role of an offset position

Role.draw (g, OffsetX, OffsetY);

In both Gamehandle and Gamemap, the offsetx and offsety values should be injected to generate the corresponding images.

Gamehandle implementation:

Starting with the Example6, all algorithms are added to the offset value to achieve the background movement.

Public void Draw (Graphics g, int offsetX, int OffsetY) {

Takes count as the offset value of the image and adds direction to the Example4 to get the image block position

G.drawimage (image, X * cs + offsetX, Y * cs + offsetY, X * cs + OffsetX + cs, Y * cs + OffsetY + cs,

Count * cs, direction * CS, CS + count * cs, Direction * CS + cs, panel);

}

Gamemap implementation:

Correcting the plotting method in EXAMPLE6 and introducing map coordinate offset calculation

Public void Draw (Graphics g, int offsetX, int OffsetY) {

int Firsttilex = pixelstotiles (-OFFSETX);

Change x coordinates

int Lasttilex = Firsttilex + pixelstotiles (mypanel.width) + 1;

Returns the minimum x offset value

Lasttilex = Math.min (Lasttilex, COL);

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.