Mittwoch, 3. August 2016

Knufftris

Knufftris - my fluffy puzzle game for iOS and Androidis available now!

Do you remember it, as I've shown how to develop your own Tetris game with GameMaker? At that time I promised that I will develop this game further - and so it was.
Today's post is to introduce you to the end result:

Knufftris

A fluffy game... just like Tetris, but cute.


Arrange the falling Knuffs of various forms so that lines get filled. Completed lines dissolve and give points.




The more Knuffs are cleared at once, the more points you get. But be careful, with the time the speed at which the Knuffs fall is getting higher and you have to prevent the game area to overflow!





Choose from ten different starting speeds and four different game area sizes and beat your and your friends highscore! Can you unlock all the achievements?

Swipe your finger across the screen to move the Knuffs. Alternatively, you can use a gamepad that is compatible with your device.



 Find the game in Apple App Store and in Google Play Store!

 Here you can find the free full version:
                         

I would be happy about feedback and support
in the form of reviews and sharing the game!

Have fun and see you next time.

Knufftris

Mein neues Spiel Knufftris ist für iOS und Android erschienen - ein knuffiges Tetris Spiel.

Erinnert ihr euch noch daran, wie ich eich gezeigt habe wie man sein eigenes Tetris Spiel mit dem GameMaker entwickelt? Damals habe ich versprochen, dass ich dieses Spiel noch weiter entwickeln werde - und so war es dann auch.
Der heutige Post soll euch das Endergebnis vorstellen:

Knufftris

Ein knuffiges Spiel... wie Tetris, aber in süß.


Ordne die herunterfallenden Knuffs verschiedener Formen so an, dass sich gefüllte Zeilen ergeben. Komplette Zeilen lösen sich auf und geben Punkte.




Je mehr Knuffs auf einmal aufgelöst werden, um so mehr Punkte gibt es. Aber Vorsicht, mit der Zeit wird die Geschwindigkeit, mit der die Knuffs herunter fallen immer größer und das Spielfeld darf nicht überlaufen!





Wähle zwischen zehn verschiedenen Startgeschwindigkeiten und vier verschiedenen Spielfeldgrößen und überbiete deinen Highscore und den deiner Freunde! Kannst du alle Errungenschaften freispielen?

Wische mit deinen Fingern über den Bildschirm um die Knuffs zu bewegen. Alternativ kannst du auch ein Gamepad verwenden, welches mit deinem Gerät kompatibel ist.


 Finde das Spiel im Apple App Store und im Google Play Store!

 Hier könnt ihr die kostenlose Vollversion finden:


                         

Ich würde mich über Feedback und Unterstützung
in Form von Bewertungen und Verbreitung sehr freuen!

Viel Spaß und bis zum nächsten Mal.

Donnerstag, 2. Juni 2016

Erstellen einer eigenen VR-Welt welche in Browsern auf allen Plattformen läuft

Lange nicht gesehen! Sorry, ich bin sehr beschäftigt ...

Heute möchte ich euch zeigen, wie man ganz einfach eine eigene VR-Erfahrung mit dem WebVR Boilerplate erstellt:
Ein THREE.js-basierter Ausgangspunkt für VR Erfahrungen, welcher sowohl Google-Cardboards als auch andere VR-Headsets unterstützt. Außerdem wird ein Fallback angeboten, der das Erleben des gleichen Inhalts erlaubt, ohne dass eine VR-Vorrichtung erforderlich ist.
Das Ergebnis am Ende wird wie folgt aussehen:


Dieser Screenshot wurde in Chrome (Version 50.0.2661.102 m) ohne den VR-Modus gemacht.
Ihr könnt es selbst auf http://badtoxic.de/webvr begutachten.
Wenn euer Browser mit dem VR-Modus kompatibel ist, seht ihr einen kleinen Cardboard-Button in der rechten unteren Ecke. Ich habe den VR-Modus mit Android, iOS (Safari auf dem iPhone 6+, iOS 9.3.2) und einem speziellem Chromium-Build auf meinem PC mit einer HTC Vive getestet. Ihr könnt auch eine Firefox Nightly Version mit dem Oculus Rift Enabler verwenden.
Für weitere Infos könnt ihr webvr.info besuchen.

