Quote: "It's a bad habit though XD"
Yeah, a bad habit I'm not going to start.
Quote: "BTW: Purely academic question, but why bother with any sprite offset? Isn't it easier to center the player with:"
I imagine the only reason the OFFSET SPRITE command exists is because of the ROTATE SPRITE command. As you know sprites are just like images and are placed in relation to the upper left corner of the sprite. The ROTATE SPRITE command rotates via that spot so if you rotate a sprite without OFFSET SPRITE it'll go around that upper left corner.
In the following code snip hold down any mouse button to OFFSET SPRITE to it's center and let go to reset it to it's starting position.
` Create a box
box 0,0,200,200,rgb(255,0,0),rgb(0,255,0),rgb(0,0,255),rgb(255,255,255)
get image 1,0,0,200,200,1
do
` Show the sprite at the mouse coordinates
sprite 1,mousex(),mousey(),1
` Check for mouse button
if mouseclick()
` Show what it's doing
text 0,0,"Sprite offset to center"
` Offset the sprite
offset sprite 1,sprite width(1)/2,sprite height(1)/2
else
` Show what it's doing
text 0,0,"Sprite not offset"
` Reset offset
offset sprite 1,0,0
endif
` Rotate the sprite
rotate sprite 1,wrapvalue(Angle)
` Increase angle
inc Angle,1
loop
Although he doesn't use ROTATE SPRITE with the player I'm sure he will eventually since he's set up the player to prepare to rotate it.
Actually (using his code) I wouldn't use the variables player.width and player.height and use SPRITE WIDTH() and SPRITE HEIGHT() directly.
// ---- Create player in centre of screen ----------------
player.x = screen width()/2
player.y = screen height()/2
Sprite player.id, player.x,player.y,player.img
// center sprite image
offset sprite player.id,sprite width(player.id)/2,sprite height(player.id)/2
Quote: "Then you wouldn't need to offset anything at all. The reason I ask as I'm always curious about the WHY when I see things being done a different way."
One of programming greatest strengths is all the different ways to do exactly the same thing. We all may have different methods but ultimately we reach the same goal.