Worklog for Yue

Learning BlitzMax

Return to Worklogs

Menu work2017-01-23

The menu is already working, so after the loading scene, you go to a menu in 3d, then click on play, and the menu is released to manipulate the car. When you want to return to the menu, you press the escape key, the menu is visible.

Menu simple Finish.2017-01-21

Interaction of buttons with the mouse pointer.2017-01-21

Started working on the game menu. It is relatively simple, three buttons, one to start the game, another to change graphic options and another to exit.

Radio Screen2017-01-01

Shadows Blur vs Detailed shadows2016-12-31


This is terrible, I have a performance drop that really affects the game, and although at this point is not a problem, it will be in the future when you want to put rocks and other things on the stage.

I have thought that programming wires can help, but I'm not sure what I think the best way is to reduce the terrain triangles from 200,000 to about 80,000 to make it more sustainable.

In addition I have managed to better manage the subject of shadows, if I put the light in about 10 degrees of inclination the shadow looks long and pretty, something like looks in a dusk or sunset, but if activated self-shading, triangles rise To almost a million, it is very nice to see how the shadows of the hills fall on the car, but the performance is fatal in computer.

So I will have to make changes and sacrifice graphic quality for performance, this implies that very possibly the terrain does not remain with the quality that is at the moment.


An advantage of what I can highlight in my limited knowledge about them. It is that for example it can show an animation while in the background it will load resources. This is the case, I show a static message, while background loads the terrain.

This font I've always liked, and it's called space age.ttf.

The next step is to create a load animation, a progress bar or something nice.


I've always thought that threads make things faster. But for some reason I realize that it takes the same thing a task or a little more if it is done on threads.

At the end of both doing things and learning on my own I have managed to learn better the wrong things I do, he said it because I do not know how is the right way.

Today I have been dealing with the threads, but it has been easier than other times, and it is not that it is very complicated that task, simple, to load the ground in the background, while showing a sign in Spanish of loading.

In such a case there is much to deepen in the threads, and hopefully he will get the best out of them.

Enhanced lighting and multi terrain texture2016-12-30

Splatting Test2016-12-29
The evidence of multiple textures on the ground is not that they give very good. Starting with the fact that the terrain does not react to sunlight, and it is clearer. So I have to look if I leave it with a single texture or use several.

Shadows Finish2016-12-28
Touch to know when to lose, the only way to implement correctly shadows that I can achieve, is that the sun is above the explorer, about midday in the equatorial zone of planet earth.

The panorama has changed a lot, driving the car is faster and smoother. Many ideas for a game, hopefully it happens.

The shadows - Bugs2016-12-28
The shadows seemed to be fine, then I noticed strange things in legania, that's when I started looking for a solution.

The thing is very easy, apparently I just have to make the bigger model and this way it fixes the problem.

Trial and error, unfortunately this is when I try to learn something. The shadows I have optimized, and is that when I speak of optimizing what I mean is to try again and again to find the perfect settings so that I do not lower the FPS, but I have been lucky, and I have some beautiful shadows, which If they run on my machine 8 years ago, I think they will run on any machine of these times.


Optimizing convex collider2016-12-27
Before 57 FPS.

Now 85 FPS.

I have reduced as much as possible the collider polygons.

Body Concave vs Convex2016-12-27

The colonies of the explorer can be implemented in two ways, a convex body or a concave body.
The problem is that the Concavo body produces more collisions, but is not compatible with the terrain, because it lowers the frames per second to 1. So the most viable is to use a convex body, where collisions are not so prescient , But not as serious as using a collider hub. A convex body is like putting the scanner in a plastic bag and so does the respective calculation of collisions.

Scanner chassis collider.2016-12-27
Collisions are currently being made by a cube where if the collider collides with an object, the collision will not be very real. So I have this mesh that makes the calculation for a more collision, but I have to do tests with a concave crow and a convex to know which is the best.

Finish Explorer II2016-12-27
There is always the possibility of doing things better. However I think the result for me is acceptable and the trick is to leave aside what I can not do to focus on what I can do. I have learned many things, but I believe and I hope I'm not mistaken that with what I can do a simple game, something very simple.

So I'm already reviewing the story, to understand that makes that vehicle on Mars.

Front shock absorbers on Explorer2016-12-27

Front shock absorbers.2016-12-27

4 vs 6 Wheels2016-12-27

Glass for Explorer2016-12-27

Wheels Brightness2016-12-26

Whews New Explorer2016-12-26

Other Vehicle2016-12-26

Fps Performance2016-12-24
One of the worst things that could happen to me is that I find myself with a drop in performance, where the FPS goes.

In that case I have to optimize this in some way, lowering polygons, lowering shadow quality, etc.

So no more, I go to sleep, tomorrow I have a 24-hour shift.

Bump Map Terrain.2016-12-24
A dirty trick to put bump fake, a lack of Shaders cone is to use Corel Draw and apply the effect on the texture.

Chassis explorer2016-12-24

Wheel Finish II2016-12-24
Everything is already with the tires. The next step is to think about the Martian Explorer chassis.

Wheel Finish2016-12-24
The tires were already as follows.

Maybe somebody thinks they should get some relief in the part that makes contact with the ground, but this is high technology of the year 2045, so the old technology of today is not necessary at that time. : D

Effect of brightness - Wheels2016-12-24

Test Wheel on Game2016-12-24


Texting Wheel2016-12-24

Not that it's a big deal, I guess the help came from listening to Mozart, Bach, Beethoven, Chopin, Brahms, Handel, Wagner, :)

Designing tires for the explorer.2016-12-24

My website2016-12-23
Working on my website. Over time I learned some things, I do not consider myself an expert, but the website is to put forward the project I intend to do. I believe and I feel sure that it is possible that with the learned I can do something interesting, at least for me.

Vehicle with 6 wheels2016-12-23
One of the advantages of programming in BlitzMax is that everything is at least more ordered, where you can have variables for objects with the same name, for example.

Explorer.Wheel[0].color:String = "White"
.Explorer.Chassis.color:string = "Red"

Now, for my explorer on Mars, I've put six wheels to the model. This is just a simple prototype of a cube and 6 cylinders flattened for the rims. ;)

Texture Terrain2016-12-22
One of the things I have learned is that the more we repeat what we have learned, we become experts at doing things. In such case the difference is that we know how to do them and we do not have to find the right form.

The texture for the terrain has a size of 4096 x 2 and weighs 16 megs, this texture has been put a filter in colrel Draw to simulate the orange color, in addition its seams have been arranged with the program PhotoShop with a respective plugins.

On the tires, I seem to have found a solution, said apparently because I do not really know if what I'm doing is correct, but it seems that if it is possible that the tires do not tremble.

Creating a terrain2016-12-21

Suspension wheels2016-12-20
The point is that there is always something to learn. That's what keeps
me from creating a video game, there will always be something that I do
not understand, some detail that has no solution.

I continue with the issue of the tires that jump, but here I found
a solution that only works possible on my pc and I do not know how
it would work on other computers.

The solution consists of two points, increasing the frequency
with which physics is rendered.
XWorldSetFrequency (3000)

Documentation Xors3D.
Sets the world's physics simulation frequency.

frequency Physics simulation frequency (60 fps by default)
world World handle

xUpdateWorld ( 10.0 )

Documentation Xors3D.
Animates all entities in the world, and performs
collision checking. The speed parameter allows
you affect the animation speed of all entities
at once. A value of 1.0 will animate
entities at their usual animation speed,
a value of 2.0 will animate entities at
double their animation speed, and so on.
For best results use this command once per main
loop, just before calling xRenderWorld().

speed A master control for animation speed


If these two values Correct I put them are as shown above, the tires no longer tremble as the vehicle moves.

This has some advantages that I have corrected, I previously had to create very large models thinking that that fixed the problem, now I work at scale of a normal cube created with xCreteCube

Already speaking of another thing, the learning with
BlitzMax focused on objects is very striking, although
it should be noted that I am filled with frustration that
there are things that are beyond my reach to understand,
but the fact of thinking about Xors3D encourages me to
continue With things. Another aspect is that the shaders
are really a hidden knowledge that little by little I'm
trying to break through in my curious mind.

