PINBALL DREAMS to przeglądarkowa wersja gry mojego autorstwa
napisana w JavaScript (pierwowzór powstał na komputery Amiga).
Gra umożliwia granie poprzez ekran telefonu oraz klawiaturę komputera.
Jest jeszcze sporo do zrobienia tj. implementacja bonusów, poprawa przesuwu ekranu i dźwięku oraz dodanie obietnic, gdyż zdarzają się przekłamania symulacji.
W skrócie należy obliczyć położenie kuli przed jej narysowaniem.
JavaScript nie zawsze zdąży obliczyć całość przed narysowaniem kolejnej ramki.
Za niedługi czas zaprezentuje finalną wersję stołu Ignition, a następnie zabiorę się za inny temat.
PINBALL DREAMS is the browser port of the game written by me
in JavaScript (released for Amiga computers).
The game allows you to play through the phone screen and computer keyboard.
There is still a lot to do, such as implementing bonuses, improving screen scrolling and sound.
I have to implement JS promises because there are some instances of simulation glitches.
In short, you need to calculate the position of the ball before drawing it.
JavaScript may not always calculate the whole thing before drawing the next frame.
ASTEROIDS to przeglądarkowa gra mojego autorstwa
napisana w JavaScript (pierwowzór wykonany przez Atari w 1979 roku).
Gra umożliwia wspólne granie dwóch osób na jednej klawiaturze.
Rozgrywka wymagała napisania bezwładności statku, kolizji, efektów cząsteczkowych oraz procedur obrotów i przesunięć wielokątów.
Cieszy mnie, że rozgrywka zachowała grywalność!
Grę można znacznie rozbudować zamieniając symboliczne asteroidy na obracające się sześciany lub inne bryły trójwymiarowe.
Obecna wersja umożliwia grę tylko przy użyciu klawiatury,
w czasie testów napisałem sterowanie statkiem przy użyciu żyroskopu telefonu komórkowego,
jednak sterowanie było na tyle problematyczne, że porzuciłem ten pomysł.
ASTEROIDS online game written by me
in JavaScript (the original written by Atari in 1979).
The game allows two people to play together on one keyboard.
The gameplay involved writing the ship's inertia, collisions, particle effects, and polygon rotation and displacement procedures.
I am glad that the gameplay remains playable!
The game can be significantly expanded by turning symbolic asteroids into rotating cubes or other three-dimensional solids.
The current version allows you to play only using the keyboard, during tests I wrote the ship control using a mobile phone gyroscope,
but the control was so problematic that I abandoned this idea.
TEKSTUROWANY I CIENIOWANY SZEŚCIAN 3D czyli kolejny przykład wykorzystania JavaScript do wyświetlania grafiki trójwymiarowej z wykorzystaniem teksturowania i cieniowania.
Program nie używa zewnętrznych bibliotek (np. three.js), wykorzystuje podstawowy tryb graficzny Canvas2D, który w przeciwieństwie do WebGL nie pozwala na użycie akceleracji sprzętowej.
Najtrudniejsza w realizacji była funkcja teksturowania co wymagało przypomnienia działań na macierzach.
Teksturowanie to inaczej transformacja tekstury (kwadratu) w czworobok o różnych kątach nachylenia ramion.
Wyliczona macierz transformacji, pozwala na transformację prostokąta w romb, co wymusza rysowanie dwóch rombów, pierwszy dopasowany jest do lewego, drugi do prawego boku teksturowanej ściany.
Kolejny krok to przycięcie każdego z nich poprzez podział ściany na dwa trójkąty. Podział czworokąta na dwa trójkąty pozwala uzyskać akceptowalny efekt teksturowania.
3D CUBE TEXTURE SHADER is an example of using JavaScript to display three-dimensional graphics with the use of texturing and shading.
The program does not use external libraries (e.g. three.js), it uses the basic graphic mode of Canvas2D, which, unlike WebGL, does not allow the use of hardware acceleration.
The most difficult to implement was the texture mapping function, which required reminding of the matrix operations.
Texturing is the transformation of a texture (square) into a quadrilateral with different angles of inclination of the arms.
Computed transformation matrix, allows you to transform a rectangle into a diamond, which forces you to draw two diamonds, the first one fits the left side,
the second one fits the right side of the textured wall. The next step is to trim each of them by dividing the wall into two triangles.
Dividing a quadrilateral into two triangles allows you to obtain an acceptable texturing effect.
KULA 2D (SOCZEWKA) imitująca obiekt trójwymiarowy, to przydatny efekt, gdy chcemy uniknąć użycia grafiki 3d i wszystkiego co się z nią wiąże (sporo obliczeń, teksturowanie).
Efekt soczewki polega na wyliczeniu tablicy w oparciu o mnożenie i pierwiastkowanie, na podstawie której przekształcamy teksturę.
Złudzenie obrotu wykonujemy poprzez zmianę offsetu, podobnie jak w tunelu z tła. Zmiana rozmiaru obiektu wymaga przeliczenia tablicy przekształceń.
Rasteryzacja kuli polega na rysowaniu kolejnych pikseli linii skanującej (poziomej), gdy odległość danego piksela od środka koła jest większa od promienia koła to piksel nie należy do obiektu.
W tym przypadku koło imitujące kulę jest pokryte przekształconą teksturą. Gdy na kule narzucimy tło, uzyskamy zagięcie obrazu analogiczne jak w szklanej kuli.
2D SPHERE (LENS) imitating a three-dimensional object is a useful effect when we want to avoid the use of 3D graphics and everything related to it (a lot of calculations, texturing).
The lens effect is to compute an array based on multiplication and square root, which we use to transform the texture.
The illusion of rotation is made by changing the offset, similarly to the background tunnel. Resizing an object requires a transformation table recalculation.
Sphere rasterization consists in drawing successive pixels of the scanning line (horizontal), when the distance of a given pixel from the center of the circle is greater than the radius of the circle, then the pixel does not belong to the object.
In this case, the circle imitating a sphere is covered with a transformed texture. When we impose a background on the spheres, we obtain a bending of the image analogous to that in a glass sphere.
TUNEL NA OFFSETACH (VORTEX) to kolejny efekt jaki chciałem napisać od dawna.
Efekt tunelu uzyskujemy dzięki zwinięciu tekstury przy użyciu funkcji arcus tangens oraz pierwiastka kwadratowego.
Wrażenie lotu w tunelu powstaje poprzez przesuwanie tekstury o określony offset.
Najtrudniejsze w implementacji było uzyskanie akceptowalnej ilości klatek na sekundę.
Niezbędną prędkość działania otrzymałem poprzez tablicowanie wyliczonych pikseli oraz przezroczystości dla cieniowania głębi tunelu.
ZAPAMIĘTAJ!! Co bardzo ważne, nie należy rysować pikseli, a zmieniać kolory istniejących!
Jak zawsze dla ciekawskich komentarze w źródle strony.
TUNNEL OFFSET (VORTEX) is another effect that I have wanted to write for a long time.
The tunnel effect is achieved by folding the texture using the arctangent and square root functions.
The impression of flight in a tunnel is created by shifting the texture by a certain offset.
The most difficult thing to implement was getting an acceptable number of frames per second.
I obtained the necessary speed of operation by arraying the calculated pixels and transparency for shading the depth of the tunnel.
REMEMBER!! What is very important, do not draw pixels, but change the colors of existing ones!
As always for curious comments in the source of the page.
TWISTER to klasyczny efekt często spotykany w produkcjach demoscenowych.
Twister powstaje poprzez rysowanie pięciu ścian (w tym przypadku), ściana jest rysowana dopóki współrzędna x prawej krawędzi jest większa od współrzędnej x lewej krawędzi.
Skręcenie ścian powstaje przy pomocy funkcji sinus i cosinus, które nakładając się na siebie powodują deformację położenia na osi x.
Efekt cieniowania powstaje poprzez wyliczenie szerokości ściany co pozwala określić kolor aktualnie rysowanej linii.
Rozwinięciem efektu jest dodanie płynnie przesuwającego się tekstu przylegającego do płaszczyzny wybranej ściany.
TWISTER is a classic effect often found in demoscene productions.
Twister is created by drawing five faces (in this case), the face is drawn until the x-coordinate of the right edge is greater than the x-coordinate of the left edge.
The twisting of the walls is created by means of the sine and cosine functions, which overlap each other cause deformation of the position on the x axis.
The shading effect is created by calculating the width of the wall, which allows to determine the color of the currently drawn line.
The extension of the effect is adding smoothly moving text adjacent to the plane of the selected wall.
METABLOBS to ciekawy efekt ilustrujący oddziaływanie na siebie obiektów cząsteczkowych.
Do uzyskania efektu należy policzyć odległości każdego piksela od odległości wszystkich metaball`i.
Kolejnym krokierm jest wyliczenia pierwiastka kwadratowego otrzymanych odległości.
Wynik pierwiastkowania mnożymy przez wszystkie kolejne wyniki pierwiastkowania.
Iloczyn odległości posłuży do wyliczenia koloru pikseli łączenia się elementów.
Ustawienie wsztystkich parametrów jest dość skomplikowane.
METABLOBS is an interesting effect that illustrates the interaction of molecular objects.
To obtain the effect, the distance of each pixel from the distance of all metablobs should be counted.
The next step is to calculate the square root of the obtained distances.
Multiply the square root result by all successive square root results.
The product of the distance will be used to calculate the pixel color of the joining elements.
Setting all parameters is quite complicated.
Witam, tym razem przedstawiam efekt CIRCLE SCROLL, czyli przesuwanie tekstu po okręgu.
Aby uzyskać efekt, użyłem funkcji save, translate, rotate, drawimage i restore.
Przykład jest czytelny, ale niezbyt szybki. Kąty są wstępnie obliczone.
Hello, this time I present CIRCLE SCROLL effect, i.e. moving the text around a circle.
To get the effect i used save, translate, rotate, drawImage and restore functions.
The example is readable but not very fast. Angles are pre-calculated.
SINUS SCROLL to klasyczny efekt stosowany na demoscenie przy przesuwaniu tekstu.
Znośną prędkość programu uzyskałem dzięki funkcji context.drawImage (rysowanie liter) oraz context.setTransform (odbicie lustrzane).
Czcionka wczytywana jest z pliku fonts.gif,
falowanie tekstu powstaje przez zmianę położenia plastrów liter.
Wywołanie rysowania kolejnej klatki (ramki) odbywa się za pomocą funkcji window.requestAnimationFrame(draw).
SINE SCROLL is a classic effect used on demoscene for text scrolling.
I got the program's acceptable speed thanks to the functions context.drawImage (drawing letters) and context.setTransform (mirroring).
The font is loaded from the fonts.gif file, text waving is created by changing the position of the letter slices.
The next frame (frame) is drawn using the window.requestAnimationFrame (draw) function.
TEKSTUROWANY I CIENIOWANY TORUS 3D to kolejny przykład wykorzystania języka JavaScript do wyświetlania grafiki trójwymiarowej.
Torus to bryła obrotowa, powstająca przez obrót koła wokół osi Y (w tym przypadku). Największym problemem było teksturowanie, a konkretnie
mapowanie UV. To co sądziłem, że zajmie mi chwilę, zajęło 4 razy więcej czasu. Myliły się proporcje, zmienne U i V. Dla przypomnienia, zmienna U
to inaczej X, a V to inaczej Y ale w stosunku do tekstury, a nie obiektu 3d.
TEXTURED AND SHADED TORUS 3D is another example of using JavaScript to display three-dimensional graphics.
A torus is a solid of revolution, created by rotating a circle around the Y axis (in this case). The biggest problem was texturing,
specifically UV mapping. What I thought would take me a while took 4 times more time. The proportions, the U and V variables were wrong.
As a reminder, the U variable is analog of X, and V analog of Y, but in relation to the texture, not to 3d object.
SZEŚCIAN 3D napisany w JavaScript przy użyciu Canvas2D.
Przykład rzutowania perspektywicznego, obrotów, przesunięć, sortowania i cieniowania wielokątów.
Dla ciekawskich komentarze w źródle strony.
Cieniowanie wielokątów wykonałem w oparciu o odległość wierzchołków Z od obserwatora,
którą poprzednio wyliczyłem do sortowania ścian, tj. ściany najbliżej obserwatora rysujemy na końcu
(odległość wielokąta od obserwatora to średnia wartość współrzędnych Z).
CUBE 3D written in JavaScript using Canvas 2D.
Example of perspective projection, rotation, shifting, sorting and shading of polygons.
For curious comments in the source of the page.
I made the shading of the polygons based on the distance of the Z vertices from the observer,
which I previously calculated for sorting the walls, i.e. the walls closest to the observer are drawn at the end
(the distance of the polygon from the observer is the average value of the Z coordinates).
3D Cube, Javascript, Canvas2D.
3D Cube, Javascript, Canvas2D.
2D BUMP MAPPING (NIE SKOŃCZONE - PROBLEM Z NORMALIZACJĄ) to technika teksturowania, która symuluje niewielkie wypukłości powierzchni, bez ingerencji
w geometrię obiektu trójwymiarowego. Technika polega na użyciu tekstury, która nie jest jednak bezpośrednio wyświetlana, ale powoduje lokalne
zakłócenia (obrót) wektora normalnego. Ponieważ każdy model oświetlenia (np. oświetlenie Phonga) w jakiś sposób wiąże kąt pomiędzy promieniem
światła a wektorem normalnym, to rezultatem zakłóceń jest pojawienie się na obrazie złudzenia nierówności powierzchni.
2D BUMP MAPPING (NOT FINISHED - NORMALIZATION NOT DONE) is a texturing technique that simulates small surface bumps without intervention
into the geometry of a three-dimensional object. The technique is to use a texture which is however not directly displayed but causes local
disturbances (rotation) of the normal vector. Because every lighting model (e.g. Phong lighting) somehow relates the angle between the ray
light and the normal vector, the result of interference is the appearance of the illusion of surface unevenness in the image.
Fireworks, Javascript, Canvas2D.
Image rotation, Javascript, Canvas2D, Classic demoscene effect.