Quote: "There must be something i am doing wrong!"
yes, i found it.
see Draw2Dline remarks and screenshot. start and then use the row with //OK
i made Draw2Dline2 for verifying.
#option_explicit
rem AGK 2017.9.25
rem MR 06.12.2017
// Project: TwoDThreeD
// Created: 2017-12-06
// show all errors
SetErrorMode(2)
// set window properties
SetWindowTitle( "TwoDThreeD" )
SetWindowSize( 1024, 768, 0 )
SetWindowAllowResize( 1 ) // allow the user to resize the window
// set display properties
SetVirtualResolution( 1024, 768 ) // 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
setPhysicsScale(0.2)
setPhysicsGravity(0,0)
SetPhysicsDebugOn()
SetPhysicsWallLeft(0)
setviewoffset(-120, -120)
#constant KEY_LEFT 37
#constant KEY_UP 38
#constant KEY_RIGHT 39
#constant KEY_DOWN 40
plane as integer
plane = CreateObjectPlane(20, 20)
SetObjectColor(plane, 0x80, 0x80, 0x80, 0xff)
RotateObjectLocalX(plane, 90)
SetObjectPosition(plane, 0, 0, 0)
Draw2Dline(-100, -100, 100, -100)
Draw2Dline(100, -100, 100, 100)
Draw2Dline(-100, 100, 100, 100)
Draw2Dline(-100, -100, -100, 100)
box as integer
box = Draw2Dsprite()
sphere as integer
sphere = CreateObjectSphere(0.2, 8, 8)
SetObjectPosition(sphere, 0, 0.0, 0)
SetObjectColor(sphere, 0xff, 0, 0, 0xff)
vert as float
horz as float
do
Draw2Dline2(-100, -100, 100, -100)
Draw2Dline2(100, -100, 100, 100)
Draw2Dline2(-100, 100, 100, 100)
Draw2Dline2(-100, -100, -100, 100)
vert = ( getRawKeyState(KEY_UP)-getRawKeyState(KEY_DOWN) ) * -100.0
horz = ( getRawKeyState(KEY_RIGHT)-getRawKeyState(KEY_LEFT) ) * 100.0
setSpritePhysicsImpulse(box, GetSpriteXByOffset(box), GetSpriteYByOffset(box), horz, vert)
SetObjectPosition(sphere, GetSpriteXByOffset(box) / 10.0, getobjectY(sphere), -GetSpriteyByOffset(box) / 10.0)
Print( str(ScreenFPS())+"("+str(GetSpriteXByOffset(box))+","+str(GetSpriteYByOffset(box))+")" )
Sync()
loop
function Draw2DSprite()
s as integer
s = CreateSprite(0)
SetSpriteSize(s, 10, 10)
SetSpriteColor(s, 0, 0xff, 0, 0xff)
SetSpritePositionByOffset(s, 0, 0)
SetSpritePhysicsOn(s, 2)
endfunction s
function Draw2Dline(x1 as float, y1 as float, x2 as float, y2 as float)
//function Draw2Dline(x1 as integer, y1 as integer, x2 as integer, y2 as integer)
s as integer
s = CreateSprite(0)
SetSpriteShapePolygon(s, 2, 0, 0.0, 0.0)
SetSpriteShapePolygon(s, 2, 1, x2 - x1, y2 - y1)
SetSpritePosition(s, x1, y1) //<<<<<<<<<<< Wrong
//SetSpritePositionByOffset(s, x1, y1) //OK
SetSpriteVisible(s, 0)
SetSpritePhysicsOn(s, 1)
endfunction
function Draw2Dline2(x1 as integer, y1 as integer, x2 as integer, y2 as integer)
x1=WorldToScreenX(x1)
y1=WorldToScreenY(y1)
x2=WorldToScreenX(x2)
y2=WorldToScreenY(y2)
col as integer
col = MakeColor(255,255,0)
DrawLine(x1,y1,x2,y2,col,col)
endfunction
AGK (Steam) V2017.09.25 : Windows 10 Pro 64 Bit : AMD (17.11.4) Radeon R7 265 : Mac mini OS High Sierra (10.13)