Possible Solution2016-12-19
After resuming the project with fresh mint. I have noticed that if the frequency with which the world renders the physics increases, the tires no longer tremble, or they do it very little.

The frequency per defect is 60, but if I put it in 1000 seems to solve the problem.

I do not know if this runs correctly on other computers properly. As I have always said this is very far from making a game, rather the challenge is to get to understand how things work to trial and error.

So after understanding this, I will replant the idea of ​​making a game with Xors3D and BlitzMax, although I really do not think so, I am currently trying to understand the shaders.


' - Importar módulo Xors3D
Import xorsteam.xors3d

' - Includes Generales.

' - Init TG3D.
xSetEngineSetting( "Splash::TileSize","1")
xSetEngineSetting( "Splash::TilingTime","0.0")
xSetEngineSetting( "Splash::AfterTilingTime","0.0")

xGraphics3D( 1024, 768, 32, 0, True)
xSetBuffer ( xBackBuffer())

Include "../Generales/Includes.bmx"

Local camara:Int = xCreateCamera()
Local sol:Int = xCreateLight()
Local suelo:Int = xCreateCube()

xRotateEntity ( sol:Int, 90, 0, 0 )
xPositionEntity ( suelo:Int, 0, -2, 0 )
xScaleMesh ( suelo:Int, 200, 1, 200 )
xPositionEntity ( camara:Int,0, 2, 0 )

' - Sombras.
xCreateDSS( 1024, 1024)
xInitShadows (1024, 0, 0)
xCameraEnableShadows (camara:Int )
xLightEnableShadows ( sol,True )
xSetShadowParams(5,0.95, True, 300.0 )
xLightShadowEpsilons( sol:Int, 0.00001, 0.16 )

' - Coche.
Local chassis:Int = xCreateCube()
xScaleMesh ( chassis:Int, 1,.2, 2 )
xEntityColor( chassis:Int, 255, 0, 0 )

' Llantas.
Local llanta0:Int = xCreateCylinder(16)
xPositionEntity ( llanta0:Int, 0,0, 10 )
xScaleMesh ( llanta0:Int, .5,.15, 0.5 )
xRotateMesh ( llanta0:Int, 90, -90, 0 )

Local llanta1:Int = xCopyMesh(llanta0:Int )
Local llanta2:Int = xCopyMesh(llanta0:Int )
Local llanta3:Int = xCopyMesh(llanta0:Int )

xPositionEntity ( chassis:Int, 0, 2, 0 )
xPointEntity ( camara:Int, chassis:Int )

' - Fisica.
xEntityAddTriMeshShape( suelo:Int )
xEntityAddBoxShape( chassis:Int, 2000 )

' - Vehiculo.
xEntityCreateVehicle( chassis:Int )
xEntityAddWheel(chassis:Int, llanta0:Int )
xEntityAddWheel(chassis:Int, llanta1:Int )
xEntityAddWheel(chassis:Int, llanta2:Int )
xEntityAddWheel(chassis:Int, llanta3:Int )

xEntityWheelSetConnectionPoint( chassis:Int, 0, -1, 0, 1.3, True )
xEntityWheelSetConnectionPoint( chassis:Int, 1, 1, 0, 1.3, True )
xEntityWheelSetConnectionPoint( chassis:Int, 2, -1, 0, -1.3, True )
xEntityWheelSetConnectionPoint( chassis:Int, 3, 1, 0, -1.3, True )

xEntityWheelSetRadius( chassis:Int, 0, 0.48 )
xEntityWheelSetRadius( chassis:Int, 1, 0.48 )
xEntityWheelSetRadius( chassis:Int, 2, 0.48 )
xEntityWheelSetRadius( chassis:Int, 3, 0.48 )

xEntityWheelSetAxle( chassis:Int, 0, -1, 0, 0 )
xEntityWheelSetAxle( chassis:Int, 1, -1, 0, 0 )
xEntityWheelSetAxle( chassis:Int, 2, -1, 0, 0 )
xEntityWheelSetAxle( chassis:Int, 3, -1, 0, 0 )

For Local n:Int = 0 To 3
xEntityWheelSetMaxSuspensionForce( chassis:Int, n:Int, 20000)
xEntityWheelSetMaxSuspensionTravel( chassis:Int,n:Int, 2000 )
xEntityWheelSetSuspensionCompression ( chassis:Int, n:Int,200 )
xEntityWheelSetSuspensionDamping ( chassis:Int, n:Int,200 )

xEntityWheelSetSuspensionStiffness( chassis:Int, n:Int, 200 )
End Rem

xEntityWheelSetMaxSuspensionForce( chassis:Int, n:Int, 20000*2)
xEntityWheelSetSuspensionCompression ( chassis:Int, n:Int,20000*2 )
xEntityWheelSetSuspensionDamping ( chassis:Int, n:Int,200 )
xEntityWheelSetSuspensionStiffness( chassis:Int, n:Int, 200 )
xEntityWheelSetMaxSuspensionTravel( chassis:Int,n:Int, 2000 )
xEntityWheelSetFriction( chassis:Int, n:Int, 1 )

xEntityWheelSetSuspensionLength ( chassis:Int, n:Int, 0.5 )

xEntityDisableSleeping(chassis:Int,True )

xRotateEntity( chassis:Int, 0, 90, 0 )

xRotateEntity ( suelo,5,90,0 )

'xPhysicsDebugRender( 1 )

' - Conductor.
Local conductor:Int = xCreatePivot( chassis:Int)

Local mousespeed:Float = 0.5
camerasmoothness:Float = 4.5

Const FPS=60

xWorldSetGravity( 0, -9.81, 0 )

'xEntitySetGravity( chassis:Int, 0, -9.81*10.0, 0 )
While Not(xKeyHit(XKEY_ESCAPE))

elapsed = MilliSecs() - time
Until elapsed

ticks = elapsed / period
tween# = Float(elapsed Mod period) / Float(period)
For k=1 To ticks
time = time + period
If k = ticks Then xCaptureWorld


If xMouseDown(2) Then
cameraDist = cameraDist + (xMouseYSpeed() * mousespeed)
If cameraDist < 10 Then cameraDist = 10
If cameraDist > 100 Then cameraDist = 100
xMoveMouse xGraphicsWidth() / 2, xGraphicsHeight() / 2
mxs# = CurveValue(xMouseXSpeed() * mousespeed, mxs, camerasmoothness)
mys# = CurveValue(xMouseYSpeed() * mousespeed, mys, camerasmoothness)
camxa# = camxa - mxs Mod 360
camya# = camya + mys
If camya < 0 Then camya = 0
If camya > 45 Then camya = 45
cameraDist = cameraDist + (xMouseZSpeed() * 3)
xMoveMouse xGraphicsWidth() / 2, xGraphicsHeight() / 2
xRotateEntity camara, camya, camxa, 0.0
If cameraDist < 10 Then cameraDist = 10
If cameraDist > 100 Then cameraDist = 100

xPositionEntity camara, xEntityX(chassis), xEntityY(chassis), xEntityZ(chassis)
xMoveEntity camara, 0, 0, -cameraDist


'xTurnEntity ( chassis:Int, 1, 1, 1 )

xText ( 0, 0, xGetFPS())

If xKeyDown(xKEY_UP) Then
xEntityApplyCentralForce( chassis:Int, 0, 2000*50, 0, False )
End If

If xKeyHit(xKEY_R) Then

xPositionEntity( chassis:Int, 0, 3, 10 )
xRotateEntity ( chassis:Int, 0, 90, 0 )

End If


Function CurveValue#(newvalue#, oldvalue#, increments)
If increments > 1 Then oldvalue# = oldvalue# - (oldvalue# - newvalue#) / increments
If increments <= 1 Then oldvalue# = newvalue#
Return oldvalue#
End Function

I think that during these days I have improved in my code writing skills in Blitzmax, but apparently it is not enough. Well I have an error and it is that the tires jump, and I thought that I had solved the problem, but that only implies that it works correctly in my computer.

This really is painful, because it is not worth continuing with the project, so the partial solution was to disable the vertical synchronization, to use an algorithm of the Tween technique, where the faps should be very something so that the tremor of the tires is not visible, But as I mentioned that only works on my machine, and in others it has strange effects.


Const FPS:Int=10000
Local period:Int=10000/FPS:Int
Local elapsed:Int
Local tween:Float
Local ticks:Int
Local k:Int
Local time:Int=MilliSecs()-period

' - Bucle Principal.
While xKeyHit(XKEY_ESCAPE:Int) = False

elapsed = MilliSecs() - time
Until elapsed
ticks = elapsed / period
tween# = Float(elapsed Mod period) / Float(period)
For k=1 To ticks

time = time + period
If k = ticks Then xCaptureWorld


camara.Libre() ' Camera free.
'camara.MoverDebug( camara.camara:Int)

camara.pos(vehiculo.chassis.malla:Int) ' Pos Camera.


xRenderWorld( tween#, True )
xText ( 10, 10, "FPS : " + xGetFPS() )
xText ( 10, 30, "Motor :" + Int(vehiculo.fuerzaMotor:Float ))
xText ( 10, 50, "Freno : " + Int(vehiculo.fuerzaFreno:Float ) )
xText ( 10, 70, "Vel : " + Int(xEntityGetLinearVelocityZ( vehiculo.chassis.malla:Int,False)))



Although I can not stop thinking about a possible solution to the issue of tires, I think it is better to leave it that way.

Although I can not stop thinking about a possible solution to the issue of tires, I think it is better to leave it that way. Although as I write these lines my brain continues to look for possible solutions.

I think I'll try again one more time.

I have improved the shadow system, they look a little sharper.

I have established a very simple scenario, a terrain and four walls that allow to block that the user does not reach the end of the ground.

Fog: This does not convince me, I do not know how to apply this effect correctly and test and error is the only form, but I do not reach anything specifically, I do not know if I leave it white or the same color of the sky.

About the fog touches say a lot, do not do many things, so I have to focus on what I can do, this implies that this will not have effects of bulge maps, and other effects, because it is not programmed in Shaders, And if I get to learn shaders, I will not get anywhere in the development of the project.

Sky Sphre2016-12-12
A simple sky, which has been created with a crushed sphere on its Y axis. It is not perfect per my taste looks very good.

Fade Out / Fade In2016-12-10
Before going to sleep.

I have worked on the effects of the camera when entering a scene, and when leaving it, effect of fading and revenge. This is achieved by hooking a cube to the camera, and with the command FlipMesh, their faces are inverted, then using an algorithm their alpha is established.

Similarly I have put the Space Age.ttf source for information when loading resources in the background, and used the Blitz font to display debug info in the game. In addition, two libraries were added, DirectXC9.dll and Play.dll.

These libraries have nothing special, they are just a dirty way to hide the fonts used in the project. : D

That's it, tomorrow I have a 24-hour shift and we'll see each other on Monday.

Structure of the program.2016-12-10
The program consists of the following libraries and the executable in the root directory of the game.

Within the data directory, we find the encrypted resources of the game in iso format.

Iso files, in done are Zip files, only that I have changed the extension, in that case if you put the Zip extension, you could display its contents with a decompressor, but they are with password.

Today was the fight against the threads in BlitzMax. The idea is to load resources in the background, while showing information of what happens. So to illustrate the operation of the threads, I have created a work space called "laboratory", where I experiment things I have to learn. The result was that for some unknown reason I have to use "Delay" before the main thread loop that shows a "Loading" message while in the background a mesh is loaded.

All are really assumptions of what really happens, but if I do not use "Dealay", it does not work, and I do not know why.

In the end, this to learn in certain is very frustrating, I want someone to tell me things, but in the end this is this, trial and error.


' - Importar módulo Xors3D
Import xorsteam.xors3d
xSetEngineSetting( "Splash::TileSize","1")
xSetEngineSetting( "Splash::TilingTime","0.0")
xSetEngineSetting( "Splash::AfterTilingTime","0.0")

xGraphics3D ( 800, 600, 32, 0, True )
xSetBuffer ( xBackBuffer())

Global camara:Int
Global luz:Int

Local Hilo:TThread = CreateThread( cargarRecursos,"Hola")

Global carga:Int

Delay 50

xText( 0, 0, "LOADING")

If ThreadRunning(hilo) = False
End If


While Not xKeyHit(1)

xTurnEntity carga:Int, 0, 1, 0


Function CargarRecursos:Object( data:Object)


Delay 1
If carga:Int = 0 Then

camara:Int = xCreateCamera()
luz:Int = xCreateLight()
carga:Int = xLoadMesh("Modelos/Carga.b3d")
xPositionEntity carga:Int, 0, 0, 25



End If


Return "Fin"

End Function


A simple message of resource loading, which may very well improve in the very near future. A thread has been implemented that will load the resources in the background, in order to present a more complex analysis.

Debug Log Game2016-12-09
The Debugger exports a document in html with detailed information about what happens in development mode. Loads of resources, computer information and other things that are often of importance when solving problems.

The bug2016-12-09
When you return the written code the next day, thinking that the previous day everything was correctly, is when a logic error appears.

This error discovered today when trying to improve the speed of the wagons when being pushed by the tractor or disengaged in full motion, is based on that the brake system, for the tractor only applied to a single tire, when what was expected was That all receive equal braking force.

This implies that I fix the wagons, but I have to fix the brake system for all the tires.

In such a case this would not have been a problem if the tire on the left side of the front of the tractor is always in contact with the ground, but if it was in the air, it implied that the car would never brake.

Mass, speed, engine, friction2016-12-09
The vehicles behave differently according to these four aspects. Mass, speed, engine and friction. One of the points here is trial and error to find the most balanced point between reality and what is a game, I think it should not be so perfect, but something nice.

For example, if the wheels of the wagons have a lot of friction, when the wagon is pulled by the tractor, in the curves the wagon is turned over, just as the mass of the wagon influences. I do not consider myself an expert on these points and everything I do is based as I mentioned earlier on trial and error.

However I do not have to complicate the issue as much, and make it as simple as possible and over time improve things.

At this point I need to control the speed of the wagons, when they are not hooked to the tractor. This will allow with a push of the tractor do not go at high speed, but its behavior is a little more real, and what I think is that the parameters that I must control are the speed.

Optimizing collisions.2016-12-08
The development process involves optimizing collisions for the vehicle, where two meshes are used. The first mesh is the one that the player visualizes as a vehicle on the stage, and it is composed of 2591 polygons, the second is that the player does not visualize and has a very low number of polygons in relation to the first one. This mesh has 100 polygons.

So I've noticed that the lower the collision mesh, the better the performance. The process to create this second mesh for collisions involves exporting the model to Blender and applying a modifier that decimates the polygon numbers, then returning it to obj format and with fragmotion, removing faces that I do not think are necessary for the collision calculation, In that case the result is that of the image.

The calculation for collisions is made with a concave body, the difference with a convex body is that the collisions are more accurate.

In the following image we see the difference with a convex body and a concave body for the d system.

This same system applies to freight wagons.

Airport Cargo Game2016-12-08

A new learning project. Every time you do a task over and over again, I can consider that I become more expert on that topic and the development process is not that complicated.

I do not know if this ends in a game. I guess talking about a game as such is a goal that over time looks like if I can achieve it. The fact is that this luggage vehicle can take cars and drag them on the stage.

I am working with BlitzMax and Xors3D, where it is very nostaligic that Xors3D no longer have more support and is considered a dead project, because from my point of view is the best improvement for users of Blitz3D, this comment is based on my experience With Blitz3D.

About the game, I do not have much to say, there are many things that can be implemented, what happens is that I do not know if I can do them, but try again and again, I have more confidence. As always the idea is not to complicate myself with what is not done, and rather to focus on what I can do. At this point I want to implement resource load algorithms in the background, using threads, something that BlitzMax allows in its programming, to create a simple menu and later to plan the game playability as such. Something that worries me is I do not know anything about programming in shaders and quite possibly I find myself facing a very difficult learning curve if I decide to learn to program them, but from that.