Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit ca5d752

Browse files
game
1 parent 8ab7eb7 commit ca5d752

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

‎functions/gameEx2.py‎

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import pgzrun
2+
HEIGHT = 600
3+
WIDTH = 1200
4+
p = Actor('ironman', center=(WIDTH//2, HEIGHT//2))
5+
6+
title= " IRON MAN GAME(@helloharendra) "
7+
8+
def draw():
9+
screen.fill('white')
10+
screen.draw.text(title, center=(WIDTH//2,30), fontsize=60,color='black',
11+
align="center",shadow=(.2,1),scolor="red")
12+
p.draw()
13+
14+
def p_move():
15+
'''function to mave player'''
16+
if keyboard.left:
17+
p.x -= 3
18+
p.angle = 10
19+
elif keyboard.right:
20+
p.x += 3
21+
p.angle= -10
22+
elif keyboard.up:
23+
p.y -= 3
24+
elif keyboard.down:
25+
p.y += 3
26+
else:
27+
p.angle = 0
28+
29+
def handle_boundary():
30+
if p.x > WIDTH :
31+
p.x = 0
32+
if p.y > HEIGHT :
33+
p.y = 0
34+
if p.x < 0:
35+
p.x = WIDTH
36+
if p.y < 0:
37+
p.y = HEIGHT
38+
39+
def update():
40+
p_move()
41+
handle_boundary()
42+
print(p.x,p.y,p.angle)
43+
44+
pgzrun.go()
File renamed without changes.

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /