Hi
Quote: "looking good, as always, Blendman.
your style is unique and beautiful, including the UI/Inventory items. great stuff!"
Thnak you a lot
Quote: "Quote: "I have some strange behavior sometimes"
can you describe the issues? it feels like you're using multiple shapes for some of the sprites and no spheres (which could help with some of the "sliding collision" responses if you did, as would lower friction).
"
For the sprite which moive (player, enemies), I use a circle shape.
For other sprite, I use a square shape in general.
I don't use friction.
For my game, I have used the physics I have found on an example made by you (I think), for 2D collisions sliding.
Here is the example I have changed to test for my game :
// Project: 2DSlidingCollision (Physics) and move box
// Created: 2022-december
// based on an example by virtualnomad
// set window properties
SetWindowTitle( "2DSlidingCollision (Physics)" )
global g_width, g_height
g_width = 1024
g_height = 768
SetWindowSize( g_width,g_height, 0 )
// set display properties
SetVirtualResolution( g_width,g_height ) // doesn't have to match the window
SetOrientationAllowed( 1, 1, 1, 1 ) // allow both portrait and landscape on mobile devices
SetSyncRate( 30, 0 ) // 30fps instead of 60 to save battery
SetScissor( 0,0,0,0 ) // use the maximum available screen space, no black borders
UseNewDefaultFonts( 1 ) // since version 2.0.22 we can use nicer default fonts
SetPhysicsGravity(0,0)
//~ SetPhysicsDebugOn()
//~ SetPhysicsScale(.01)
GLOBAL WallImg as Integer : WallImg = 0
GLOBAL FloorImg as Integer : FloorImg = 0
GLOBAL HatchImg as Integer : HatchImg = 0
GLOBAL Hatch = 0
GLOBAL Dump as Integer []
GLOBAL Monster as Integer []
Global monsterID
GLOBAL Player as Integer
Player = createsprite(0)
SetSpriteDepth(Player,10)
SetSpriteShape(Player,3)
SetSpritePhysicsOn(Player,2)
SetSpritePhysicsCanRotate(Player,0)
SetSpritePhysicsFriction(Player,0)
MakeMap()
GLOBAL Speed# = 100.0
AddVirtualJoystick(1, 120, GetVirtualHeight()-60, 100)
do
Move()
If GetSpriteHitTest(Hatch, GetSpriteXByOffset(Player), GetSpriteYByOffset(Player)) or GetRawKeyPressed(32) `[SPACE]
Finish# = Timer() + 3.0
SetSpriteActive(Player,0)
Repeat
Print("Escaped!")
Sync()
Until Finish# < Timer()
MakeMap()
Endif
Sync()
loop
Function MakeMap()
// delete all
For i = 0 to Dump.Length
If GetSpriteExists(Dump[i]) then DeleteSprite(Dump[i])
Next i
For i = 0 to monster.Length
If GetSpriteExists(monster[i]) then DeleteSprite(monster[i])
Next i
// create the wall/ground, hatch
j as float
j = 1 //800/640
Hatch = 0 // exit
u = 32*j
// map is 2X the size of the screen
w = (g_width*2)/u -1
h = (g_height*2)/u -1
For x = 0 to w*j
For y = 0 to h*j
If x = 0 or y = 0 or x = w*j or y = h*j // or Random(1,30) = 1
If x = 5 and y = 5
This = CreateSprite(FloorImg)
setspritecolor(this, 200,200,200, 255)
setspritesize(this, u, u)
Else
This = CreateSprite(WallImg)
setspritesize(this, u, u)
SetSpritePhysicsOn(This,1)
setspritecolor(this, 150, 150, 150, 255)
Endif
Else
If Hatch = 0 and Random(1,5) = 1
This = CreateSprite(HatchImg)
Hatch = This
setspritecolor(this, 80, 80, 80, 255)
setspritesize(this, u, u)
Else
This = CreateSprite(FloorImg)
setspritecolor(this, 200,200,200, 255)
setspritesize(this, u, u)
Endif
Endif
SetSpritePosition(This,x*32.0,y*32.0)
SetSpriteDepth(This,100)
Dump.Insert(This)
Next y
Next x
// create the Monster
u = 16
For i=0 to 10
This = CreateSprite(0)
setspritesize(this, u, u)
SetSpritePhysicsOn(This,2)
setspritecolor(this, 255, 150, 150, 255)
SetSpritePhysicsCanRotate(this,0)
SetSpritePhysicsFriction(this,0.5)
//~ SetSpritePhysicsMass(this, 5)
x = 8+i*4 // random(2,w-2)
y = 8 + (i-1)/3 // random(2,h-2)
SetSpritePosition(This,x*32.0,y*32.0)
SetSpriteDepth(This,100)
Monster.insert(this)
next
SetSpritePosition(Player,5*32.0, 5*32.0)
SetSpriteActive(Player,1)
SetViewOffset(Getspritex(Player)-G_width*0.5, getspritey(player)-g_height*0.5)
EndFunction
Function Move()
LR# = (GetRawKeyState(39) - GetRawKeyState(37))*Speed#
UD# = (GetRawKeyState(40) - GetRawKeyState(38))*Speed#
if LR#= 0
LR# = GetVirtualJoystickX(1)*Speed#
endif
if ud# = 0
UD# = GetVirtualJoystickY(1)*Speed#
endif
SetSpritePhysicsVelocity(Player,LR#,UD#)
if LR# <> 0 or UD#<> 0
SetViewOffset(Getspritex(Player)-G_width*0.5, getspritey(player)-g_height*0.5)
endif
For i= 0 to monster.length
n = monster[i]
If GetSpriteCollision(player, monster[i]) =1 or (GetSpriteDistance(player, Monster[i])<=2 and i=monsterID)
monsterID = i
exit
else
if GetSpriteDistance(player, n) >2 and (GetSpritePhysicsVelocityX(n) <>0 or GetSpritePhysicsVelocityY(n) <>0 )
SetSpritePhysicsVelocity(n,0,0)
endif
Endif
next
if monsterid>-1
If GetSpriteCollision(player, monster[monsterID]) = 0 and GetSpriteDistance(player, Monster[monsterid]) >2
SetSpritePhysicsVelocity(monster[monsterID],0,0)
monsterid=-1
Endif
Endif
EndFunction
As you can see, when you push a monster (square red) to the right or to the botom, it's ok
but not when you push the monsters to the left or to the top.
I don't know why;
Quote: "i know the demo is at a very early stage but, even without animation, etc, a few sound effects could help make it feel more like a game at this point. i generally throw a few SFX in early where it's otherwise motivating to me and a quick way to make a project feel "alive" early on.
"
Yes, but I have a problme : I'm disabled (hyperacusis), and I can't hear a sound.
So I don't know what kind of sound to use, when, et and whare I could find these sounds (without the possibility to listen to those sound to know if they are good or not, it's not easy ^^).
For the music, it's more easy, because, I can create the music in midi in a daw (on the piano roll), without listening to the music. I just hope the result is like in my mind.
AGK2 tier1 - http://www.dracaena-studio.com