Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Microsoft CSharp Programming For The Absolute Beginner (2002) [eng].pdf
Скачиваний:
39
Добавлен:
16.08.2013
Размер:
15.71 Mб
Скачать

Chapter 7: Timers and Animation: The Lunar Lander

When you move to a graphical interface, you can write many new kinds of programs. Games and animations are especially interesting to write. In this chapter, you will write a simple arcade game, with all the features you might expect from such a game. Along the way, you’ll master techniques used for writing animations in C#. In this chapter you will learn how to

Read individual key presses.

Work with multiple images.

Use the timer object to simplify animation.

Move objects around on the screen.

Detect collisions between objects.

Introducing the Lunar Lander

The sample game for this chapter re−creates one of the all−time classic arcade games, the Lunar Lander game. In this game, the user tries to pilot a spacecraft near the surface of the moon. The pilot must land his or her craft on a small platform with limited fuel. Figure 7.1 demonstrates the Lunar Lander game in action.

Figure 7.1: The landing craft starts with a random speed and direction—and limited fuel.

The player controls the ship with thrusters controlled by the arrow keys. However, each blast of a thruster burns precious fuel. If the player is going too fast when he or she touches the landing pad, it is a crash, and he or she loses a ship. A safe landing is rewarded with more fuel and a new, randomly chosen landing assignment. The game continues until the user loses three ships.

168

Соседние файлы в предмете Программирование на C++