I am using GetPhysicsCollision() but it doesn't seem to work the way i expect it to work
EDIT : I figured it out it was happening too quickly to see
// Project: Angry Blocks
// Created: 2017-03-02
// By Easter Bunny
/*
Hacks you should totally do
1. Infinite shots
2. Player doesn't reset position on level restart
3. Design your own levels!
4. Add some sort of scoring system
*/
SetErrorMode(2)
//init stuff
SetWindowTitle( "Angry Blocks" )
SetWindowSize( 1000,625, 0 ) //use 16:10 aspect ratio
SetVirtualResolution( 160,100 )
SetOrientationAllowed( 0, 0, 1, 1 )
SetSyncRate( 0,1 ) //unlimited framerate
UseNewDefaultFonts( 1 )
SetPhysicsDebugOn()
//by default these 4 walls are on anyway so these lines are redundant
//however if you move the viewport (using SetViewOffset(x,y), the walls will automtically be removed
//so if you ever intend to move the viewport around, you should use static physics sprites for walls at the bounds of your level
SetPhysicsWallBottom(1)
SetPhysicsWallTop(1)
SetPhysicsWallLeft(1)
SetPhysicsWallRight(1)
//I'm not sure what the default gravity is set to
//so it's best practice to manually set the gravity so you have full control over it (ie if you change it, you can change it back since you know what it is)
SetPhysicsGravity(0,50)
//it's best practice to declare your variables as this will prepare you for using more advanced languages like C++
startPad as integer
firingState as integer
levelBlocks as integer[99]
ix as float
iy as float
plr as tPlayer //set up type for player. Includes player sprite, shots remaining and firing state. Check out the type declaration at the bottom of the code
startPad=CreateSprite(0)
SetSpriteSize(startPad,10,20)
SetSpritePosition(startPad,0,80) //set to 100-20 [bottom of screen]-[height of startPad]
SetSpritePhysicsOn(startPad,1) //static
// SetSpriteVisible(startPad,0) //we'll make the sprite invisible and just use the physics debug for visualisation
plr.sprite=CreateSprite(0) //use blank [white square] image
SetSpriteSize(plr.sprite,5,5)
SetSpritePosition(plr.sprite,2,73) //75=80-5 [top of startPad]-[height of player sprite]
// SetSpriteVisible(plr.sprite,0)
SetSpriteShape(plr.sprite,1) //0=no shape, 1=circle, 2=box, 3=polygon
//setspritescale(plr.sprite, 1.0, 0.5)
SetSpritePhysicsOn(plr.sprite,2) //1=static, 2=dynamic, 3= kinematic
SetSpritePhysicsDamping(plr.sprite,0.2) //linear movement damping, basically wind resistence
SetSpritePhysicsMass(plr.sprite,5)
SetSpritePhysicsRestitution(plr.sprite,0.7) //the 'bounciness' of the sprite
plr.shots=3
plr.firingState=0
bump1 = CreateSprite(0)
SetSpriteSize(bump1, 15,15)
SetSpritePosition(bump1, 70, 30)
SetSpriteShape(bump1, 1)
SetSpritePhysicsOn(bump1, 1) //1=static, 2=dynamic, 3= kinematic
do
//print(ScreenFPS())
print("Shots remaining: "+str(plr.shots))
if plr.firingState=0
Print("Click anywhere and hold")
if GetPointerPressed()
ix=GetPointerX()
iy=GetPointerY()
plr.firingState=1
endif
elseif plr.firingState=1
Print("Drag then release to fire!")
DrawLine(GetPointerX(),GetPointerY(),ix,iy,200,200,200)
if GetPointerReleased()
dec plr.shots,1
SetSpritePhysicsVelocity(plr.sprite,(ix-GetPointerX())*10,(GetPointerY()-iy)*10)
plr.firingState=2
endif
elseif plr.firingState=2
if (GetPhysicsCollision(plr.sprite, bump1) = 1)
print("Collision!")
else
print("No collision")
endif
if plr.shots>0
print("Click to reset")
if GetPointerReleased()
SetSpritePosition(plr.sprite,2,75)
SetSpritePhysicsVelocity(plr.sprite,0,0)
SetSpritePhysicsAngularVelocity(plr.sprite,0)
plr.firingState=0
endif
else
print("")
print("Game over")
print("Click to restart game")
if GetPointerReleased()
SetSpritePosition(plr.sprite,2,75)
SetSpritePhysicsVelocity(plr.sprite,0,0)
SetSpritePhysicsAngularVelocity(plr.sprite,0)
plr.shots=3
plr.firingState=0
endif
endif
endif
Sync()
loop
type tPlayer
sprite
shots
firingState
endtype