Medieval Dreams

Started by William, July 12, 2023, 20:29:04

Previous topic - Next topic

Midimaster

hääää? are you kidding?

Quote... do you know are there functions for 3d text or dialogue for messages and names in openb3d or bmx? ....


Are you able to scroll?

The answer to this question is what I wrote in my last post on 2nd of Oct.
...crossing the alps with my bike at the moment

William

#46
i had thought this is a problem with openb3d but that perhaps it is execution of what the code is telling b3d to do.
it is not always the same each execution of client, sometimes the player falls through terrain at certain coordinate degrees of  entities.

terrain is at 0 Y axis but that,  player entity pivot is sometimes of Y axis coordinate degrees between after the entity is moved why is there variance not between when entitycollided and entity jumps and lands back on terrain (entityisonground=true and therefor not moved any further if entitycollided(terrain, pivot) = true.) (jumps: player moved +positive degrees in Y axis). i believe i need to develop code to compensate of the entity playerisonground=true case clause player not above terrain/on terrain below terrain, seems i may need to know manual collision and i shall post code i have in the appropriate section.

in bad english: player "falls" and player is moved to under the terrain but not on every execution of application client. sometimes playerisonground is set to false when it should be true
im still interested in oldschool app/gamedev

William

i found a culprit. collision isnt always detected and in the case that it does not detect collision the else statement its set to false. but is there any way to detect distance from the nearest points between two entity's surfaces?
im still interested in oldschool app/gamedev

William

just wanted to say that i am not entirely certain i've done the threading of the openb3d copy entity command safely or that openb3d can become safely threaded. well, it does not result in a crash (yet) but that though i close the thread it does output segmentation fault on app termination.
im still interested in oldschool app/gamedev

William

Just thought: perhaps maybe that it only appears the player falls through the terrain due to the position of the model and the pivot. not sure how to correct this as pivot is not visable to try to position them correctly.. though perhaps it is not the model for it does not happen consistently, occasionally a player can walk to the edge of the corner and occasionally the player falls through.
im still interested in oldschool app/gamedev

angros47

Quote from: William on November 13, 2023, 01:07:51is there any way to detect distance from the nearest points between two entity's surfaces?

Yes, you can use a pick (LinePick or EntityPick, for example), and then use PickedTime that returns the distance of the last pick operation.

Midimaster

Normally, the pivot would always stays (glides) on the ground, while only the mesh jumps or does strange movements. In this configuration the mesh always needs to return to Y=0, because this is the "inside" base of the pivot. So no need to check mesh against terrain. Or?

...crossing the alps with my bike at the moment

William

but how then, does the pivot stay under meshes like rocks or other objects the player may have jumped on a top of?

idk.. i dont like that style. i may, i am to consider it.
im still interested in oldschool app/gamedev

Midimaster

Good question...

The pivot controls floor altitude and it's related Y-collisions. So I would guess, the pivot needs to rise to the top level of a rock, when a rock appears.

But it is a simple rising, not a jump or a somersault. Like an elevator. And inside the elevator, the player performs a jumping action. And returns to "inside-0"
...crossing the alps with my bike at the moment

William

#54
i checked, blender says model coordinates are 0,0,0. player occasionally falls under the terrain while walking on top of it, pivot and entity coordinates match mostly,  one is -0 degrees.

this is the code:

If  PlayerTime<MilliSecs() And PlayerIsOnGround=False'And YAcceleration<>0
PlayerTime = MilliSecs()+ MOTION

YAcceleration = YAcceleration - GRAVITY

MoveEntity me.Pivot, 0,YAcceleration,0
'Print EntityY(Pivot)
If EntityY(me.Pivot)<0
'  auto floor collision or:
'PositionEntity me.Pivot, EntityX(me.Pivot), 1 , EntityZ(me.Pivot)
YAcceleration=0
EndIf
EndIf

Local pX:Int = EntityX(me.pivot)
Local pY:Int = EntityY(me.pivot)
Local pZ:Int = EntityZ(me.pivot)


Local WhoCollided:TEntity = EntityCollided(me.pivot,GroupEnvironment)
If WhoCollided=terrain
     'Print "Entity has collided with the terrain"
PlayerIsOnGround = True
ElseIf EntityY(me.pivot) > ( TerrainY(terrain, pX, pY, pZ))
PlayerIsOnGround = False
'Print "player isnt colliding with anything"
EndIf

i think it is a openb3d fault.
im still interested in oldschool app/gamedev

Midimaster

#55
The use of INTEGERs is definitely wrong, if you want to find the correct TerrainY!


This code would simplify the calculations:

(not tested)
Global YAcceleration:Float
Global PlayerIsOnGround:Int
....
Repeat
    CheckPlayerAltitude
Until...


Function CheckPlayerAltitude()
        Global PlayerTime:Int        
        If  PlayerTime > MilliSecs() Then Return

        PlayerTime     = MilliSecs() + MOTION
        YAcceleration  = YAcceleration - GRAVITY

        Local pX:Float = EntityX(Me.Pivot)
        Local pY:Float = EntityY(Me.Pivot)
        Local pZ:Float = EntityZ(Me.Pivot)
        Local pT:Float = TerrainY(Terrain, pX, pY, pZ)

        If (pY+YAcceleration) < (pT + 1.01)
            YAcceleration    = pY-(pT+1.01)
            PlayerIsOnGround = True
        Else
            PlayerIsOnGround = False
        EndIf
        MoveEntity Me.Pivot, 0, YAcceleration, 0
