Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from ursina import *
- app = Ursina()
- dx = 0.05
- dy = 0.05
- score = 0
- dead = False
- def update():
- global dx, dy, score, dead
- if not(dead):
- if held_keys['right arrow']:board.x += 0.07
- if held_keys['left arrow']: board.x -= 0.07
- ball.x += dx
- ball.y += dy
- if ball.x >= 7 or ball.x <= -7: dx *= -1
- if ball.y <= -4: dead = True
- hit_info = ball.intersects()
- if hit_info.hit:
- dy *= -1
- if hit_info.entity in boxes:
- destroy(hit_info.entity)
- score += 1
- print_on_screen("SCORE: "+str(score), position=(-0.8,0.5))
- else:
- destroy(board)
- destroy(ball)
- for i in boxes:
- destroy(i)
- print_on_screen("GAME OVER!", position=(-0.05,0.2))
- print_on_screen("FINAL SCORE: "+str(score), position=(-0.07,0.15))
- box_1 = Entity(model="cube", color=color.cyan, texture="brick", scale=(1,0.5,0.5), position=(-10,4,0), collider="box")
- boxes = []
- for i in range(6,-7,-1):
- for j in range(1,7):
- boxes.append(duplicate(box_1, x=i, y=j/2 + 0.5, color=color.random_color()))
- board = Entity(model="cube", color=color.orange, texture="brick", scale=(4,0.5,0.5), position=(0,-4,0), collider="box")
- ball = Entity(model="sphere", color=color.orange, scale=0.5, position=(0,-2,0), collider="box")
- app.run()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement