| Tutorial Flash - HTML5 - Javascript - DKV

Latest Blog



23.10.2020

Virtual Lab Flash

Library untuk pengembangan laboratorium virtual dengan Flash/Animate

06.10.2020

Game Among Us

Membuat gerakan karakter seperti pada game Among Us

05.10.2020

Multimedia Interaktif Tata Surya

Membuat Multimedia Pembelajaran Interaktif tentang tata surya

04.10.2020

Animasi Rotasi Bumi 3D

Membuat animasi bumi berotasi dengan grafik 3 Dimensi

01.10.2020

Membuat Kuis Essay

Mengecek jawaban kuis essay pada aplikasi pembelajaran interaktif

12.09.2020

Membuat Game Ular Tangga

Membuat game ular tangga dengan Adobe Flash/Animate AS3

10.09.2020

Membuat Pengacak Dadu

Membuat acak dadu untuk game ular tangga/monopoly

13.07.2020

Membuat Game Onet

Membuat game mencari gambar yang sama (onet) dengan JS/HTML5

11.06.2020

Membuat Kuis CBT

Membuat kuis CBT, menyimpan nilai ke server dengan PHP dan XML

11.05.2020

Game RPG dengan HTML Canvas (Javascript)

Pengembangan game RPG dengan teknik tiling menggunakan HTML canvas


ALL BLOG

Latest Games


;
Free Games

Indonesia Soccer League

Play Indonesian Soccer League on Flash 3D Games

Handling 3D Movement on Froyo Taxi

Programming : Moving My Taxi

3D Modelling is done, next step is the coding. The easiest part when coding Froyo Taxi is moving my own taxi. Its very simple because Ariel Nehmad (Flare3D writer) has a good sample on tutorial5-Movement. I just grab the code and adjust it with new speed, acceleration and other variables and my taxi is moving on the city. However i need some lines of code to make my taxi keep on the road, so player can't crash the taxi into the buildings. Read my post about 2D calculation of Ace Trucker, i use the same method to detect the collision betwen my taxi with the road border.


froyotaxi-screenshot

Programming : Moving The Traffic Cars

This part is quite tricky. Problem with moving the traffic are :

  • There are a lot of car that moving. Each car move on their own path, in expert mode you can use some pathfinding method (ex: A Star), but i am not expert so i use the most simple car movement base on the coordinates. After write some code, i can drive my taxi around. Just imagine that your taxi is a traffic car, and now you drive around with your taxi, and record your taxi position (use simple trace code). Drive around the city and make sure you make a loop (start position same with last position). Save that trace output on an array, and you can move the "real" traffic cars using that coords.
    Look at the red track, i will record my start point, and each turn until the end point, and the result is the car_track array. roadtrack-array track-coord
  • Each car can hit each other and hit player's taxi. In this case use the 2D calculation and hitTestPoint code to detect the collision. Physic engine is the perfect stuff to detect the car collision and the respond after car hit the other. But somehow i think that Flare3D physic is quite heavy, so i decide to use my simple collision detection-its not perfectly accurate, but its work.
  • Traffic cars will stop and wait if there is another car stop in front of them. To do this you can simply using hitTestPoint. You can set some sensor with some distance, so when the sensor touch the other cars, the respond is stop the car, and wait untill the traffic is normal again. But sometime car accident will happen when the "crazy" player hit the other traffic using his taxi and create some violence. To avoid this, i simply put some logic that reset the traffic car position when the traffic car get an accident and that car's position is behind the player's taxi (in 3D world some object behind you is invisible), so when you reset the position any object behind you, player will never notice.


I build several tracks for the traffic cars, and I made sure all the road on the city are passed by the car track, so when the actual game is running player will see some cars (like in the real world). In this game I have 30 different tracks, so player will see at least one car in front of his/her taxi.

froyotaxi-screenshot

Programming : Moving The Pedestrian (human)

Done with the traffic, i can use the same method to handle the pedestrian. Basically i have to add one man model on the scene and control it. Using that model, i walk around and save my path. After get some several path, save it into an array and use it as pedestrian track. Best thing about pedestrian is, they don't have to hit each other and they will never hit by the cars. I add some random event that make the pedestrian stop and waiting for the taxi, when it does the green area will appear and if the taxi is close enough (check using distance code) the pedestrian will walking to the taxi and become the passenger.

froyotaxi-screenshot

To set the destination, you need to drive around, trace some coordinate and give the location name. When you get the passenger, simply random the destination (keep random if the destionation is too close), then you can check the distance between the taxi and the destination, the time, the fuel and the taxi fare. Next step is adding some upgrade stuff like upgrade the engine, change the taxi color, add some accesoris, put some good interface and DONE, Froyo Taxi is a 3D version of Sim Taxi.

froyotaxi-screenshot

Conclusion

I use some simple method to build the Froyo Taxi, 2D calculation for car hit detection with the road and with the other cars, simple coord movement rather than complex pathfinding, and push the poly budget to improve the perfomance because Flare3D (yet) doesn't have LOD system. We can develop any games that using complex movement with very simple method, no physic, no pathfinding, no hardcore coding. That is my point of view as half programmer half artist. Thanks.