Computer World. Матросова Т.А. - 100 стр.

UptoLike

Составители: 

99
The main character class would maintain information such as life points and any
items picked up during the game, such as weapons, lanterns, keys, and so on. The
character class would have methods for moving in different directions based on the
player's input. The items carried by the character also would be objects. The lantern
class would contain information such as how much fuel is left and whether the
lantern is on or off. The lantern would have methods for turning it on and off, which
would cause it to use up fuel.
There would be a general creature class from which all creatures would be
derived. This creature class would contain information such as life points and how
much damage the creature inflicts when fighting. It would have methods for moving
in different directions. Unlike the character class, however, the creature's move
methods would be based on some type of intelligence programmed into the creature
class. The mean creatures might always go after the main character if they are on the
same screen together, for example, but passive creatures might just ignore the main
character. Derived creature classes would add extra attributes such as the capability to
swim or fly.
I've obviously left out a lot of detail in the descriptions of these hypothetical
objects. This is intentional because I want to highlight the benefit of the object
approach, not the details of fully implementing a real example.
Java and Other OOP Languages
You've learned that OOP has obvious advantages over procedural approaches,
especially when it comes to games. OOP was conceived from the ground up with the
intention of simulating the real world. However, in the world of game programming,
the faster language has traditionally always won. This is evident by the amount of
assembly language still being written in the commercial game-development
community. No one can argue the fact that carefully written assembly language is
faster than C, and that even more carefully written С is sometimes faster than C++.
And unfortunately, Java ranks a distant last behind all these languages in terms of
efficiency and speed.
However, the advantages of using Java to write games stretch far beyond the
speed benefits provided by these faster languages. This doesn't mean that Java is
poised to sweep the game community as the game development language of choice;
far from it! It means that Java provides an unprecedented array of features that scale
well to game development. The goal for Java game programmers is to write games in
the present within the speed limitations of Java, while planning games for the future
that w ill run w ell w hen fas ter versions of Java are released.
In fact two separate speed issues are involved in Java game programming. The
first is the issue of the speed of the Java language and runtime environment which
will no doubt improve as better compilers and more efficient versions of the runtime
environment are released. The second issue is that of Internet connection speed which
is limited by the speed of the modem or physical line used to connect to the Internet.
Both of these issues are important but they impact Java games in different ways: first