FIXED IT, Thanks 'TomToad'
In this program I make a square Sprite, I rotate it 45 degrees , and then I try to get the top half of the image in order to make a triangle sprite.
However, the Sprite turns out looking like the original diamond shaped sprite.
I just want to get the top half of the 'diamond' in order to make a 'triangle sprite'. Instead, it gets the entire diamond shape and I end up with a second 'diamond shaped' sprite.
// Project: Make a triangle sprite
// Created: 2018-11-22
// show all errors
SetErrorMode(2)
// set window properties
SetWindowTitle( "Make a Triangle sprite" )
SetWindowSize( 1200, 760, 0 )
SetWindowAllowResize( 1 ) // allow the user to resize the window
// set display properties
SetVirtualResolution( 1200, 760 ) // 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
r = MakeColor(255,65,0)
y = MakeColor(200,200,0)
b = MakeColor(0,65,255)
g = MakeColor(32,255,32)
DrawBox(0,0,200,200,r,y,b,g,1)
GetImage(1,0,0,200,200)
CreateSprite(1,1)
SetSpriteOffset(1, GetSpriteWidth(1)/2,GetSpriteHeight(1)/2 )
SetSpriteAngle(1,45)
SetSpritePositionByOffset(1,600,380)
DrawSprite(1)
///Fixed it Here below //GetImage(2,460,238,740,379)
GetImage(2,460,238,280,141) `Fixed It , this is the correct line
CreateSprite(2,2)
SetSpritePosition(2,800,280)
CreateText(1, 'Sprite 1')
SetTextSize(1,30)
CreateText(2, 'Sprite 2')
SetTextSize(2,30)
SetTextPosition(1,499,221)
SetTextPosition(2,846,259)
DrawText(1)
DrawText(2)
do
SetPrintSize(34)
printc ('pointer x = ') : print (GetPointerX())
printc ('pointer y = ') : print (GetPointerY())
hit = GetSpriteHit ( GetPointerX ( ), GetPointerY ( ) )
print ('Sprite hit = ' + str(hit))
sync()
loop
So, maybe what is happening here is..... the 'GetImage() command only gets a 'square' image, and does
not get 'rectangle' images.
It gets a 'square' image based on the width of the image, even though a different height is specified.
However, working on this thesis, I still could not get this program to work properly.