Робота з графікою в SDL: Урок №5: Clickomania

Marius Andra, “GFX with SDL: Lesson 5: Clickomania”, public translation into Ukrainian from Ukrainian More about this translation.

See also 13 similar translations

Translate into another language.

Participants

eReS1719 points
ALEXfanata455 points
rom-broiler81 points
And others...
Join Translated.by to translate! If you already have a Translated.by account, please sign in.
If you do not want to register an account, you can sign in with OpenID.
Pages: ← previous Ctrl next
1 2 3 4 5 6 7 8

GFX with SDL: Lesson 5: Clickomania

Робота з графікою в SDL: Урок №5: Clickomania

History of edits (Latest: eReS 1 year, 10 months ago) §

GFX with SDL: Lesson 5: Clickomania

GFX з SDL: Урок №5: Clickomania

History of edits (Latest: ALEXfanata 1 year, 10 months ago) §

Hi all! In this tutorial we will build a simple game in SDL called Clickomania. Clickomania is actually a really simple game to build. Our version of the game will consist of a 10x14 grid of balls. When you click (with the mouse) on a ball, that's connected to 2 or more balls, all the connected balls of the same color as the ball you clicked dissapear. And the balls that were above the dissapeared balls will simply fall down. If you manage to clear a row of balls, then the other rows move in to the left from the right. These 4 images illustrate the basic aspects of the game:

Привіт всім! У цьому туторіалі ми створимо просту гру в SDL під назвою Clickomania. Clickomania - це дійсно дуже проста у написанні гра. Наша версія гри буде складатися із сітки розміром 10х14 із кульок. При натисканні (мишею) на кульку, що з'єднана із двома або більше іншими кульками, всі з'єднані кульки того ж кольору, на який натиснули, зникають. А ті, що знаходились вище, просто падають вниз. Якщо вдається очистити одразу рядок кульок, тоді решта рядків зсуваються справа наліво.
Наступні 4 ілюстрації зображують базові аспекти гри:

History of edits (Latest: wertomaniak 1 year, 5 months ago) §

After clicking one of the purple balls in the yellow region, all of them disappear and the balls that were above them fall down.

Після натискання однієї з пурпуровових кульок в жовтій області, всі вони зникають і кульки, які були над ними падають вниз.

History of edits (Latest: ALEXfanata 1 year, 10 months ago) §

When we get rid of the balls in the yellow region the rest move from right to left. Note that the rows of balls move from right to left, not the individual balls themselves. Now let's get to coding the game.

Коли ми позбуваємось кульок в жовтій області, інші будуть рухаються справа наліво. Зверніть увагу на те, що справа наліво рухаються ряди кульок, а не окремі кульки. Тепер давайте перейдемо до написання гри.

History of edits (Latest: BlaXpirit 1 year, 2 months ago) §

We first have some #includes and some #defines.

Спочатку ми оголошуємо директиви #include та деякі константи #define

History of edits (Latest: BlaXpirit 1 year, 2 months ago) §

#include <stdio.h>

#include <stdio.h> //стандартна біблиіотека вводу/виводу

History of edits (Latest: eReS 1 year, 10 months ago) §

#include <stdlib.h>

#include <stdlib.h>

History of edits (Latest: ALEXfanata 1 year, 10 months ago) §

#include <stdarg.h>

#include <stdarg.h>

History of edits (Latest: eReS 1 year, 10 months ago) §

#include <string.h>

#include <string.h> // бібліотека для роботи з рядками.

History of edits (Latest: eReS 1 year, 10 months ago) §

#include <time.h>

#include <time.h> // бібліотека, яка відповідає за час та рандомні функції.

History of edits (Latest: eReS 1 year, 10 months ago) §

#include <SDL/SDL.h>

#include <SDL/SDL.h> // бібліотека, яка використовується для роботи с SDL

History of edits (Latest: eReS 1 year, 10 months ago) §

Since we'll also use the SDL Font routines (tutorial 4), we'll have to include font.h

Оскільки ми будемо також використовувати SDL шрифти (4 урок), ми повинні включити font.h

History of edits (Latest: ALEXfanata 1 year, 10 months ago) §

#include "font.h"

#include "font.h"

History of edits (Latest: ALEXfanata 1 year, 10 months ago) §

Now come some variables. The first two contain the dimensions of the playfield. They will be set to some values later.

Тепер оголошення деяких змінних. Перші дві містять розміри ігрового поля. Вони будуть встановлені в деяких значенях пізніше.

History of edits (Latest: ALEXfanata 1 year, 10 months ago) §

int rows;

int rows; // рядки

History of edits (Latest: eReS 1 year, 10 months ago) §

int cols;

int cols; // стовпці

History of edits (Latest: eReS 1 year, 10 months ago) §

screen should be obvious. balls contain the images of the 10 possible ball types. font1 and font2 shouldn't be too much to grasp as well.

картина повинна бути очевидною. Кулі містять зображення з 10 можливих типів кульок. font1 і font2 не повинно бути занадто багато, щоб зрозуміти краще.

History of edits (Latest: eReS 1 year, 10 months ago) §

SDL_Surface *screen; // The screen surface

SDL_Surface *screen; // Повернення екрану

History of edits (Latest: ALEXfanata 1 year, 10 months ago) §

SDL_Surface *balls[10];// The ball images

SDL_Surface *balls[10];// Зображення кульок

History of edits (Latest: ALEXfanata 1 year, 10 months ago) §

SDLFont *font1; // 2 fonts

SDLFont *font1; // ініціалізація шрифтів

History of edits (Latest: eReS 1 year, 10 months ago) §

SDLFont *font2;

SDLFont *font2;

History of edits (Latest: ALEXfanata 1 year, 10 months ago) §

playf contains the grid of all the balls. We will initalize it later.

в функція playf міститься сітка з всіх кульок. Ми ініціалізуємо її пізніше.

History of edits (Latest: ALEXfanata 1 year, 10 months ago) §

char *playf; // The playfield itself

char *playf; // Ігрове поле

History of edits (Latest: ALEXfanata 1 year, 10 months ago) §

scrwidth and scrheight contain the default width and height of the screen. Later we'll "parse" the command line arguments checking, if the user wants to run this program at some other screen resolution. Depending on the screen resolution, the grid of balls might and might not fully cover the screen when drawn from the screen coordinates o,o. centx and centy tell us from where to start drawing the array of balls. They will be calculated later.

scrwidth та scrheight містить висоту та ширину поля за замовчуванням.Пізніше ми розберемо аргументи командного рядка , якщо користувач схоче запустити цю програму з іншим розширенням екрану. Залежно від розширення екрану, сітка кульок може і не може повністю покрити екран зображувані на екрані координат О, О. centx і centy дають нам знати, де треба починати малювати масив кульок. Це буде розраховано пізніше.

History of edits (Latest: eReS 1 year, 10 months ago) §
Pages: ← previous Ctrl next
1 2 3 4 5 6 7 8