📄 levelone.java
字号:
import java.awt.Component;
import java.awt.Color;
import java.applet.Applet;
/**
Hi everybody out there!
Thank you for downloading the "J-Rio level editor". If you have a JDK installed on your
computer you'll be able to create new levels for the J-Rio game and run this level on
your computer. You can only run one level at a time! This file will show you how to
create a J-Rio level and it would be really cool if you would send me your levels (please
only the LevelOne.java file!!!). If I like the level, I'll add it to the official J-Rio
release, if you tell me your name even with your name appearing in the game. So take your
chance and write as many levels as possible!
Ok, lets start writing a level, use this level as template, the rules
of how to make it are given with the comments!
Please send this file to javacooperation@gmx.de if you finished a level and if you
want to share it with the rest of the world!
*/
public class LevelOne extends Level
{
/**
Level definition:
A J-Rio level consists of 25 rows represented as strings. Row one
is the "sky" of the game row 25 is the "bottom" of the game. The
level strings can be as long as you want them to be but they must
be all of the same length! Each character in the level definition
has a certain meaning. Here comes the explanation:
Level elements:
":" : this charakter is a spacer for parts of the level where is no other element
g: ground element, J-Rio stops falling if he falls on it and stops
jumping if he bangs his head against it
p: platform, has the same function as the ground element but looks different
s: secret stone, represents a stone with a question mark on it, has no new
life and no other goody
i: invisible stone, this stone is invincible as long as it has not been
touched once, then it will be visible
u: mushroom stone, looks the same as the question mark stone, but has
a mushroom or a flower if J-Rio bangs it's head against this stone
l: new life stone, looks the same as the question mark stone, but has a new life
if J-Rio bangs it's head against this stone
e: exit stone, place only one of these stones at the end of a level. J-Rio
can reach a new level by banging it's head against it
m: money, shows up as a coin, J-Rio get's score for it
b: left - right moving platform, a little bit complicate to use. Write the following:
rbrrrrrr to the level definition. b is the symbol for the platform, r is a spacer
so that no other element can be placed here. You can also find a example in the
example level further down.
a: up - down moving platform, even more complicate to use. Write the following in a
line from up to down (you'll need 11 rows):
row1+x: ...::r::...
row2+x: ...::r::...
row3+x: ...::r::...
row4+x: ...::r::...
row5+x: ...::r::...
row6+x: ...::r::...
row7+x: ...::r::...
row8+x: ...::r::...
row9+x: ...::r::...
row10+x: ...::b::...
row11+x: ...::r::...
you can find a example for this platform in the example level
r: is not translated to a visible level_object, but shows, where spacer will
be created
Enemies:
k: platform keeper, walks around and does not fall down if a whole or the end of
a platform is reached (blue guy)
o: gooba, walks around and falls down if the end of a platfrom or a whole is reached
(red guy)
c: jumping koopa, walking around and jumps
f: fire koppa, walks, jumps and shoots
d: dolphin, jumping up and down out of wholes
If a level doesn't work:
1.) check if the number_of_enemies is correct
2.) check if the number_of_moving_elements is correct
3.) check if all the rows have the same length
4.) check if there is no wrong (undefined) character
*/
// Change the level definition as you want to, use the specified characters for
// certain level elements and enemies. You can change the level size by changing
// the length of the strings but they have to be of the same size.
// Also don't forget the exit stone and don't place too many enemies, this would
// make the game slower.
public static final String row1 = "::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::";
public static final String row2 = "::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::ssss";
public static final String row3 = "::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::";
public static final String row4 = "::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::";
public static final String row5 = ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::m:k:::::::::k:::m";
public static final String row6 = "::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::sss::::::sus:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::p::p::ppppppppppppppppp";
public static final String row7 = "::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::";
public static final String row8 = ":::::::::::::::::::::::::::::::::::::::::::::::::::k::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::r:::::::::::::::::::::::::::::";
public static final String row9 = "::::::::::::::::::::::::::::::::::::::::::::::::::rbrrrrrr:::m::m::m::m::m:km:m:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::r:::::::::::::::::::::::::::::";
public static final String row10 = ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::pppppppppppppppppp:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::r:::::::::::::::::::::::::::::";
public static final String row11 = ":::::::::::::::::::::::::::::::::::::::::::::::p::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::r:::::::::::::::::::::::::::::";
public static final String row12 = "::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::r:::::::::::::::::::::::::::::";
public static final String row13 = "::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::r:::::::::::::::::::::::::::::";
public static final String row14 = ":::::::::::::::::::::::::::::::::::::::::::::p::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::r:::::::::::::::::::::::::::::";
public static final String row15 = "::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::r:::::::::::::::::::::::::::::";
public static final String row16 = "::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::r:::::::::::::::::::::::::::::";
public static final String row17 = ":::::::::::::::::::::::::::::::::::::::::::p::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::a:::::::::::::::::::::::::::::";
public static final String row18 = ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::p::::r:::::::::::::::::::::::::::::";
public static final String row19 = "::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::mm::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::";
public static final String row20 = "ssuss:::::::::::mmm::::::::::::::::::::::s::::::sss::::::::::::::::::::::::::::::::::::::::::::::::::::::::mppm:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::";
public static final String row21 = "::::::::::::::::ppp::::p:::pp::::::::::::::::::::::::::::::::::::sss::::sss:::::::m::::m::::::::::::::::::mpggpm:::::sss::::::::::::::::::::::::::::::p:::p:::p:::p::::::::::::::::::::::::::::::e::::::";
public static final String row22 = "::::::::::::::::ggg::::::::gg:::::::::::::::::::::::::::::::::::::::::::::::::::::p::::p:::::::::::::::::mpggggpm::::::::::::::::::::::::::::::::::::p::::::::::::::::::::p::::p::::p:::p:::::::::::::::";
public static final String row23 = "::::::::::::::::gggo::::::ogg::::::::::::m::k::::mk::c:m::::::::::::::::::::::::::g::::g::::::::::::::::mpggggggpm::::::::::::::::::::::::::::::::::pg::::::::::::::::::::g::::g::::g:::g:::::::::::::::";
public static final String row24 = "pppppppppp:::pppgggppppppppggppppp:::pppppppppppppppppppppp::::::::::mmmm:k:::::::g::::g:::::::::::k:::mpggggggggpm:::::::::::::k::::::::::::k:::::pgg::m:::mc::::::f:::::g::o:g::o:g:::g:::::::mmmm:f::";
public static final String row25 = "gggggggggg:::ggggggggggggggggggggg:::gggggggggggggggggggggg:::ggggggggggggggggg:::g::d:g:::gggggggggggggggggggggggggggggggg:::gggg:d:gggg:d:ggg:::gggggggggggggggggggggggggggggggggggggggggggggggggggggg";
/* count the number of enemies and write them there, don't write a wrong
number, because your level wouldn't work then */
private static final int number_of_enemies = 21;
/* count the number of moving elements (the a's and b's), number must be
correct, otherwise it won't work */
private static final int number_of_moving_elements = 2;
/* this is the time in seconds the player may use to solve the level, you
can write whatever you want */
private static final int level_time = 150;
/* don't change this name */
public static final String level_name = "Level1";
/* leave this as it is!! */
private final String [] definitions = {row1, row2, row3, row4, row5, row6, row7, row8, row9, row10,
row11, row12, row13, row14, row15, row16, row17, row18, row19, row20,
row21, row22, row23, row24, row25};
/* don't change */
private Color [] colors;
/* don't change */
public LevelOne(Component parent, Applet applet)
{
super(parent, applet, level_name, level_time);
initializeColorArray();
super.setColorArray(colors);
super.initializeLevel(definitions, number_of_enemies, number_of_moving_elements);
}
/* don't change */
public void resetLevel()
{
super.initializeLevel(definitions, number_of_enemies, number_of_moving_elements);
}
/* This method initializes the color array for the background.
The color array must hold 255 colors, you can change the
generation line ... = new Color (... , ... , ...) to what
ever you want to generate different color effects */
private void initializeColorArray()
{
colors = new Color[255];
for(int i=0; i<255; i++)
{
// change this line (the values in the brackets) if you
// want to generate a new background effect
Color color = new Color(i, i, 255);
colors[i] = color;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -