Petr Schreiber
13-07-2024, 12:29
I have an idea for a game project - THE WAREHOUSE.
You as a player wake up in a mysterious warehouse and you need to find a way out.
Goals of the project
1/ Create a fun little game I would like to publish once finished as binary for free on itch.io
- this should allow us to promote thinBASIC a bit
2/ Explore more in depth what it takes to have game with multiple possible inputs
- how to ballance gameplay to be fun with both keyboard and mouse or XBox controller
3/ Identify spaces for improvement in TBGL, other modules and maybe even in the core language itself
- I expect to run into issues here and take it as a journey to discover what could we enhance
4/ Try to share more the whole process as I think with my GitHub adventures I completely escaped the community in the last years
- while I consider GitHub to be the goto solution for development, forum is simply more fun :)
You will always find the latest version and change log in this first post.
Please note the first post will never contain spoilers for the game, but further posts down the thread will have big spoiler potentail.
If you want to just enjoy the game, stick to this post, if you want to learn a bit along the way, please do not hesitate to follow the development.
Status of the project
In development, there is nothing to really play yet, but you are welcome to try current versions :)
Change log
Version 0.1 - Provides title screen to "game" transition. You can try to walk with XBox controller or Mouse and Keyboard in a huge empty environment
Version 0.2 - Populates warehouse with crates and allows jumping around
Petr
Petr Schreiber
13-07-2024, 12:40
Version 0.1 is very basic, and not entertaining yet, but features few core elements.
Title screen
The game starts with title screen, which seems basic, but implements the mechanics mentioned further - displaying key descriptions from controller config (not just hardwired values into string prompt).
Note that the displayed character for A button on XBOX controller is custom, and part of the font in the area which would be otherwise not used. So I "steal" characters with ASCII codes 252 - 255 for XBox buttons.
The animation is done in rudimental way of randomly picked camera angles, which are interpolated in linear way.
The whole aesthetic of the game will be closer to 2000's titles, riding on the retrowave which I enjoy a lot in games currently.
State transition mechanics
I would like to offer a regular structure to the game, that is some title screen, main menu, game itself and maybe some other states.
To achieve this, there is a concept of State, which has always the same interface:
- Initialize
- DrawFrame
- ProcessInput
- Deinitialize
All these functions take always as input StateContext, which allows to pin custom data for each state and process input in generic way.
Standard interface allows standard handling - so no crazy "IFs" for menu, game, ... everything handled in the same way and structure.
Control bindings
I try to play with unified interface allowing controls via keyboard, mouse and XBox controller for now.
It is an interesting exercise in understanding how XBox controller works on low level, and how to make the code easy to read on the high level.
For now the control keys are hardwired in controller.tbasicu, but already stored in a structure which will in time allow hopefully a proper user control binding.
Petr
Lionheart008
14-07-2024, 04:24
Good Idea with this Game petr :)
I am using only Keyboard Keys to move in 3d Scene a,s,d,w. Mouse coordinates would be good how to know where your Position is.
And perhaps a primitive Objekt AS reference. In Center If Scene or a XYZ Axis Line Cross. I have No more Idea If tbgl entities.. sorry.. I have only for me included a simple Pyramide for Testing ..
Good luck and have fun with this Game, Bye Frank
Lionheart008
14-07-2024, 15:43
Good sunday afternoon petr, in
Perhaps you can Insert a voxel in your Warehouse they shouldnt get out of the grid borderline..
And Keyboard movements you can add to Up down left right arrows with more Speed
And Draw perhaps some wals für a Labyrinth..
I am No more familiär with tbgl entity Setup.. sorry but send you Here a little example for this voxel you must only Adept in your warehouse.tbasic
'=============================================================================
'= TBGL Sample Script =
'= Moving in 3D =
'= =
'= Petr Schreiber, 2007 =
'=============================================================================
'---Load needed modules
Uses "TBGL"
uses "MATH" ' DegToRad Function
#INCLUDE "%APP_INCLUDEPATH%\thinbasic_gl.inc" ' glColor3f
Dim hWnd As Dword
'---Creates OpenGL window and returns handle
hWnd = TBGL_CreateWindowex("Moving in 3D, entity optimized - press ESC to quit", 640, 480, 32, %TBGL_WS_WINDOWED )
'---Shows TBGL window
TBGL_ShowWindow
' -- First we will create world as place to contain entities
%MY_WORLD = 1
tbgl_SceneCreate(%MY_WORLD)
' -- Our world will have two entities
%ENT_CAMERA = 1
%ENT_GRIDLIST_1 = 2
%ENT_GRIDLIST_2 = 3
%ENT_GRIDLIST_3 = 4
%ENT_GRIDLIST_4 = 5
' .. Camera
tbgl_EntityCreateCamera( %MY_WORLD, %ENT_CAMERA)
tbgl_EntitySetPos ( %MY_WORLD, %ENT_CAMERA, 0.0, 0.1, 0.0 )
' .. Grid below
tbgl_EntityCreateDLSlot( %MY_WORLD, %ENT_GRIDLIST_1, 0, CreateGridAsDList(1, -2, 20) )
' .. Grid above
tbgl_EntityCreateDLSlot( %MY_WORLD, %ENT_GRIDLIST_2, 0, CreateGridAsDList(2, 2, 20) )
' .. Grid below ' 90 degrees
tbgl_EntityCreateDLSlot( %MY_WORLD, %ENT_GRIDLIST_3, 0, CreateGridAsDList2(3, -2, 20) )
' .. Grid above '90 degrees
tbgl_EntityCreateDLSlot( %MY_WORLD, %ENT_GRIDLIST_4, 0, CreateGridAsDList2(4, 2, 20) )
' Declare Variables here
dim w as single
dim x, y, z as integer
dim scene, cubeSize as integer
dim distance as single
dim angle(2) as single
' Initialize Variables here
distance = 80
cubeSize = 20
'Create Lists here
%CUBE = 1
%SCENE = 2
tbgl_newlist %CUBE
buildCube()
tbgl_endlist
tbgl_newlist %SCENE
createScene()
tbgl_endlist
dim FrameRate as double
dim Sheeps as long
'---Resets key status before checking
TBGL_ResetKeyState()
'---Main script loop
WHILE TBGL_IsWindow(hWnd)
tbgl_translate 0.0, 0.0, -distance
tbgl_rotate angle(1), 1.0, 0.0, 0.0
tbgl_rotate angle(2), 0.0, 1.0, 0.0
tbgl_CallList %SCENE
keyboardControl()
'---Script will run on different PCs so we must assure
'---constant speed of movement by scaling movements relative to frame rate
FrameRate = TBGL_getFrameRate
'---Prepares clear frame
TBGL_ClearFrame
tbgl_SceneRender(%MY_WORLD)
TBGL_DrawFrame ' Swaps the buffers - displays rendered image
if TBGL_GetwindowKeyState( hWnd, %VK_UP) then tbgl_EntityPush(%MY_WORLD, %ENT_CAMERA, 0, 0, 5/FrameRate) ' 5 meters/second
if TBGL_GetwindowKeyState( hWnd, %VK_DOWN) then tbgl_EntityPush(%MY_WORLD, %ENT_CAMERA, 0, 0, -5/FrameRate)
if TBGL_GetwindowKeyState( hWnd, %VK_PGUP) then tbgl_EntityPush(%MY_WORLD, %ENT_CAMERA, 0, 5/FrameRate, 0 )
if TBGL_GetwindowKeyState( hWnd, %VK_PGDN) then tbgl_EntityPush(%MY_WORLD, %ENT_CAMERA, 0, -5/FrameRate, 0 )
if TBGL_GetwindowKeyState( hWnd, %VK_LEFT) then tbgl_EntityTurn(%MY_WORLD, %ENT_CAMERA, 0, 60/FrameRate, 0)
if TBGL_GetwindowKeyState( hWnd, %VK_RIGHT) then tbgl_EntityTurn(%MY_WORLD, %ENT_CAMERA, 0, -60/FrameRate, 0) ' 60°/second
if TBGL_GetwindowKeyState( hWnd, %VK_ESCAPE) then EXIT WHILE
doevents
WEND
'---Closes OpenGL window
TBGL_DestroyWindow
function buildCube() as long
TBGL_Box 1,1,1
end function
function createScene() as long
for z = -cubeSize to cubeSize
for y = -cubeSize to cubeSize
for x = -cubeSize to cubeSize
w = sqr(x*x + y*y + z*z)
if w < 20 and w > 18.75 then
tbgl_pushmatrix
tbgl_translate x, y, z
glcolor3f cos(degtorad(x*7)), cos(degtorad(y*7)), cos(degtorad(z*7))
tbgl_CallList %CUBE
tbgl_popmatrix
endif
next
next
next
end function
'-------------- GRID PLANES ------------------- //
function CreateGridAsDList(optional lList as long, lPos as long, lSize as long) as long ' Returns to which display list we save
local i, j as long
local lList1 as long
if lList = 0 then lList = 1
tbgl_NewList lList
'---Let's build a grid
tbgl_Rotate 90,0,0,1
TBGL_BeginPoly %GL_LINES ' Starts polygon definition based on 2 vertex lines
TBGL_Color 0,255,0 ' Defines color
For i = -lSize To lSize
For j = -lSize To lSize
TBGL_Vertex -lSize, lPos, j ' Adds vertex
TBGL_Vertex lSize, lPos, j ' Adds vertex
TBGL_Vertex i, lPos, -lSize ' Adds vertex
TBGL_Vertex i, lPos, lSize ' Adds vertex
Next
Next
TBGL_EndPoly
tbgl_EndList
function = lList
end sub
function CreateGridAsDList2(optional lList1 as long, lPos as long, lSize as long) as long ' Returns to which display list we save
local i, j as long
'local lList1 as long
if lList1 = 0 then lList1 = 1
tbgl_NewList lList1
tbgl_Rotate 0,0,0,1
TBGL_BeginPoly %GL_LINES ' Starts polygon definition based on 2 vertex lines
TBGL_Color 0,255,0 ' Defines color
For i = -lSize To lSize
For j = -lSize To lSize
TBGL_Vertex -lSize, lPos, j ' Adds vertex
TBGL_Vertex lSize, lPos, j ' Adds vertex
TBGL_Vertex i, lPos, -lSize ' Adds vertex'
TBGL_Vertex i, lPos, lSize ' Adds vertex
Next
Next
TBGL_EndPoly
tbgl_EndList
function = lList1
end sub
function keyboardControl() as long
if tbgl_getWindowkeystate( hWnd, %VK_RIGHT) then angle(2) += 1
if tbgl_getWindowkeystate( hWnd, %VK_LEFT) then angle(2) -= 1
if tbgl_getWindowkeystate( hWnd, %VK_UP) then angle(1) -= 1
if tbgl_getWindowkeystate( hWnd, %VK_DOWN) then angle(1) += 1
if tbgl_getWindowkeystate( hWnd, %VK_PGDN) then distance += 1
if tbgl_getWindowkeystate( hWnd, %VK_PGUP) then distance -= 1
end function
Petr Schreiber
16-07-2024, 09:59
Thank you, Frank! Nice to see your pyramid warehouse mod :)
I am now thinking about the warehouse visuals and then I will start to populate it with crates.
Crates will be a core gameplay element. Each crate will contain nothing or special "powerup" and will be destroyable.
I am now working on this part, will share once I have next step or its part ready :)
Petr
Petr Schreiber
29-07-2024, 16:58
I would like to share updated version.
Populated warehouse
The warehouse is now populated by columns of crates of the same type.
The algorithm basically generates columns of different sizes on fixed grid.
Collision detection
There is a rudimentary collision detection implemented for the boxes, so you should not be able to walk into one and you should be able to hop on the boxes.
Few quirks and bugs still there, some reminiscent of Tomb Raider corner bug :D
Jumping
SPACE / A key on XBox controller now allow framerate invariant jumping.
I hope you will have fun exploring the warehouse :)
ErosOlmi
09-08-2024, 09:42
Petr, I'm astonished about the quality and organization of the source code :eusaclap:
Really something to have a look by any thinBasic developer, me first.
And also a great example to be used to improve thinAir capability to scan source code and included files.
I've tested with a cabled XBOX Controller and is working just fine.
To have more fun ...
I've increased some parameter in order to have more speed, I like it quicker.
Also changes some data to have bigger and higher map
Really great potential for a nice 3D platform game or other kind of scripts.
Thanks a lot for this present.
Eros
Michael Hartlef
09-08-2024, 15:13
Hi Petr,
on the title screen I get a framerate between 200 and 300. Difficult to say. After pressing ENTER, it drops to 40-45, sometimes 30.
This is on a Radeon 4800U integrated GFX chip with 8 GB assigned to it.
Petr Schreiber
28-08-2024, 22:35
Dear Eros,
thank you very much!
Can you share the altered parameters? I did not optimize them in any way yet...
Dear Mike,
great to see you here! And for the helpful feedback, I will try to replicate during weekend. Thanks!
Petr
Michael Hartlef
29-08-2024, 08:46
Hi Petr,
ya since I have more time on my hands and was looking for a different dev environment, I wanted to see how TB and you guys are doing.
Was looking at some of your Bonus examples for TBGL and forgot that you can uses shaders. Awesome! :D
Combined with the speed of Oxygen, you can create some impressive apps with TB. If my bundle bug is solved, I could see using it more often.
Adding to that, Windows Defender doesn't complain about bundles I create. Not sure how Virus Scanners would act on them these days as I don't use one.
Take care
Michael
ErosOlmi
29-08-2024, 08:59
Uses thinAir\Tool\User Tools\WinDiff
... because I didn't remember what I changed.
Also tested some change in number of boxes, max box Y and size of warehouse to test thinBasic speed.
Maybe all those fixed parameters can be stored into an AppConfig XML file so they can be easily changed and shared.
Ciao
Eros
ErosOlmi
29-08-2024, 10:21
Adding to that, Windows Defender doesn't complain about bundles I create. Not sure how Virus Scanners would act on them these days as I don't use one.
It is a never ending story, a continue fight.
But I always insist doing something to improve thinBasic security and credibility.
In the company I work for we use a mix of Windows Defender (on premise and in Azure) + Cynet ( https://www.cynet.com/ ) + a remote company that monitor H24 7/7 our systems in real-time.
Cynet is very suspicious because its scanners scan deeply on application behaves and other things (that are secret to us).
The nice part is that Cynet support is that they are very responsive when there are false positive.
When I bundle some .EXE and they do not pass Cynet scan, they get informed almost immediately.
Sometimes they contact us to have more info.
In general after few hours problem is solved.
Most of the time thinBudle gives error during bundling just because AV scanner can takes longer to release bundled EXE
Thant's why thinBundle ha 2 options inside "UPX" tab in which indicates how many seconds to wait before considering passed the AV scan.
Also thinBundle checks for final executable size: most of the time when there are AV problems, final executable is much smaller than the final expected size because AV scan process interrupted thinBundle process in the middle.
So ... it's a daily fight ... that I'm also happy to fight because I always learn something new.
Petr Schreiber
01-09-2024, 17:39
Eros,
thank you for the idea with configurable parameters, I took a note. The default movement is very slow indeed :)
Mike - I was not able to confirm your observation yet, not having Radeon, but I am solving other issue, which is constant 60 FPS on NVIDIA, not able to go over that value at all :) Will investigate both.
Petr