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.

Tampilkan postingan dengan label python. Tampilkan semua postingan
Tampilkan postingan dengan label python. Tampilkan semua postingan

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.