Answered step by step
Verified Expert Solution
Question
1 Approved Answer
please make my rotating elipse appear somewhere other than the cdenter of the screen and move when the dragon gets it . code is provided
please make my rotating elipse appear somewhere other than the cdenter of the screen and move when the dragon gets it code is provided below. this is in pygames. import pygame
import random
pygame.init
# Create a display surface
WINDOWWIDTH
WINDOWHEIGHT
displaysurface pygame.display.setmodeWINDOWWIDTH, WINDOWHEIGHT
# Set FPS and clock
FPS
clock pygame.time.Clock
# Set the game values
VELOCITY
# Load images
dragonimage pygame.image.loaddragonright.png
dragonrect dragonimage.getrecttopleft
coinimages
pygame.image.loadcoinpng
pygame.image.loadcoinblue.png
pygame.image.loadcoingreen.png
coinvalues
"coin.png:
"coinblue.png:
"coingreen.png:
coinimage random.choicecoinimages
coinrect coinimage.getrectcenterWINDOWWIDTH WINDOWHEIGHT
backgroundimage pygame.image.loadstarbackground.png
def drawrotatingellipsesurface color, rect, angle:
ellipserect pygame.Rect rect.width, rect.height
ellipserect.center rect.center
rotatedellipse pygame.Surfacerectsize, pygame.SRCALPHA
pygame.draw.ellipserotatedellipse, color, rotatedellipse.getrect
rotatedellipse pygame.transform.rotaterotatedellipse, angle
surface.blitrotatedellipse, ellipserect
# The main game loop
running True
angle
while running:
# Process events
for event in pygame.event.get:
if event.type pygame.QUIT:
running False
# Get keys
keys pygame.key.getpressed
if keyspygameKLEFT and dragonrect.left :
dragonrect.x VELOCITY
if keyspygameKRIGHT and dragonrect.right WINDOWWIDTH:
dragonrect.x VELOCITY
if keyspygameKUP and dragonrect.top :
dragonrect.y VELOCITY
if keyspygameKDOWN and dragonrect.bottom WINDOWHEIGHT:
dragonrect.y VELOCITY
# Check for collision
if dragonrect.colliderectcoinrect:
printfHIT Collected coinvaluescoinimage points'
coinrect.x random.randint WINDOWWIDTH coinimage.getwidth
coinrect.y random.randint WINDOWHEIGHT coinimage.getheight
coinimage random.choicecoinimages
# Fill display surface with star background
displaysurface.blitbackgroundimage,
# Draw boundaries
pygame.draw.rectdisplaysurface, dragonrect,
pygame.draw.rectdisplaysurface, coinrect,
# Blit assets
displaysurface.blitdragonimage, dragonrect
drawrotatingellipsedisplaysurface, coinrect, angle
displaysurface.blitcoinimage, coinrect
# Update display
pygame.display.update
# Tick the clock
clock.tickFPS
# Update rotation angle
angle
pygame.quit
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started