Racer

Recommended levellevel
10+
Have you ever played the video game Speed Race? Not sure? Or perhaps Wheels? Okay, what about a game where you drive a race car at high speed and simultaneously dodge other cars and various obstacles that are sometimes illogical? We think you must have encountered some obstacle-laden racing games at some point in your gaming life! There are too many of these games to count. They have always been super popular, because they are exciting and the rules are so simple. The genre's first representatives appeared back in the days of arcade machines and even let you compete against your friends. And once in 1981, Bill Gates and Neil Konzen wrote a similar game. It was called Donkey.bas (the .bas extension means that Microsoft's former CEO used the BASIC programming language to write it) and was included in early versions of PC DOS, an operating system that today's kids can imagine only in their worst nightmares? In Donkey.bas, the race car driver (player) had to avoid running into donkeys that would suddenly appear on the road. A situation familiar to any fan of the genre! Let's follow in the footsteps of Microsoft's founder and create a similar game. But not in BASIC, of course. And we'll also do without the gray odd-toed ungulates. We're cooler, so we'll use our beloved Java. Let's call our game Racer. In addition to a player who can steer left and right and accelerate, it will have objects that move horizontally and vertically ? other cars and stationary obstacles. The objective is to get to the finish line without hitting any of these objects. The finish line appears after a certain number of obstacles are passed. This isn't as hard as it may seem, but effort will be required. Here at CodeGym, we've already split this project into managable tasks that beginning programmers can understand. Shall we get started?
Comments (61)
  • Popular
  • New
  • Old
You must be signed in to leave a comment
25 December 2023, 18:07
🙄
Denis Gritsay
Level 37
13 November 2023, 20:23
терпения не хватает на компилятор, все время жму "правильное решение" в больше половине случаев не могу найти отличия от моего. Это баг или фича?
toowee
Level 14
Expert
8 November 2023, 16:40
как в ide по шагам двигаться у меня первый шаг стоит и все
Vlad V
Level 35
17 April 2023, 12:16
А почему в этой игре все по встречке едут?
Gans Electro
Level 50
3 May 2023, 15:50
Это с какой стороны смотреть...😂
Vlad V
Level 35
13 July 2023, 16:21
та я имел ввиду что по обе стороны от разделительной полосы все в одну сторону едут
Kirill Java Developer
13 February 2023, 14:47
У кого игра при компиляции в IDEA выдает NullPointerException и ничего не выводит на экран: В методе Initialize() класса RacerGame удалите или задокументируйте вызов метода drawScene()! Он должен вызываться только в createGame().
@Override
    public void initialize() {
        showGrid(false);
        setScreenSize(WIDTH, HEIGHT);
        //drawScene();
        createGame();
При текущей конфигурации в методе drawScene() осуществляется вызов методов соответствующих объектов, но их состояние - null, так как их инициализация проводиться в методе createGame() => отсюда и получаем исключение NullPointer. Если валидатор будет настойчиво требовать вызов этого метода в данном месте, можно просто раздокументировать, пройти валидацию и снова его выключить.
STEPASHKINS
Level 34
31 January 2023, 18:17
Люди добрые, подскажите как запустить программу, чтобы хоть поглядеть на процесс создания игры, если кнопка пуска неактивна(нет метода мэйн), jdk установлен . Куда этот мэйн пихнуть правильно
Kirill Java Developer
13 February 2023, 14:52
Для запуска нужен переопределенный метод initialize()
@Override
    public void initialize() {
        showGrid(false);
        setScreenSize(WIDTH, HEIGHT);
        drawScene();
        createGame();
Но в нем есть баг, в коментарии выше я описал как с ним быть)
5 August 2022, 06:43
Странно, почему вот так не принимает: public void move(){ switch (direction){ case LEFT: x--; case RIGHT: x++; } } То же самое, что и через If. Ругается только на LEFT...
Valkery
Level 41
17 August 2022, 13:07
потому что switch брейкать надо
JavaPlayerPro999 Android Developer at Genesis
28 May 2022, 14:29
18/28 +10 28
9 May 2022, 10:59
24 шаг. Впервые за 600 задач использовал кнопку "Правильное решение". Ничего не помогало победить 3 пункт.
27 September 2022, 18:39
Пааанты:)
LevPM
Level 50
8 January 2022, 19:41
https://javarush.com/projects/apps/310863 Моя версия SpaceRacer :)