Welcome to tridi game development

In this blog, i'll try to explain how to create game, tips and tricks to develop game, especially using my 3D engine, tridi - in English and Indonesia.

PDF Report for .NET and Python

Its has been long time i'am not writing this blog. And now, my game coding interest reach lowest level. Now i have many jobs that require mush time.

And i want to share some of my work, here. A few years ago, i have write a reporting tools using delphi, i name it RYF (you can search it on source forge), this reporting tool act like PDF reader, but you can write the document using notepad or something else. The syntax itself is relatively simple. You can download at source forge.

But, my RYF only run on windows, and i have lost latest source, and i'am to lazy to fix the mess in the source. So i create new RYF implementation from scratch using Python.

And now my python RYF has been ready and i have use it in my projects (i use python and some my secret package that can create outstanding UI).

My python RYF using PDF as output (differ from my previous RYF that has its own rendering system). Its support PNG and JPEG format. And has some new feature.

Well a few days ago i need a PDF report tool for VB .NET, i look on the net and doesnot found something that as simple as my RYF. Thanks for IronPython, now my RYF can be used in any .NET application, using ironpython to execute the python RYF.

You can download the source at www.codeplex.com

Bricks, final post.

I know, some of you can't run the game, yet. For those don't understand how to extract and run the game here i have make a simple installation. Just download bricks_tridi_complete
That file contain tridi,bricks (+model,+sound&music). You only need to run "runbricks.bat"

To download bricks files: try ftp://ryannining.hostspot.com

Final word: Bricks game is a challenging game to make. Many bricks close game that better than this game, but at least here, we learn how to make a simple 3D bricks game.

Next, i will write tutorial about making other simple game, Phong game. We can use models from bricks game.


*Minor update, download link changed to another free web hosting.

Bricks game logic

I think we will understand more if i give you a picture, here you go:




So we have 2 collision detection code for our game. First, collision with wall. This collision is simple to code, here:

if yb<-55:yb,vd=-55,(360-vd)%360
if xb<-75:xb,vd=-75,(180-vd)%360
if xb>75:xb,vd=75,(180-vd)%360

Basically that is a ball orientation modification when ball position (xb or yb) reach a limit position. % 360 (mod operator) is to ensure that vd is always in 0-359. The rules is just like light reflection we learn in physic.

Second, collision with object (box). From the picture we know that (xo,yo)-(xb,yb) is the ball motion vector. So we need this vector to check is this vector collide with one of the four side of the object (box) ?

To do it just call boxintersect with parameter is motion vector, object position and the object itself. Its return 1-4 mean on which side the vector collide.

boxintersect source code is like this. Its job to get the bounding box from tridi and create an array of line (4 line) represent each of object side. And then calculate if one of this line intersect with motion vector provided.
def boxintersect(x1,y1,x2,y2,xo,yo,o):
x1=x1-(x2-x1) # extend vector ? just to make sure ????
y1=y1-(y2-y1)
boxs=([o.bbox[0],o.bbox[2]],[o.bbox[3],o.bbox[2]],[o.bbox[3],
o.bbox[5]],[o.bbox[0],o.bbox[5]],[o.bbox[0],o.bbox[2]])
for i in range(3):
b1=boxs[i]
b2=boxs[i+1]
if lintersect(x1,y1,x2,y2,b1[0]+xo,b1[1]+yo,b2[0]+xo,b2[1]+yo):return i+1

Rendering the objects
To render objects, we need to initialize renderer, set the position of the objects(s) and submit them to tridi rendering engine. For world transformation, in this game we set the camera only once. The camera will see the coord (0,0,0) at distance (180) and from the top (0,0,0) the code is casp(0,0,0,180,0,0,0) you can try change this code to see the effect. I recommend to change the 4th and last number. Here the objects rendering code:

# draw 3d scene ===============================
tridi.scn_reset()
tridi.scn_addlights(LIGHT0)
# set object position
if vb<>0: ball.set1(xb,yb,-30,rframe*4,rframe*7,0)
else: ball.set1(xp,yp-5,-30,rframe*4,rframe*7,0)
pad.set1(xp,yp,-30,0,0,90)
wall.set1(0,13,-20,0,0,-90)
# submit objects
ball.submit()
pad.submit()
wall.submit()
# submit bricks

For bricks, we have 1 objects but we will submit it many times, depends how many bricks left on the game. Set1 parameter is (x,y,z,rota,rotb,rotc)

Player movement
To control movement of the pad, first we should get keyboard event. Keyboard event hold information about which key pressed/released. After we get the events, we can act according to the key pressed/released. The code is simple:


# handle key events =============================
x=tridi.getevents()
for e in x:
if e[0]==SDL_KEYUP:
if e[1]==SDLK_Q: running=0
if e[1]==SDLK_W and vb==0:
xb=xp
yb=yp
vb=1
vd=40+tridi.rnd(90)
if e[1] in keystate:del keystate[e[1]]
if e[0]==SDL_KEYDOWN:
keystate[e[1]]=1

if SDLK_LEFT in keystate and xp>-65: xp-=1
if SDLK_RIGHT in keystate and xp<65: xp+=1

Keystate is needed because we want to detect more than 1 key event at once. So

Lets coding, II

First, i have to make this game first and ensure that the code is simple enough but complete enough to help all of you understanding what tridi is. And from my current bricks game code, i got screenshot like this:


Ok, for the code, you can grab bricks source code. But i will update this code sometimes, so you can check again another time.

Line Intersection

This function is very crucial for this bricks game. So i have search on google and found a fast algorithm and write python version. You can view the code at mylib.py. If you want to see the detail, please visit http://www.antihax.net/2D_Line_Intersection

Trial and error

Some number of the code in the game source is created by trial and error, especially for setting the camera, setting shadow parameter, light parameter, etc. So you can try to the number on the code.

Lets start coding I

First, i have make a minimalist tridi core for download. Grab it here 3d Core. If you lazy do make the model, here the models i made. The only things you gonna change is the bricks.py

For sound effect. You can find it your self. You will need a collision sound effect when the ball bounching, crash sound effect for bricks. And maybe another sound effect you like. But we will focus at the graphics first.

If you dont need the music plugins to play SNES and PSF format, you can delete plugins folder.