End Function

If you still need PlayerIsOnGround outside this function, you can keep it, but the functions itself would not longer need it.
...crossing the alps with my bike at the moment

William

#56
okay midimaster i should look into using your alternative.

well, i thought that perhaps the entity type were the culprit that perhaps the entity type used for collision were not the pivot. no, turns out its the if statement if entity Y is less than 0 then set entity y acceleration to 0 and move entity and the check that the entity collided with the terrain becomes false and the player is moved below terrain.

that was the culprit :)  during collision sometimes the player is at less than 0 before positioned. something like that.

edit: setting yacceleration to 0 triggered a cascade effect i believe. i still am uncertain it has been corrected.
im still interested in oldschool app/gamedev

William

#57
working to restructure what is already functional in this game project.. still learning how to OOP for clean code structure.

yet instead of adding more to it. but i need to get a proper index ID for any entity (will look at ECS/RandomCruft Game Engine to include to this project)

and a graphical interface that may be modified for cool game UI. i may just use CEGUI if applicable. i've been interested in other graphic engine game libs like irrlicht or something. speed, is performance comparable to a c++ compiled app?

i would like to continue with b3d or another lib if it can be repaired and certain things work in good order. i had thought of a Hit melee system in a case that a child entity collides with a player entity and maybe their shield and stuff during animation mesh movement. graphics3D has some problems, i had trouble getting full screen mode to work successfully as intended.

as well.
im still interested in oldschool app/gamedev

William

Function CheckPick()
' via camera pick from coordinates of cursor
If CameraPick(camera, MouseX(),MouseY()) = Null
Print "returned null: no entity could be picked"
Return
Else
Local Picked:TEntity=PickedEntity()
Print EntityName(picked)
'For Local s:TEntity = EachIn TPlayer.PlayerID.Keys()
    'Print EntityName(Picked) + " = " + String(TPlayer.PlayerID[picked]) ' retrieve value using index operator
'Next


Select EntityName(Picked) ' Switch Case Select for purpose to action of the picked.
Case "playerEntity"
Print "action: how to interact?"
Return String(TPlayer.PlayerID[picked]).ToInt()
End Select

EndIf
End Function


my mind barely cognicized that maybe this could use method overloading somehow but it works alright distinguishing between what kind of entity it might be when i start adding trees and rocks and stuff. i will need to come up with a generalized id system for that. https://github.com/zarosath/MedievalDreams.io see player.bmx

' load player mesh
Global Playermodel:TMesh=LoadAnimMesh("Media/models/Player/player.b3d")
HideEntity Playermodel

Type TPlayer

Global all:TList = New TList
Global PlayerID:TMap = New TMap

Field Username:String
'Field x: Float
'Field y: Float
Field PlayerIsOnGround:Int
Field YAcceleration:Float
Field playerentity:TEntity = CopyEntity(Playermodel)
Field Pivot:TPivot=CreatePivot()
Field GObj:TGNetObject
  Field id:Int
  Global lastID:Int = 0

  Method NewID()
    lastID :+ 1
    Self.id = lastID
Return Self.id
  End Method

Method printID()
Print Self.id
End Method

    Function Addme:TPlayer(Name:String)
Local loc:TPlayer = New TPlayer
EntityType(loc.pivot,GroupCharacters, True)
'EntityType(loc.playerentity,GroupCharacters, False)
ScaleEntity loc.playerentity,1,1,1
EntityParent loc.playerentity, loc.Pivot
RotateEntity(loc.playerentity, 180,0,180)
PositionEntity(loc.playerentity, 0, -1,0, True) ' position entity ground level, exactly -1 from Y radius.
EntityRadius(loc.pivot, 0.2, 1)
PositionEntity(loc.pivot,10,5.5,-5) 'general player spawn location

        loc.GObj = CreateGNetObject(Host)
        For Local i:Int= 0 To 31
        SetGNetFloat loc.GObj,i,0
        Next
      loc.Username=Name
        all.AddLast loc
        Return loc
    End Function

    Function Addplayer(Obj:TGNetObject)
        Local loc:TPlayer = New TPlayer
        loc.GObj = Obj
        All.AddLast loc
'NameEntity(loc.playerentity, "playerEntity")
PlayerID.Insert(loc.playerentity, String(loc.NewID()))
loc.playerentity.NameEntity "playerEntity"
EntityType(loc.pivot,GroupCharacters, True)
EntityPickMode(loc.playerentity,2)
EntityParent loc.playerentity, loc.Pivot
RotateEntity(loc.playerentity, 180,0,180)
PositionEntity(loc.playerentity, 0, -1,0, True) ' position entity ground level, exactly -1 from Y radius.
ScaleEntity loc.playerentity,1,1,1
EntityRadius(loc.pivot, 0.2, 1)
PositionEntity(loc.pivot,14,0.2,-15) 'general player spawn location
    End Function

   Function remove(Obj:TGnetObject)
      For Local loc:TPlayer = EachIn All
         If loc.GObj=Obj
FreeEntity(loc.playerentity)
            All.Remove loc
         EndIf
      Next
   End Function
im still interested in oldschool app/gamedev

William

im kindof a novice, i dont know how i can improve code structure here.
      For Local loc:TPlayer = EachIn TPlayer.All
 If loc.GObj=obj
 loc.set()
may be useful reference code for the section above.
im still interested in oldschool app/gamedev