Los geht's

1. Zuerst solltet ihr Boris’ WebVR Boilerplate repo klonen oder herunterladen
git clone https://github.com/borismus/webvr-boilerplate.git

2. Dies könnt ihr dann auf euren Webserver hochladen oder einen lokalen starten, genauso, wie ihr es für jede andere Web-Anwendung tun würdet
cd webvr-boilerplate/
python -m SimpleHTTPServer 8000

Um zu testen, ob der Server läuft, öffnet localhost auf dem Port, mit dem der Server spricht. (Standard: http://localhost:8000)


Alternativ könnt ihr einen Dropbox Public-Ordner verwenden, wenn ihr einen habt, wie ich es hier gemacht habe:
Web VR BadToxic Beispiel auf Dropbox

Ihr solltet nun die Standard-Boilerplate-Szene, mit einem sich drehenden Würfel vor einem schwarzen Hintergrund mit grünen Rasterlinien sehen.


Glückwunsch! Ihr habt eure erste VR-Web-App erstellt.

3. Nun lasst uns beginnen, indem wir die Szene modifizieren - wir ersetzen das Hintergrund-Gitter mit einer Skybox-Kugel.
Als erstes lasst uns alles entfernen, was mit dem Laden der Hintergrundtextur img/box.png und der alten skybox zu tun hat. Stattdessen laden wir eine andere Textur, die wir im img-Ordner abgelegt haben - zum Beispiel ein skybox.png, welches wir vielleicht durch eine Suche nach "skybox" mit Google gefunden haben... Aber denkt stets daran, dass Texturen immer Größen von 2er-Potenzen haben müssen, wie etwa 1024x512. Ich habe dieses Bild gefunden:


Und so kann unser Code wie folgt aussehen:
var textureLoader = new THREE.TextureLoader();
var skybox;
textureLoader.load('img/skybox.png', function (skyboxTexture) {
  var skyboxMaterial = new THREE.MeshBasicMaterial();
  skyboxMaterial.map = skyboxTexture;
  skyboxMaterial.side = THREE.BackSide;

  // Create the mesh based on geometry and material
  var skyboxSphereGeometry = new THREE.SphereGeometry(50, 200, 200);
  var skyboxmesh = new THREE.Mesh(skyboxSphereGeometry, skyboxMaterial);
  skybox = new THREE.Mesh(skyboxSphereGeometry, skyboxMaterial);
  scene.add(skybox);
};

Hier haben wir einen Textur-Loader erstellt und rufen seine Funktion load auf, um unser neues Bild zu laden. Die Funktion benötigt auch eine weitere Funktion, die aufgerufen wird, wenn das Laden der Textur abgeschlossen wurde. Wenn diese asynchrone Funktion aufgerufen wird, wird das Skybox-Material mit der geladenen Textur erstellen und die Skybox instanziiert, welche wir dann zu unserer Szene hinzufügen.

4. Danach können wir unserem Würfel eine ausgefallene Textur hinzufügen. Also laden wir einfach eine andere Textur wie im vorherigen Schritt und binden diese an den Würfel.
So habe ich den folgenden Code direkt nach dem scene.add(skybox); des letzten Code-Ausschnitts hinzugefügt (in unserer asynchronen Funktion der Skybox).
textureLoader.load('img/toxicon_logo.png', function (toxiconLogoTexture) {
  var toxiconCubeGeometry = new THREE.BoxGeometry(0.5, 0.5, 0.5);
  var toxiconCubeMaterial = new THREE.MeshBasicMaterial();
  toxiconCubeMaterial.map = toxiconLogoTexture;
  toxiconCube = new THREE.Mesh(toxiconCubeGeometry, toxiconCubeMaterial);

  // Position cube mesh to be right in front of you.
  toxiconCube.position.set(0, controls.userHeight, -1);
  
  // Add cube mesh to your three.js scene
  scene.add(toxiconCube);
  
  // For high end VR devices like Vive and Oculus, take into account the stage
  // parameters provided.
  setupStage();
});



Fertig!

Also - das sollte für unser kleines Tutorial ausreichen. Unser Code resultiert nun in folgende Szene.


Dieses Mal habe ich den erwähnten Chromium-Build verwendet und den VR-Modus gestartet. Deshalb sehen wir zwei Bilder - eines für jedes Auge.
Wenn ihr Fragen oder Anregungen habt, fühlt euch frei unten die Kommentar-Funktion zu nutzen.
Und wenn ihr das komplette Projekt anschauen wollt, können ihr mich auf GitHub besuchen unter:



Vielen Dank für's Lesen - man sieht sich!
Übrigens, auch mein Mii mag VR!




Quellen:
WebVR
WebVR Boilerplate
Responsive WebVR
4 Steps to Start Experimenting with WebVR in 10 Minutes

Siehe auch:
MOZVR
WebVR Samples

Mittwoch, 1. Juni 2016

Creating your own VR world running in browsers on all platforms

Long time no see! Sorry, I'm very busy...

Today I want to show you, how you can easily create your own VR experience using WebVR Boilerplate:
A THREE.js-based starting point for VR experiences that work well in both Google Cardboard and other VR headsets. Also provides a fallback for experiencing the same content without requiring a VR device.
 The result will look like this in the end:


This screenshot was taken in Chrome (Version 50.0.2661.102 m) without the VR mode enabled.
You can check it out yourself by visiting http://badtoxic.de/webvr.
If your browser is compatible to the VR mode you will see a little cardboard button on the bottom right. I testet the VR mode with Android, iOS (Safari on iPhone 6+, iOS 9.3.2) and a special chromium build on my pc with a HTC Vive. You also can use Firefox Nightly with an Oculus Rift enabler installed.
For more info visit webvr.info.

Getting started

1. At first you should clone or download Boris’ WebVR Boilerplate repo
git clone https://github.com/borismus/webvr-boilerplate.git

2. Then you can upload this to your web server or start a local one, similar to way you’d have to spin up a server for any regular web app like
cd webvr-boilerplate/
python -m SimpleHTTPServer 8000

To test that your server is running, open up localhost on the port that your server is talking to. (Default: http://localhost:8000)

Alternatively you can use a Dropbox Public folder, if you have one, like I did here:
Web VR BadToxic example on Dropbox

You should now see the default boilerplate scene, with a spinning cube against a black background with green gridlines.



Congratulations! You just deployed your first VR web app.

3. Now let us start modifying the scene by replacing the background grid with a skybox sphere.
So first remove everything that has to do with loading the background texture img/box.png and the skybox. Instead we load another texture we placed in the img folder - for example a skybox.png we may have found via google by searching "skybox"... But remember that textures always have to have any power of 2 size like 1024x512. So I just found this image:


And so our code may look like the following:
var textureLoader = new THREE.TextureLoader();
var skybox;
textureLoader.load('img/skybox.png', function (skyboxTexture) {
  var skyboxMaterial = new THREE.MeshBasicMaterial();
  skyboxMaterial.map = skyboxTexture;
  skyboxMaterial.side = THREE.BackSide;

  // Create the mesh based on geometry and material
  var skyboxSphereGeometry = new THREE.SphereGeometry(50, 200, 200);
  var skyboxmesh = new THREE.Mesh(skyboxSphereGeometry, skyboxMaterial);
  skybox = new THREE.Mesh(skyboxSphereGeometry, skyboxMaterial);
  scene.add(skybox);
};

Here we created a texture loader and call its function load for our new image. The function also need a further function that will be called when loading the texture has finished. When this asynchronous function is called, it will create the skybox material with the loaded texture and instanciate the skybox we then add to our scene.

4. After that we may want to add some fancy texture to our cube. So we just do load another texture like in the previous step and bind it to the cube.
So I added the following code just after the scene.add(skybox); of the last one (inside our asynchronous function of the skybox).
textureLoader.load('img/toxicon_logo.png', function (toxiconLogoTexture) {
  var toxiconCubeGeometry = new THREE.BoxGeometry(0.5, 0.5, 0.5);
  var toxiconCubeMaterial = new THREE.MeshBasicMaterial();
  toxiconCubeMaterial.map = toxiconLogoTexture;
  toxiconCube = new THREE.Mesh(toxiconCubeGeometry, toxiconCubeMaterial);

  // Position cube mesh to be right in front of you.
  toxiconCube.position.set(0, controls.userHeight, -1);
  
  // Add cube mesh to your three.js scene
  scene.add(toxiconCube);
  
  // For high end VR devices like Vive and Oculus, take into account the stage
  // parameters provided.
  setupStage();
});



Finished!

So - this may be enough for our little tutorial. Our code now results in the following scene.


This time I used the mentioned chromium build and startet the VR mode. That's why we see two views - one for each eye.
If you have any questions or suggestions, feel free to use the comment function below.
And if you want to check out the complete project you can visit me on GitHub:



Thank you for reading and see you later!
BTW, also my Mii likes VR!




Sources:
WebVR
WebVR Boilerplate
Responsive WebVR
4 Steps to Start Experimenting with WebVR in 10 Minutes

See also:
MOZVR
WebVR Samples

Donnerstag, 7. Januar 2016

Create games for Nintendo's New 3DS Browser (HTML5) with GameMaker

Hi Guys,
this time I deald with trying to get a game
running in the browser on the N3DS, which was written with the GameMaker.

The Nintendo New 3DS is Nintendo's current handheld, which is able to display on its upper screen 3-dimensional images without glasses and has a lower touchscreen.


I'm going to share my findings with you here so that you can get games running on the N3DS, too.

My first step:
I want to find out at runtime whether the game is currently running on a N3DS, so that the game can adapt to this situation.


 I have written a small HTML5 application with GameMaker that displays some information about the device / program / browser, on / in which it is running. I've adjusted the resolution of this application to the 3DS touch screen size. The device has a resolution of 2 × 400 × 240 px, ie 400 × 240 px for each eye.

Just open the following address on your N3DS to see the information:

badtoxic.de/deviceTest

This information shall include the following:

1. As OS iOS is detected!
2. There is exactly one gamepad identified with the description"New Nintendo 3DS Controller".
(Done with GameMaker: Studio in version 1.4.1657)


This is what my little test application displays


So I wrote a script that determines whether it is a 3DS:

1:  /// check_gamepad_for_3ds();  
2:  // This script checks if there is exactly one gamepad that is named  
3:  // "(New) Nintendo 3DS Controller", like it's the case when the game was launched in the (New) Nintendo 3DS Browser.  
4:  // This script will also support detecting the old 3DS, even while its Browser doesn't support HTML5 (yet).  
5:  // Returns true if it's any kind of Nintendo 3DS.  
6:  // by BadToxic  
7:  global.is_3ds = false; // Is any kind of 3DS  
8:  global.is_o3ds = false; // Is the old 3DS model (also 2DS)  
9:  global.is_n3ds = false; // Is the new 3DS model  
10:  if (gamepad_is_supported()) {  
11:    if (gamepad_get_device_count() == 1) {  
12:      if (gamepad_is_connected(0)) {  
13:          
14:        var gamepad_description = gamepad_get_description(0);  
15:          
16:        global.is_o3ds = gamepad_description == "Nintendo 3DS Controller";  
17:        global.is_n3ds = gamepad_description == "New Nintendo 3DS Controller";  
18:        global.is_3ds = global.is_o3ds || global.is_n3ds;  
19:      }  
20:    }  
21:  }  
22:  return global.is_3ds;  

It should be self-explanatory in this context for people being familiar with the GameMaker scripting language or general programming.
On the screenshot you can see the
result in the OS tab - it works.

IMPORTANT (for GameMaker users):
The gamepad is not available in the first step!
It's best to use an alarm [0] = 2 event, or something like that, to this test a little bit later.
And no - the
async system event is not triggered, which can tell you about a gamepad just plugged in.

Then I also experimented with a game of mine on the N3DS, which I had already written for a browser. It seemed to me as would ten small scaled sprites slow down the game too much. So I would first start with only a few unscaled sprites or even geometric shapes only, then it might work well.
In the mentioned game it didn't help to remove all unnecessary things like particles or graphics... The basic elements were already too complex.


However, I think I will program something without GameMaker natively for the 3DS in C first - I already did a little Hello World program and I was able to run it on my device. ;) Maybe I'll tell you more about this here later.

 Other important findings for the HTML5 variant:
- Only the touch screen is usable.
- You can also control with touch.
  But this
unfortunately also brings up the lower browser bar - uncool!
- By pressing "digital down" once you get a fullscreen.
- The digital pad then is freely usable according to other gamepads.
- The A button can be used in the game.
   All other buttons trigger a function in the browser.
(
I have not yet explored as what button the A button is recognized, but I guess it's the start button.)

Do you now want to try it yourself?
Have fun and good luck!

See also:

Informationen zum Browser des Nintendo 3DS
Spezifikation von Nintendos altem 3DS Internetbrowser

Spiele mit dem GameMaker für Nintendos New 3DS Browser erstellen (HTML5)

Hallo Leute,
diesmal habe ich mich damit beschäftigt, wie man ein Spiel im Browser auf dem N3DS zum Laufen bekommt, welches mit dem GameMaker geschrieben wurde.

Der Nintendos New 3DS ist Nintendos aktueller Handheld, welcher in der Lage ist auf seinem oberen Bildschirm 3-dimensionale Bilder ohne Brille anzuzeigen und einen unteren Touchscreen besitzt.

Ich werde meine Erkenntnisse hier mit euch teilen, damit ihr selbst Spiele auf dem N3DS zum Laufen bekommen könnt.

Mein erster Schritt:
Ich möchte zur Laufzeit herausfinden, ob das Spiel aktuell auf einem N3DS ausgeführt wird, damit sich das Spiel an diese Situation anpassen kann.

Ich habe mit dem GameMaker eine kleine HTML5 Anwendung geschrieben, die etliche Informationen über das Gerät / Programm / Browser anzeigt, auf / in dem sie ausgeführt wird. Die Auflösung habe ich fest auf die 3DS TouchScreen Größe eingestellt. Das Gerät besitzt eine Auflösung von 2 × 400 × 240 px, d. h. 400 × 240 px für jedes Auge.

Öffnet einfach folgende Adresse auf eurem N3DS um die Infos auszulesen:

badtoxic.de/deviceTest

Daraus gehen folgende Informationen hervor:

1. Als OS wird iOS erkannt!
2. Es wird genau ein Gamepad erkannt mit der Bezeichnung "New Nintendo 3DS Controller".
(Verwendet wurde GameMaker: Studio in der Version 1.4.1657)

Dies zeigt mein kleines Test-Programm an


Ich habe also ein Skript geschrieben, welches feststellt, ob es sich um einen 3DS handelt:

1:  /// check_gamepad_for_3ds();  
2:  // This script checks if there is exactly one gamepad that is named  
3:  // "(New) Nintendo 3DS Controller", like it's the case when the game was launched in the (New) Nintendo 3DS Browser.  
4:  // This script will also support detecting the old 3DS, even while its Browser doesn't support HTML5 (yet).  
5:  // Returns true if it's any kind of Nintendo 3DS.  
6:  // by BadToxic  
7:  global.is_3ds = false; // Is any kind of 3DS  
8:  global.is_o3ds = false; // Is the old 3DS model (also 2DS)  
9:  global.is_n3ds = false; // Is the new 3DS model  
10:  if (gamepad_is_supported()) {  
11:    if (gamepad_get_device_count() == 1) {  
12:      if (gamepad_is_connected(0)) {  
13:          
14:        var gamepad_description = gamepad_get_description(0);  
15:          
16:        global.is_o3ds = gamepad_description == "Nintendo 3DS Controller";  
17:        global.is_n3ds = gamepad_description == "New Nintendo 3DS Controller";  
18:        global.is_3ds = global.is_o3ds || global.is_n3ds;  
19:      }  
20:    }  
21:  }  
22:  return global.is_3ds;  

Es sollte selbsterklärend sein in diesem Kontext, wenn man sich mit etwas GameMaker Skriptsprache bzw. Programmierung allgemein auskennt, auch wenn man die englischen Kommentare nicht lesen kann.
Auf dem Screenshot seht ihr im OS-Tab auch das Ergebnis - es funktioniert.

WICHTIG (für GameMaker-Kenner):
Das Gamepad ist nicht bereits im ersten Step verfügbar!
Am besten ihr nutzt ein alarm[0] = 2 - Event, oder dergleichen, um diesen Test etwas heraus zu zögern.

Und nein - der System-Async-Event wird nicht getriggert, über den man normal das Anschließen eines Gamepads wahrnehmen kann.

Ich habe dann auch mit einem Spiel von mit experimentiert auf dem N3DS, welches ich bereits für einen Browser geschrieben hatte. Mir schien es so, als würden bereits zehn kleine skalierte Sprites das Spiel zu stark einbrechen lassen. Also würde ich zunächst nur mit wenigen unskalierten Sprites oder gar nur geometrischen Formen beginnen, dann klappt das auch.
Bei genanntem Spiel hat es jedenfalls nicht mehr geholfen alles unnötige zu streichen, wie Partikel oder Grafiken die nur der Verschönerung dienen... Die grundlegenden Elemente waren einfach bereits zu komplex.

Allerdings werde ich glaub erstmal ohne GameMaker nativ etwas für den 3DS in C programmieren - ein Hello World konnte ich bereits auf meinem Gerät ausführen. ;) Dazu hier vielleicht später mehr.

Sonstige wichtige Erkenntnisse für die HTML5 Variante:
- Nur Touchscreen nutzbar.
- Dafür kann man auch mit Touch steuern.
  Dieser bringt aber leider auch die untere Browser Leiste zum Vorschein - uncool!
- Drückt man einmal "Digital Unten" bekommt man ein Vollbild.
- Das digitale Steuerkreuz ist dann im Spiel frei Nutzbar entsprechend anderer Gamepads.
- Der A-Button kann im Spiel genutzt werden.
  Alle anderen Buttons lösen eine Funktion im Browser aus.
(Als was der A-Button erkannt wird, habe ich noch nicht erforscht, aber ich befürchte als Start-Button.)

Bekommt ihr jetzt Lust es selbst auch mal zu probieren?
Viel Spaß und viel Erfolg!

Siehe auch:
Informationen zum Browser des Nintendo 3DS (Englisch)
Spezifikation von Nintendos altem 3DS Internetbrowser (Englisch)

Freitag, 25. Dezember 2015

Creating a game with GameMaker - Tetris

As promised, I will show you today the source code of a small game that I programmed. But it is not an original creation, but the reprogramming of a game that has been around a very long time - since 1984. Even today there are many new versions of it and it's still a popular pastime in many ages. Most probably know it from Nintendo consoles, others play it mid way on their smartphones.
It is TETRIS!








This game is liked to be cloned and imitated, and not least because it is so "simple". The programming, however, is perhaps not as trivial as one might think ... depending on how you implement it.
I'd like to
share my version, I made with GameMaker: Studio (version 1.4.1657) and explain a little bit to it.

Download Tetris (.zip file 867KB)



In this archive you will find the entire project, including all images and code.
Overall the game is not necessarily written beginner friendly - we want see how it's done "correctly" for learning, and let's see how it looks like. That is, the code is partly highly optimized and no unnecessary Drag'n'Drop was used. Nevertheless, I have the scripts clearly structured and extensively commented (in English).

Below are listed some individual parts of the game I want to show and explain shortly.


The Rooms:

In order for a game can be started, there must be at least one room. In Tetris, we have three rooms:
room_intro
room_title
room_game

Relevant is only room_game, the others are only prepared for bringing you directly through to the next room, for now.


The Objects:

obj_all Persistent (ubiquitous object), which is to take care of everything that can happen always and in every room.
obj_intro An object that is to take care of an intro at the very beginning of the game.
obj_title This object is to look at the title screen. From there different game modes should be available to be started.
obj_tetris_controller The controller is to look after the in-game happenings. It is the centerpiece of the game.
obj_tetris_stone This embodies a tetris block of any form.
obj_tetris_back Helper object for drawing a background.

The Scripts:

These are just five of ten scripts, which are used in the game. For the rest you can see in the attached archive.

When a new tetris stone is created a random form is passed to it. This script sets a 2D array (matrix) for any of the possible forms that determines which parts of the maximum of 4x4 large stone are set and which are not.
 ↓ tetris_set_stone_parts(form) ↓

The following two scripts are called for the currently falling stone when you press the button for a right or left turn. It assigns the set of tetris parts of the above matrix, so that the entire stone is rotated by 90°.
 ↓ tetris_stone_turn_right() ↓

 ↓ tetris_stone_turn_left() ↓

Once a stone has been moved, you can check with the next script if it collides with another stone. For this all the other stones are checked: do the boundaries of the maximum possible size of 4x4 stone parts overlap? Only if that is the case, the individual stone parts are checked. This approach is very efficient and not necessary with today's computing power... you also can implement this much easier. But as I said - this is supposed to show how make it "right". ;)
 ↓ tetris_check_collision() ↓

If a falling stone finally hit the ground or other stones (collide after moving), it can be tested with this script if lines are completed and can be cleared.
 ↓ tetris_check_for_clearing(clear_y1, clear_y2) ↓



The interaction of items:

So now you have learned about the most important parts of the game, but how do they work together? This I also want to keep short:
The object obj_tetris_controller is assigned to the room room_game in the room editor.
If the game has been started and the room was
reached, the controller will take care of everything. For example i also creates an instance of the obj_tetris_back object which is for handling the background.
The controller will now create an obj_tetris_stone instance at the top of the screen. Always after a certain time, which is set to a half of a second, or 500,000 microseconds (fall_time = 500000) in the create event of the controller, the current stone is moved one square down. This movement takes place in the step event of the controller.
What also happens in this event, is cecking various keystrokes, such as the arrow keys or WASD, to control the stone falling. Depending on what is pressed, the stone is moved to the left, right or down or is rotated by the scripts mentioned above. After each such action it is checked for collision again and if necessary the movement or turning will be reversed, because we do not want overlapping stones.
When a stone strikes down, that means reaching a specific height in the game area, or collides with a stone under it, then its movement is stopped. After this stop it's checked via tetris_check_for_clearing for completely filled rows and then a new stone will be generated at the top of the screen.

However, if fully filled lines were found, they will be removed. This process is probably the most complicated one in this program because the matrices of the stones need to be adapted and maybe stones have to be split into several pieces if the mid part(s) of these stones were cleared...
When a new stone was "thrown" in, it is to be checked if there's enough space for it. If there already a collision takes place, the playing field is full and the game therefore is over.



And so the end result looks like. It should be noted that the background was found in a Google search and the font is not by me, either. Everything else can be used freely (it will be nice to have credits to BadToxic, of course ;) ). But errors are also still included in this version - the finder will be allowed to keep them...

I know this tutorial may not be suitable for beginners, but with it you can see how GameMaker works or learn from it if you are already ready for it. ^^
Also, I would have liked it to be able to show and explain a lot more, but unfortunately I do not have the time. But if you have any questions, please feel free to comment uses this blog's
functionality - I'll try to help. :)

And at this point I will tell you that I continue with this game and will try to make something nice. ;)