Now, you should install python first, we need python just to get its "idle" python editor. You can install any version of python. Or if you prefer other editor, you can use any editor you like (and doesn't have to install python). Remember, you DONT NEED TO INSTALL PYTHON to run tridi game. Tridi has included all neccesary library and binary to run its games.

To try tridi works, extract the core to a folder and run "cmd.bat", after that a console will pop out. Now type "run.bat" and press "return". If you got Error messages, please contact me. This mean tridi isnot ready for your PC, i have try on some PC and some of them cannot run tridi. I already investigate on this issue, but i dont know yet what causing the problem.





Why using the console, to help you when you got error message.


Indonesia

Pertama, silahkan download tridi minimal disini 3d Core. Jika anda malas bikin modelnya, silahkan pakai yg saya buat disini models. Nantinya yang perlu anda ganti adalah bricks.py

Untuk suara nanti saja , aku fokusnya ke grfis dulu.

Untuk membuat kode program anda butuh editor, bisa dengan menginstall python, maka anda akan mendapatkan "idle" python editor. Atau memakai editor kesukaan anda. Ingat ,tridi tidak membutuhkan anda menginstall Python untuk menjalankan gamenya.

Untuk mencoba apakah tridi udah bisa digunakan, coba ekstrak file ke misal c:\tridi kemudian buk folder tsb, jalankan cmd.bat, setelah itu ketik run.bat dan tekan enter. Kegunaan memunculkan konsol dulu adalah anda bisa tau errornya apa. Kalau sudah nggak error nantinya pemakai tinggal menjalankan run.bat dari explorer.






Exporting blender files

The object we created before must be exported to a file format that tridi understand. I have make a special exporter, you can download here.

Extract the file, you'll get export_obj3.py. You will need to open this file using blender. But you'll need to edit it first (using text editor, like notepad).

You must delete oexport definition from line 43 to 74. And replace it with:

oexport = {'wall':(),'pad':(),'ball':(),'brick':()}

That will tell that it should export those three object that dont have animation. After you edit it. Now time to open in blender. Open the models (bricksmodel.blend) and then change the desktop template to Scripting. And then on the editor press right-click and select "open", then you must open export_obj3.py.




Make a folder in your C:\ name it MODELS. The exporter will export the file to that folder. And then when tridi engine load the file it will create a copy of the object to its cache folder. The copy is converted to binary format by tridi, to ensure fastest loading time.

To start export the models, select all models by press "a" while not in editing mode and mouse cursor in 3D window. All object should have pink outline. And then move cursor to the script editor window and then press "Alt"+"p".

Now take a look in the C:\MODELS folder. You should see 3 files. Now the texture you create before must be copied here too.

So our objects now ready to use in our game. If you make change to the blender model, you must re-export the models.


Indonesia

Objek yang sudah dibuat sebelumnya harus dikonversi/ekspor ke format yang dipahami oleh tridi. Untuk melakukannya kami telah membuat script khusus, silahkan download disini.

Buka file zip tersebut dan simpan export_obj3.py. Anda akan membukanya dengan blender (nanti) tapi sebelumnya harus diedit dulu (dengan notepad juga bisa).

Hapus baris 43 to 74. Ganti dengan:

oexport = {'wall':(),'pad':(),'ball':(),'brick':()}

Baris tersebut kan memberitahu script kalo kita hanya perlu mengkonversi 3 objek, tanpa animasi. Untuk membuka dengan blender, buka file anda (bricksmodel.blend) kemudian ganti model desktopnya ke scripting (default adalah SR2:Model). Kemudian di editor (sebelah kanan), klik kanan dan pilih menu "open", arahkan ke file export_obj3.py yang anda edit tadi.




Buatlah folder di C:\ denga nama MODELS. Program konversi akan menyimpan disitu. Anggap sebagai gudang. Nantinya tridi akan mengambil dari situ dan mengkonversinya ke format biner yang lebih cepat diload dan disimpan di folder CACHE (folder game anda).

Untuk mekonversi, pilih semua objek anda, tekan tombol "a" di 3D editor (kiri), tapi pastikan anda tidak sedang di mode edit dan kursor mouse berada disitu. Kemudian geser cursor mouse ke window Editor, tekan "Alt"+"p".

Sekarang C:\MODELS adak berisi 3 file. Kopikan juga file tekstur yang anda simpan ke sini.

Nah objek sudah siap digunakan di game anda. kalau anda melakukan perubahan model, harus diekspor ulang.

Bricks, Modelling With Blender (Indonesia)

Blender

Blender adalah program gratis untuk membuat, memanipulasi dan membuat animasi objek 3D. Dan Blender juga dimanfaatkan untuk membuat film-film animasi. Di kesempatan ini kita akan belajar memakai blender untuk membuat objek dengan teksturnya, belum menggunakan animasi.

Untuk mendownload blender terbaru silahkan: Blender 2.46 fr Windows

Memakai Blender

Pertama-tama, anda perlu memiliki panduan shortcut, berikut adalah gambar shortcut untuk 2 mode. SIlahkan download dan kalo perlu dicetak.



Atau kunjungi situs : Blender Interface

Ayo mulai memakai blender. Jalankan blender dan anda akan mendapatkan tampilan seperi ini.

Mulau membuat model Papan

Pada saat membuka blender, anda akan melihat sebuah kotak, kecuali blender sudah anda seting2. Untuk mengubah pandangan dari depan, hidupkan numlock dan tekan tombol "1" di numpad.

Pilih kotak tadi dengan klik kanan. Kemudian tekan Tab untuk masuh ke mode edit. Akan terlihat titik2 berwarna kuning/ungu. Tekan "a" 1 ato 2 kali sampe titik2 tersebut berwarna kuning.

Nah sekarang kotak tersebut perlu diskala, tekan "s" diikuti "z", maksudnya skalanya hanya untuk sumbu z saja, kemudian gerakkan mouse.

Nah, papan sudah siap. Zoom +, - menggunakan scroll mouse. Klik dan tahan tombol tengah mouse gerakkan ke bawah dan sedikit ke kiri ato kanan. Tekan "z" untuk mengubah mode preview, usahakan sampai seperti ini.

Setelah itu lepas pilihan titik-titik dengan tombol "a". Pilih 2 titik berdekatan vertikal di pojok kiri. Caranya dengan menahan tombol Shift kemudian mengklik kanan kedua titik. Tanpa menekan shift, anda akan hanya memilih 1 titik saja.

Image Hosted by ImageShack.us

Kemudian tekan "Ctrl"+e, trus pilih "Mark as seam". Lakukan untuk sudut2 yang lain (ada 4 sudut) sampai seperti ini. Kalau salah, bisa dihilangkan dengan "Clear seam"

Image Hosted by ImageShack.us

Seam digunakan blender untuk membantu proses UV unwrap. Tanpa seampun sebenernya bisa, tapi hasilnya kurang maksimal.

Setelah selesai membuat seam, mari kita ganti mode window di bawah dengan UV/Image editing.

Image Hosted by ImageShack.us

Setelah itu, letakkan cursor mouse di window bawah, kemudian pilih menu Image-&gt;New image atau menekan tomvol "Alt"+"n". Set ukurannya ke 256x256. Setelah itu, geser cursor mouse ke window 3D (atas) kemudian pilih semua titik dengan "a" (1/2 kali). Kemdian tekan tombol "u" pilih unwrap (atas sendiri). Atau arahkan cursor mouse ke window UV editing, trus tekan "e". Hasilnya seperti ini.

Image Hosted by ImageShack.usUntuk mulai menggambar tekstur, geser dulu header dari window UV/Image editing, caranya klik mouse tengah dan tahan di tulisan menu (sembarang), kemudian geser ke kiri sampai terlihat tombol pensil.Lepas mouse kemudian klik tombol pensil tersebut. nah sekarang anda bisa menggambar di window ini, untuk mengubah opsi kuas yang digunakan tekan tombol "c". Agar tampil di objek 3D pilih mode preview ke "Textured".

Image Hosted by ImageShack.us

Atau anda bisa langsung menggambar di objek 3D (3D window), namun harus mengeset mode editnya ke Texture Paint..

Image Hosted by ImageShack.us

Tip:

  • Pakai klik+tahan+drag tombol tengah mouse untuk merotasi tampilan 3D.
  • Gunakan "Shift" + langkah diatas untuk menggeser tampilan ke kiri,kanan, atas,bawah.
  • Scroll untuk zoom.
  • Numpad 1:tampilan muka, 3:samping, 7:atas

Namai objek tersebut dengan menkan tombol "n" pada 3D window. Ganti OB:Cube menjadi OB:pad. Kata OB: tidak bisa diganti :) . Tekan "n" lagi untuk menutup window properti.

