Recent

Author Topic: Another "Snake"  (Read 3226 times)

Seenkao

  • Hero Member
  • *****
  • Posts: 652
    • New ZenGL.
Another "Snake"
« on: December 30, 2024, 11:34:58 am »
--> Download "Snake" <--

Сделать игру я сделал уже давно, но застрял на реализации меню. Решил выложить в "сыром" варианте.
Показано как можно использовать ZenGL для создания игры.

Сделано:
Quote
- управление змейкой
- создание "яблок"
- создание препятствий
- проверка коллизий
- работа со звуком
- работа с текстом
- создание меню и его реализация (сложная тема!)
- реализация поддержки двух языков
игра, по сути, не доделана...  :(
Распакуйте проект рядом с папкой ZenGL_SRC и соберите проект.
Windows, Linux должны работать (если я опять где-то не накосячил).

Надеюсь не слишком сильно всё усложнил... :-[
Всех с наступающим Новым Годом! ;)

P.S. Забыл, кто не знает ZenGL можно скачать тут.

---------------------------------
Google translate:
I made the game a long time ago, but got stuck on the menu implementation. Decided to post it in a "raw" version.
It shows how you can use ZenGL to create a game.

Done:
Quote
- snake control
- creating "apples"
- creating obstacles
- checking for collisions
- working with sound
- working with text
- creating a menu and implementing it (a complex topic!)
- implementing support for two languages
the game is essentially unfinished... :(
Unzip the project next to the ZenGL_SRC folder and build the project.
Windows, Linux should work (unless I screwed up somewhere again).

I hope I didn't make things too complicated... :-[
Happy New Year to everyone! ;)

P.S. I forgot, for those who don’t know ZenGL you can download it here.
« Last Edit: December 30, 2024, 03:14:06 pm by Seenkao »
Rus: Стремлюсь к созданию минимальных и достаточно быстрых приложений.

Eng: I strive to create applications that are minimal and reasonably fast.
Working on ZenGL

Seenkao

  • Hero Member
  • *****
  • Posts: 652
    • New ZenGL.
Re: Another "Snake"
« Reply #1 on: December 30, 2024, 03:16:14 pm »
Исправил ошибки, перезалил. Обратите внимание, так же есть вложенный файл в первопосте, чтоб на sourceforge не бегать.

Google translate:
Fixed errors, re-uploaded. Note that there is also an attached file in the first post, so you don't have to go to sourceforge.
Rus: Стремлюсь к созданию минимальных и достаточно быстрых приложений.

Eng: I strive to create applications that are minimal and reasonably fast.
Working on ZenGL

Lulu

  • Sr. Member
  • ****
  • Posts: 269
Re: Another "Snake"
« Reply #2 on: December 30, 2024, 08:22:12 pm »
Hi Seenkao
It work on Windows 10. Thanks !
wishing you a nice life!
GitHub repositories https://github.com/Lulu04

dseligo

  • Hero Member
  • *****
  • Posts: 1458
Re: Another "Snake"
« Reply #3 on: December 31, 2024, 01:51:08 am »
It works, but certainly can be improved. :)
I am missing sound, although I see in code that there should be sound.
Also, when game is started again after collision, after eating apple some square appears for split second at random place.
And 'Back' button could be removed from game screen.

P.S.: I looked at the 'glitch' which shows after eating apple. Problem is when you increase snake's length (after eating apple), coordinates in lenSnake array are not initialized for new tail addition.
Problem arises because snake is drawn before new coordinates are calculated. When program is first started, these coordinates are 0, and glitch doesn't show because you draw stone (kamen) over it.
When game is over and started again, there are some coordinates in the array already. This time when snake is enlarged the tail is drawn in the wrong position.

You could either avoid drawing longer tail immediately after eating apple with some check or you could put coordinates for new tail after each increase.
I see you commented lines 277 and 278 in game_functions.pas which does the later, you should just uncomment these lines:
Code: Pascal  [Select][+][-]
  1.         // Snake.lenSnake[Snake.len].X := Snake.lenSnake[Snake.len - 1].X;
  2.         // Snake.lenSnake[Snake.len].Y := Snake.lenSnake[Snake.len - 1].Y;
« Last Edit: December 31, 2024, 02:35:55 am by dseligo »

Seenkao

  • Hero Member
  • *****
  • Posts: 652
    • New ZenGL.
Re: Another "Snake"
« Reply #4 on: December 31, 2024, 07:31:22 am »
Lulu, dseligo, thanks!  ;)

It works, but certainly can be improved. :)
I am missing sound, although I see in code that there should be sound.
Используется OpenAL, и как я понимаю вы проверяли на Windows. Попробуйте установить OpenAL и проверить.
В дальнейшем мне надо будет делать проверку внутри программы, работает OpenAL или нет, и если нет, то переключаться на DXSound.
Вы можете попробовать зайти в файл конфигурации "zgl_config.cfg" и отключить определение для Windows
{$DEFINE USE_OPENAL}.

---------------------------------------------
Google translate:
OpenAL is used, and as I understand you checked on Windows. Try installing OpenAL and check.
In the future, I will need to check inside the program whether OpenAL works or not, and if not, switch to DXSound.
You can try to go to the configuration file "zgl_config.cfg" and disable the definition for Windows{$DEFINE USE_OPENAL}.


Quote
Also, when game is started again after collision, after eating apple some square appears for split second at random place.
And 'Back' button could be removed from game screen.

P.S.: I looked at the 'glitch' which shows after eating apple. Problem is when you increase snake's length (after eating apple), coordinates in lenSnake array are not initialized for new tail addition.
Problem arises because snake is drawn before new coordinates are calculated. When program is first started, these coordinates are 0, and glitch doesn't show because you draw stone (kamen) over it.
When game is over and started again, there are some coordinates in the array already. This time when snake is enlarged the tail is drawn in the wrong position.

You could either avoid drawing longer tail immediately after eating apple with some check or you could put coordinates for new tail after each increase.
I see you commented lines 277 and 278 in game_functions.pas which does the later, you should just uncomment these lines:
Code: Pascal  [Select][+][-]
  1.         // Snake.lenSnake[Snake.len].X := Snake.lenSnake[Snake.len - 1].X;
  2.         // Snake.lenSnake[Snake.len].Y := Snake.lenSnake[Snake.len - 1].Y;
Я не проверял игру на Windows и возможно из-за этого некоторые проблемы выползают. Я больше основывался на Linux, но да, я был в сомненьях, надо раскомментировать этот код или нет. Потому что я проблем не видел. Я больше занимался "Меню" и мало самой игрой.
Кнопка "Назад" висит как тестовая. Игровой экран должен занимать не всё поле и кнопка должна находиться вне поля игры и должна быть ещё дополнительная информация по игре, так что да, делать ещё много всего. )))
Благодарю за информацию и тесты!

---------------------------------
Google translate:
I haven't tested the game on Windows and maybe that's why some problems are creeping out. I was more based on Linux, but yes, I was in doubt whether I should uncomment this code or not. Because I didn't see any problems. I was more involved in the "Menu" and little in the game itself. The "Back" button hangs as a test. The game screen should not take up the entire field and the button should be outside the game field and there should be additional information about the game, so yes, there is still a lot to do. )))
Thanks for the information and tests!
Rus: Стремлюсь к созданию минимальных и достаточно быстрых приложений.

Eng: I strive to create applications that are minimal and reasonably fast.
Working on ZenGL

dseligo

  • Hero Member
  • *****
  • Posts: 1458
Re: Another "Snake"
« Reply #5 on: December 31, 2024, 12:39:55 pm »
You can try to go to the configuration file "zgl_config.cfg" and disable the definition for Windows{$DEFINE USE_OPENAL}.

I did this and now there is sound when eating apple.

Quote
Thanks for the information and tests!

You're welcome

 

TinyPortal © 2005-2018