
[ad_1]
whereas attempting to make my sport, I observed which you could’t change the anchor level of sprites in pyglet.
I exploit some convoluted manner (see backside of the put up) to attract my minimap (WIP) in order that the rooms are centered and lined-up appropriately, nevertheless, I considered the next prevalence.
I’ll be utilizing the mouse pointer to direct a 2D particular person from the highest. However, if the anchor level of a sprite is the bottom-left nook of the unique picture, how are you going to make it really feel as if the anchor level is in the course of the sprite?
This will not be so necessary for the participant, however it could be hell to algorithmically management the NPC’s that battle.
Any assist and enter appreciated.
Code:
pic_img = picture.load(imgPath)
picX, picY = window.width/2,window.peak/2
pic = pyglet.sprite.Sprite(pic_img, x=picX, y=picY)
pic.rotation = roomType.ImageRotation
if pic.rotation == 0:
picX = picX - pic.width / 2
picY = picY - pic.peak / 2
elif pic.rotation == 90:
picX = picX - pic.width / 2
picY = picY + pic.peak / 2
elif pic.rotation == 180:
picX = picX + pic.width / 2
picY = picY + pic.peak / 2
elif pic.rotation == 270 or pic.rotation == -90:
picX = picX + pic.width / 2
picY = picY - pic.peak / 2
pic.x,pic.y = picX, picY
[ad_2]