Simpan file ini dengan nama bricksmodel.blend, simpan juga gambar teksturnya dengan menekan tombol "Alt"+"s" tapi cursor mouse harus di window UV editing. Beri nama "player", trus ganti type menjadi BMP (defaultnya kalo gak salah "Targa" atau "PNG").

Membuat bola

Ubah tampilan dengan "z" sampai mendapatkan mode wireframe (garis saja). Ubah pandangan dari depan ("1" numpad) klik kiri di tengah layar (di titik tengah kotak tadi), ubah dari atas ("7" numpad). Klik tengah kotak tadi. Ini supaya nanti bolanya di tengah.

Tekan tombol "spasi" pilih add-&gt;mesh-&amp;amp;amp;amp;amp;gt;icosphere. Kemudian tekan "n" (object properties) dan set LocX,LocY,LocZ ke 0,0,0. beri nama juga, sebagai "ball". Resize bola dengan menekan tombol "s" sampai seperti ini kira-kira.

Image Hosted by ImageShack.us

Mari fokus ke bola saja. Pilih kotak papan (klik kanan) kemudian tekan "h". Untuk memunculkannya lagi, tekan "Alt"+"h". Zoom ke bola kemudian tekan "tab" untuk masuk ke Edit mode.

Seperti kotak tadi, kita perlu memberikan seam ke objek bola ini. Caranya mudah, kita belah saja bola ini. Pertama lepas semua titik dengan tombol "a", kemudian dengan cara pemilihan yg khusus. Tekan "b" 2 kali sampai mendapat cursor berbentuk lingkaran. Gunakan scroll untuk membesar kecilkan lingkaran. Pilih dengan cara seperti menarik garis/menggambar ke semua titik diagonal. Kemudian tekan "tab" setelah itu tekan "Ctrl"+"e" dan pilih "mark seam".

Memilih dengan klik kanan hanya akan memilih titik yg tampak saja, sedangkan dengan "b" akan memilih titik-titik yg tidak tampak juga (titik di belakang).

Image Hosted by ImageShack.us

Setelah itu tinggal di Unwrap, pilih semua titik dengan tombol "a" kemudian tekan "u" pilih Unwrap. hasilnya akan seperti ini.

Image Hosted by ImageShack.us

Jangan lupa mengimpan file simpan juga tekstur bola sebagai ball.bmp

Untuk membuat model bata , caranya sama seperti membuat papan, atau lebih baik papannya diduplikat saja dengan "Shift"+"D". Trus untuk tekstur, buat gambar baru (New image).

  1. Beri nama "brick", set LocX,Y,Z ke 0,0,0
  2. Save texture as brick.bmp
Hasilnya kira-kira seperti ini:



Setelah puas dengan hasilnya, maka perlu dicek lagi. Pilih objek papan, tekan "n" dan set DimX, DimY, DimZ ke 2,2,0.25. Set dimensi bola ke 0.3,0.3,0.3 dan batu bata ke 1,1,0.5.

Angka-angka tersebut nantinya akan memudahkan membuat logic tubrukan antara bola dengan papan dan bata.

Terakhir, kita buat background dinding, ini diperlukan supaya efek bayangan bisa terjadi.

Tambahkan objek dengan menekan
"Space"-&gt;Add-&amp;gt;Mesh-&amp;gt;Plane. Set LocX,Y,Z ke 0,0,0.
Anda dapat menyembunyikan objek2 lain dengan menekan tombol "/" pada numpad. Masuk ke edit mode("tab").
Setelah itu tekan "w" dan pilih subdivide beberapa kali, sampai memperoleh kotak2 sebanyak 16x16. Boleh lebih atau kurang sebenarnya, tergantung selera. Nah model lembaran seperti ini tidak perlu dibuatkan semas, cukup buka editor gambar, buat texture baru (new image), ukuran 512x512 dan tekan "e" ada editor gambar untuk mendapatkan UV mapping.



Jangan lupa objek ini dinamai "wall" dan teksturnya "wall.bmp".

Nah anda sudah memiliki modelnya. Selanjutnya akan kita bahas bagaimana membuat game bricks dengan model yang sudah anda buat.

Bricks, Modelling With Blender

Blender

Blender is a free tool to create, manipulate and animate 3D objects. Actually you can make CG movie too using blender, but at this point, what we need to learn is creating object with texture using blender.

To download latest blender please go to: Blender 2.46 fr Windows

Using Blender

First, you need to know blender shortcuts, here an image of belnder shortcuts. I suggest, you download and print those images.



Or you can visit Blender Interface

Lets start using blender. First when you run blender, you got a user interface just like this.

Lets model the player pad

First open blender, you will get a box already. Now we will modify this box. Turn on your numlock. Press "1" on mumpad. This will change the view orientation from front.

Select the box using "right click" on the box. Press "tab" to enter edit Mode. When you in the edit mode you will see some yellow/pink pixel indicates model vertices. Press "a" to select/deselect all vertices. Press "a" 1 or 2 times until your vertices pixel all in yellow.

Now we will scale this model. Press "s", followed by "z" - this mean we scale the z only. Now move your mouse pointer to scale the object.

Now, you have the pad ready. Time to apply textures. Zoom in by scrolling the mouse scroll. Then Click and hold the middle mouse button and move the mouse down and little bit right or left until you got like this. Press the "z" until you got preview like this too.

After that, deselect all vertices, press "a" once or twice, until all vertices are pink. Select 2 vertices on the left side of the pad by holding the "shift" key and right-click near of the vertices.

Image Hosted by ImageShack.us

After that, press "ctrl"+"e", and select "Mark as seam". Do it on the other edges, dont forget to deselect vertices first. Until you got like this.

Image Hosted by ImageShack.us

Seam is used to help blender create UV mapping for this object. Without seam, blender still can unwrap this object, but not as good when we define seam.

After seam defined, to make a texture for this object. We have to change the bottom window. We change it to UV/Image Editing.

Image Hosted by ImageShack.us

After we change the window, we must "on" the window (move mouse cursor inside the bottom window) create new texture by press "alt"+"n" or use mouse and click the image menu. Set the new texture size 256x256. After that, select all vertices.Move your mouse cursor to 3D window (top) first then press "a". After that press "u", and select top most menu (unwrap). Or, you can press "e", if your mouse cursor is in the UV editor window (bottom). Here the result.

Image Hosted by ImageShack.usNow, to draw directly to the textures, you must scroll the UV window header (where the menu lies) by move mouse cursor to the header (anywhere, for ex, on the "UVs" menu). Click and hold the middle button and then move mouse (drag) left. Until you found pencil button. Release the mouse. Click the pencil button, then press "c" to view brush option and you ready to go. To move the image left, right, up and down click,hold and drag the middle mouse button. To zoom in and out, use mouse scroll. To draw, use left mouse click (hold) and move/draw directly on the image.

Image Hosted by ImageShack.us

Or you can draw directly to the 3D window (object) by selecting Texture Paint in the object mode selection combo.

Image Hosted by ImageShack.us

Tips:

  • Use click+hold+move/drag of the middle mouse button to rotating the view.
  • Use "Shift" + click+hold+move/drag to translate the view up/down/left/right.
  • Mouse Scroll to zoom in/out.
  • Numpad 1:front view, 3:side view, 7:Top view

Give the object name, open object properties ("n" button) and change OB:Cube to OB:pad (you cant change the OB:). Close again by press "n".

Now save this document, name it, bricksmodel.blend, then save the image too, move cursor to the UV editor press "Alt"+"s" or use menu "image". Save the image as "player.bmp", dont forget to change the image type to BMP, default type is PNG. You dont have to write the extension after the filename. Just set the image type to BMP and blender will automatically add .bmp.

So, this box width is 2 unit, and heith is 0.285 (on my file). To know about the size, press "n" in the 3D window, but you must exit the edit mode first (by pressing Tab).

Make the ball

Change the preview mode using "z" until we got wireframe mode. Change to the fron view using "1" at numpad. Click the center of the 3D window. Change to the top view (numpad "7") Again, click the center window, why we do this ? to ensure that center object we created later is at the point we click earlier.

Press "space" select add-&gt;mesh-&amp;amp;gt;icosphere. Now press "n" (object properties) and set LocX,LocY,LocZ to 0. And give name this object to "ball". Resize the ball by press "s" and move the mouse button. The ball size must be like this, compared to pad size.

Image Hosted by ImageShack.us

Lets focus on the ball. Select the "pad" object and press "h" to hide it. To un-hide, press "Alt"+"h". Select the ball, zoom the ball (mouse scroll), and change to edit mode , press "tab".

Now we have to add seams, texture, just like what we do before. Make the seams like this. To do this, first deselect all vertices (using "a"). Use special select mode, press "b" twice. Until you got circle mouse cursor. Resize the cursor using mouse scroll. Then select these vertices by left click, hold and move the cursor to those vertices. Then press tab to back to edit mode. And then make the seams using "Ctrl"+"e" and select mark as seam.

Image Hosted by ImageShack.us

By using this select method, we select all visible and invisible vertices. If we use right-click, we only can select the visible vertices. After that, we just need to create new image, size must be 256x256. And then select all vertices, and press "u" or "e" in the UV editor window. Make sure the pencil button is not pressed. And then after unwrap, press the pencil button and draw the texture (or draw directly to object).

Image Hosted by ImageShack.us

Dont forget to save the file, sometimes Blender crash (rarely). Save the texture image to as ball.bmp

To model the bricks, i think you can do the same you model the pad, or you can duplicate pad by selecting it and press "Shift"+"D" and click. The difference is only the size. But remember these :

  1. Name object as "brick", set LocX,Y,Z to 0,0,0
  2. Save texture as brick.bmp
The brick size must be like this:



Now, after you satisfied with the result, you must do final adjusment. Select pad, press "n" and set DimX, DimY, DimZ to 2,2,0.25. Set dimension for ball to 0.3,0.3,0.3 and then set brick dimension to 1,1,0.5.

Those number will help us to make gameplay logic, because tridi engine doenot have 3D collision detection we must create 2D collision using those dimension.

Last , we must make a wall for background image. We need 3D model for wall because to get "shadow" effect. Shadow only can be drawed on 3D object.

To make shadow, add object by press "Space"-&gt;Add-&amp;gt;Mesh-&amp;gt;Plane. Make this object LocX,Y,Z to 0,0,0. You can hide all other object and focus on this object by press "/" at numpad while this object selected. And then press "tab" to edit mode. After that, press "w" and select subdivide. Do it again until you got 16x16 box. You can go further but it will slow down our game. So now lets make the texture. A plane doesn't need a seam to get best UV unwrap. Just open the UV/Image editor, make a new image, but this time use 512x512 texture resolution. And then press "e" to unwrap (cursor on UV editing). You will got something like this.



Dont forget to name the object as "wall" and the texture as "wall.bmp".

Now, you have the model. Next we will learn how to start simple tridi application and loading 3D file.

Introduction to Tridi

Seriously, i dont know how to number (version) my engine. In fact, i event dont have "engine only" download (i will do it later). So you have to download Dreamworld latest binary from http://sourceforge.net/projects/tridi.

So what is Tridi ?

Tridi is a combination of 3D software rendering engine, audio/music engine, scripting engine (python), database engine (SQlite) that can be used to develop game. I create tridi using Borland Delphi 7. If you want to have the source-code you can contant me (ryannining@yahoo.com)

Tridi rendering feature:

  • Semi deffered, monochromatic light. Texture and light renderer separately, so i can modify texture stage easily (you want the source heh :) ).
  • Texture and light blended at the postprocessing stage, included in this stage is Cartoon postprocessing, Depth of Field, Blur that can be turned on and Off.
  • Light source can have shadow, shadow map or vertex shadow. So developer send vertexs and faces, buffered by tridi, and processed at once with shadow, and all effect.
  • Semi free anti-aliasing. If your game runs more than 30fps, you can get Antialiasing for free.

Tridi audio feature:

  • Play wav, mp3, Sony PSF (Playstation 1 sound music), midi
  • Multi channel, channel -1 for PSF music, 0-15 for audio

Tridi database feature:

  • SQL language support
  • Only 2 calls, db_open and db_exec, db_exec can return data (list) first row is header (column name)

Tridi scripting engine:

  • Minimal Python 2.3, only include packages: os, ntpath, traceback
  • If you want more packages, you just copy package you need in folder lib

Download latest tridi : Dreamworld RPG Latest Binary

Indonesia

Bener lom aku  gak paham cara menomori versi program. Dan sementara gak ada download versi engine saja, terpaksa anda harus download game RPG versi terbaru di situs My Tridi Files.

Apa sih Tridi itu ?

Tridi adalah kommpilasi engine grafis 3D software rendering, audio, database dan scripting. Fitur2nya adalah:

Fitur software render:

  • Semi deffered, lampu hanya warna putih. Tekstru dan lampu dirender terpisah, sehingga gampang untuk merubah renderan tekstur (mungkin anda ingin source-codenya, hubingi saya).
  • Tekstur dan lampu digabung pas proses akhir, dan anda bisa memakai efek kartun, depth of field (fokus), blur.
  • Lampu bisa memiliki bayangan, baik shadow map atau vertex shadow.
  • Kalu fps game anda lebih dari 30 maka nikmatilah antialiasing secara gratis.

Fitur audio:

  • Memainkan wav, mp3, Sony PSF (Playstation 1 sound music), midi
  • Multi channel, channel -1 untuk PSF music, 0-15 untuk audio

Fitur database:

  • SQL 
  • Hanya 2 fungsi, db_open and db_exec, db_exec bisa menghasilkan data berupa array. Baris pertama adalah nama-nama kolom

Scripting engine:

  • Minimal Python 2.3, hanya modul khusus yg dipake: os, ntpath, traceback
  • Kalau ingin modul lainnya, kopikan ke folder lib

Bricks game, Introduction

Lets starting develop using tridi engine.

This time, i will explain how to make simple Bricks game. First, bricks game is an old game that the player must control a ball by bouncing it using player pad. The ball then hit groups of boxs and make them drop or destroyed. So what we need is:

  1. Pad model
  2. Ball Model
  3. Bricks model

To model those objects, we use blender. We dont need to add animation to those objects. Just static box/ball object.

In this game we will learn:

  1. Simple object movement and rendering
  2. Simple collision
  3. Simple gameplay (just control pad)
  4. Simple 2D rendering for texts
  5. Simple lights control
  6. Simple sound, music

What you need is just download the latest Dreamworld RPG demo, and then we will modify it by removing all objects, codes. In fact, jou just need download once, extract and copy the dlls,plugins,fonts folder to other folder.

Indonesia:

Ayo mulai membuat game dengan tridi.

Kali ini, kami akan menjelaskan bagaimana caranya membuat game bricks yg sederhana. Pertama-tama, game bricks adalah game jaman dulu, dimana player harus mengontrol papan yg digunakan untuk memantulkan bola keatas mengenai tumpukan bata. Karenanya yg dibutuhkan adalah model:

  1. Papan model
  2. Bola Model
  3. Bata model

Untuk membuatnya, kami memakai blender. Dan untuk game ini tidak perlu membuat objek dengan animasi, cukup kotak dan bola saja.

Di game ini kita akan mempelajari:

  1. Animasi dan penggambaran sederhana
  2. Deteksi tubrukan
  3. Gameplay sederhana
  4. Rendering teks
  5. Pengaturan cahaya lampu
  6. Penggunaan suara dan musik

Yang anda butuhkan adalah download game Dreamworld terbaru dan mengambil hanya folder dlls,plugins,fonts-nya saja dan kopikan ke folder lain dimana game akan dibuat.

Game Database

Do we really need database in game ?

Of course we do. Although maybe we not using a database engine such MySQL, Access, we still use "database" in our game. Database is needed to hold data that can easily modified such as save game, status, items in game, characters.

In RPG game, database is used extensively. RPG game itself is like a database program. We can have stats, we can interact with NPC that can pop some dialogs. We can buy or sell items, use items, etc.

The question is, do we need Sql database on our game ?

The answer is depends on our needs. But using Sql database has advantages and disadvantages.

