News:

Building a 3D Ray Tracer  By stevmjon

Main Menu

Bezerk game help?

Started by Scott_Bro, October 09, 2020, 01:38:22 PM

Previous topic - Next topic

ScottieBro1

Kevin can you show me with a working upgrade with robots moving???

kevin

  Too busy with Website (login required) stuff currently.

stevmjon

i did look at this some time ago and posted a demo. i think you are on the right track but just need to modify the robots a bit to be in the tiles when they cross over, and decide if they want to move even if there is a wall in the direction they want to move.
you have them stop moving if there is a wall in the direction they want to move. just add a bit more decisions they can make to move more like the youtube game video kev posted.

also, the example you posted was trying to open in fullscreen mode, but this failed on my computer (too small), and when this happens playbasic defaults to the screen size in the project > settings > screen tab.
so instead of a 320 * 200 fullscreen, this failed and instead opened default screen of 800 * 600 window. i have an RTX 3070 video card.
maybe make a bigger screen and you can scale the graphics up to suit, then make this bigger size fullscreen if it is compatible. you can use command ScreenModeExist() to check before using OpenScreen() command if you want to use fullscreen mode.
It's easy to start a program, but harder to finish it...

I think that means i am getting old and get side tracked too easy.

ScottieBro1

The maze generation is right on que. Though the secreen can be adusted.
My real question is robot A.I. Chase algorithm limited by walls.

kevin

#19
  A better option on modern systems will be a stretched  window


 



PlayBASIC Code: [Select]
   X_Screen_Res = 320
Y_Screen_Res = 200

Color_Mode = 32
Windowed_Mode = 1

OpenScreen X_Screen_Res,Y_Screen_Res,Color_Mode,Windowed_Mode
LR_ScaleWindowToDeskTop()
SetFPS 60

do
cls 0

lockbuffer
for ylp=0 to GetSurfaceHeight()-1
for xlp=0 to GetSurfaceWidth()-1
DotC xlp,ylp,(xlp*ylp)*Offset
next
next
unlockbuffer
offset++
sync
loop






type tWindow_RECT
X1,Y1
X2,Y2
endtype

linkdll "user32.dll"
LR_SetWindowPos(hwnd,hWndInsertAfter,x,y,cx,cy,wFlags) alias "SetWindowPos" As integer
LR_GetWindowRect(hwnd,RectPointer) alias "GetWindowRect" As integer
LR_GetClientRect(hwnd,RectPointer) alias "GetClientRect" As integer
Endlinkdll



Function LR_ScaleWindowToDeskTop()

// Get the Desk top width/height
local dtw=GetDesktopWidth()
local dth=GetDesktopHeight()*0.96

// Get the PB screens size
local w#=GetScreenWidth()
local h#=GetScreenHeight()

local Ratio# = dth / h#
w# *=Ratio#

// Get the PB screens window Handle
local hwnd=GetScreenHandle()

local Xpos = (dtw - w#)/2

; Stretch the window to the size users display size
LR_SetWindowPos(hwnd,0,Xpos,0,w#,dth,0)

; Resize PB's GFX viewport to screens (the window) new client area
StretchGFXscreen

Endfunction




kevin

#20
 Scottie:


    Dude was watching this video again..  Originally I didn't get why some of the bots would not move towards the player; even when it was clear they should  The spice seems to be all in the proximate to the walls.   So if the bot is near a wall;  then it's unable to move along the axis in either direction.  Which I remember reading about before, but glossed over.  

   So we know bots are moving towards the player, at about half the speed of the player moves.  To be it looks like they handle the X and Y axis separately.   So we could compute a delta between the Bot and Player on the X axis, forming a direction the bot needs to move in order to makes it's position the same as the player.   So some value that represents LEFT =-1 / RIGHT=1 or STAND STILL=0   .  We do the same for the Y Axis.  

   After we have the movement directions; we then check if these are cancelled out by obstructions from the map.    




   FOR EACH BOT

            Compute delta X.              
            X_DELTA   =  PlayerX - BOTX
      ;  form our movement direction along this axis
            X_AXIS_MOVEMENT_DIRECTION  =  (X_DELTA < Player_Bounding_BOX_LEFT_X ) * -1
            X_AXIS_MOVEMENT_DIRECTION+=  (X_DELTA > Player_Bounding_BOX_RIGHT_X )
 
        ; Repeat this for the Y AXIS


        ;  Check the bounding box of the MAP tile the bot is standing within  
            Map_X = BOTX /  Map_TILE_WIDTH
            Map_Y = BOTY /  Map_TILE_HEIGHT

         ; Assuming the bottom 4 bits represent what walls are present within this tile  (say bit 1=left / 2 = right / 3 =floor / 4 ='s floor)

           ThisTILE = COLLISION_MAP(Map_X,Map_Y)

           if (ThisTILE)

                   //  Check if this tile has either a LEFT or RIGHT wall  (bottom pair of bits)
                   if  (ThisTILE and %0011)
                              // This tile has either a LEFT or right wall, so we'll check how close we are and cancel out the movement if need be  

                             BOT_X_MODULUS  = mod(BOTX /  Map_TILE_WIDTH)
                             if  (ThisTILE and %0001)

                                     if BOT_X_MODULUS< MIN_DISTANCE_FROM_WALL
                                             X_AXIS_MOVEMENT_DIRECTION =0   // Limit movement along this axis
                                     endif    

                             endif


                             // does this tile has a RIGHT wall ??
                             if  (ThisTILE and %0010)

                                     // if it does; is the bot too close to that wall ??   if so; restrict movement on this axis  
                                     if BOT_X_MODULUS> (Map_TILE_WIDTH - MIN_DISTANCE_FROM_WALL)
                                             X_AXIS_MOVEMENT_DIRECTION =0   // Limit movement along this axis
                                     endif    

                             endif

                   endif


                  //  SAME LOGIC FOR THE Y AXIS

          endif


        //  MOVE BOT  
        BOTX += X_AXIS_MOVEMENT_DIRECTION * MOVEMENT_SPEED
        BOTY += Y_AXIS_MOVEMENT_DIRECTION * MOVEMENT_SPEED
   



     This doesn't cover all of it of course as there seems to be situations where the bots will stand near each other away from ways.  Maybe they check the wall proximity  regardless if whether the wall is present or not.. I dunno...

     BOTS need full collision so they'll need to be checked against the others for impacts, walls  and all projectiles (BOTS and Players)  which is what stops them all from just ended up in the same location as the player.






ScottieBro1

Could you please intergrate I will claim level design was done by me and give you robot a.i. credits.
I would love to see a working copy.
Thanks Scottie B.