Advantages:

  1. We can query data easily using SQL
  2. We can edit data using external available data manager (such Microsoft Access, Navical Mysql)
  3. Well, we dont create a new engine, so can be integrated easily, and (i hope) no bug in database engine

Disadvantages:

  1. Slow
  2. Addition file (engine) or maybe server

If we create our own database engine, well maybe:

  1. Fast, we only make something we need.
  2. Small file (maybe)
  3. No file addition (engine)

But:

  1. We must deal with buggy engine.
  2. We must make data manager too to edit database.
  3. We can't use Sql query to easily filter data or join some table/data

In my game, i use Sqlite database engine. Its small footprint (200kb) and we can use Sql Query to get data easily. But in my game, i cant save BLOB type data yet. Because in my game i create a bridge between Python and Sqlite using Delphi, so - some feature are not included yet.

To edit data, i use FireFox Sqlite plugin at first. But in the end, i make a specific data editor for my game, so i can edit things easily.

Indonesia:

Apakah kita membutuhkan database di game ?

Tentu kita membutuhkannya. Meskipun mungkin kita tidak menggunakan database seperti Mysql, Ms Access, kita tetap membutuhkan "database" di game. Database digunakan untuk menyimpan data yang bersifat permanen ataupun status yg harus disimpan di file.

Di game RPG, database digunakan sangat intensif. Karena game RPG ini sendiri seperti sebuah program database, bayangkan item yg bisa anda gunakan, jual atau beli, karakter yang bisa anda ajak komunikasi, dan lain-lain.

Pertanyaannya: apakah kita membutuhkan database SQL di game ?

Jawabannya tentu tergantung kebutuhan kita. Memakai SQL database memiliki keuntungan dan rugi sebagai berikut:

Kelebihan:

  1. Bisa mengambil data dengan query filter
  2. Mengedit data menggunakan tool yg sudah ada
  3. Engine yg kita pakai setidaknya sudah teruji dan bebas bug

Kekurangan:

  1. Lambat
  2. File tambahan yg harus disertakan

Jika kita membuat sendiri engine databasenya keuntungannya:

  1. Cepat, karena kita pasti membuat sesuai kebutuhan saja
  2. Ukuran file datanya kecil (mungkin)
  3. Kecil ukurannya, tidak menambahkan file lagi diluar

Tapi:

  1. Bagaimana kalau engine kita ada bugnya ?
  2. Harus membuat data editor sendiri
  3. Tidak bisa menggunakan SQL query untuk filter

Di game yg saya buat, aku menggunakan Sqlite, ukuran engine cukup kecil, 200kb. Fiturnya lengkap, meskipun beberapa fitur belum bisa saya manfaatkan.

Untuk mengeditnya saya menggunakan Firefox Sqlite Plugin. Namun pada akhirnya saya membuat sendiri editor yg khusus untuk game yang saya buat.

My first RPG game


A few month ago, i participate in a RPG game development contest at www.gamedevid.com, of course i'm not the winner. But from that contest, i have learn may things from 3D modelling, RPG game programming, etc.

The game itself created using my 3D engine, Tridi. I use delphi and python. Delphi for 3D engine (software rendering), and python for RPG gameplay. For database, i use Sqlite.

The game itself is weird, short, not good story, not great animation, Low resolution. Because as a technical programmer i must do things that i'm not good such as creating story, character design, etc. So i do technical stuff more than artist stuff, and i dont test the game thoroughly.

Enough chit-chat, I, Ryan Widi Saputra will write my knowledge about game programming in this blog.

Download my RPG game: http://sourceforge.net/projects/tridi

I Hope you enjoy it.

Indonesia: Game RPG pertamaku

Beberapa waktu yang lalu, (kurang dari 2 bulan) saya mengikuti sebuah lomba pembuatan game RPG di forum www.gamedevid.com, hehe tentu tidak juara. Tapi dari situ aku belajar banyak tentang modeling, animasi karakter menggunakan blender.

Gamenya sendiri dibuat memakai engine 3D yang sebelumya aku buat, Tridi. Ada 2 bahasa program yang digunakan, Delphi untuk engine grafis 3Dnya dan python untuk engine game RPGnya.

Database yang digunakan adalah SQLITE,... gamenya sendiri bisa dibilang sangat aneh, pendek, tanpa cerita yang jelas. Maklumlah aku orang teknik, sedangkan game itu aku buat seorang diri mulai dari modeling, artist, story, programming. Jadinya prosenstase yg aku kerjakan lebih besar ke arah technical.

Cukup basa-basinya. Di blog ini akan saya uraikan 1 persatu tips-tips programming untuk membuat game.