@0r1gam1/

WelloffConsiderateRevisioncontrol

Python

No description

fork
loading
Files
  • main.py
  • requirements.txt
  • sword.png
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
import pygame
import random
pygame.init()
screen = pygame.display.set_mode((640, 480))
weapons = ["sword"]
drops = []
inventory = []
droppos = []
black = (0, 0, 0)
class tree(pygame.sprite.Sprite):
	def __init__(self, startpos, size):
		self.startpos = startpos
		self.size = size
class drop(pygame.sprite.Sprite):
	def __init__(self, emitter, img, weapon):
		self.weapon = weapon
		self.position = [emitter[0] + random.randint(10, 15), emitter[1] + random.randint(10, 15)]
		droppos.append(self.position)

	def collect(self):
		if pygame.mouse.get_pressed():
			if ((pygame.mouse.get_pos()[0] - self.position[0] > -10) and (pygame.mouse.get_pos()[0] - self.position[0] < 10)) and ((pygame.mouse.get_pos()[1] - self.position[1] > -10) and (pygame.mouse.get_pos()[1] - self.position[1] < 10)):
				del drops[droppos.index(self.position)]
				inventory.append(self.weapon)
class chest(pygame.sprite.Sprite):
	def __init__(self, pos)
			
trees = []


for i in range(1000):
	trees.append(tree([random.randint(-2000, 2000), random.randint(-2000, 2000)], random.randint(30, 50)))
drops.append(drop((0, 0), "sword.png", "sword"))
mypos = [320, 480]
borderx = -180
bordery = -260
up = False
down = False
left = False
right = False
while True:
	
	
	for event in pygame.event.get():
		if event.type == pygame.QUIT:
			pygame.quit()
			quit()
		if event.type == pygame.KEYDOWN:
			if event.key == pygame.K_UP:
				up = True
			if event.key == pygame.K_DOWN:
				down = True
			if event.key == pygame.K_LEFT:
				left = True
			if event.key == pygame.K_RIGHT:
				right = True
	
		if event.type == pygame.KEYUP:
			if event.key == pygame.K_UP:
				up = False
			if event.key == pygame.K_DOWN:
				down = False
			if event.key == pygame.K_LEFT:
				left = False
			if event.key == pygame.K_RIGHT:
				right = False
	if up == True:
		if mypos[1] < 1700:
			mypos[1] = mypos[1] + 5
			bordery = bordery + 5
			for i in trees:
				i.startpos[1] = i.startpos[1] + 5
			for i in drops:
				i.position[1] = i.position[1] + 5	
			
	
	if down == True:
		if mypos[1] > 260:
			bordery = bordery - 5
			mypos[1] = mypos[1] - 5
			for i in trees:
				i.startpos[1] = i.startpos[1] - 5
			for i in drops:
				i.position[1] = i.position[1] - 5
			
	
	if left == True:
		if mypos[0] > -900:
			borderx = borderx + 5
			mypos[0] = mypos[0] - 5
			for i in trees:
				i.startpos[0] = i.startpos[0] + 5
			for i in drops:
				i.position[0] = i.position[0] + 5
			
	
	if right == True:
		if mypos[0] < 540:
			borderx = borderx - 5
			mypos[0] = mypos[0] + 5
			for i in trees:
				i.startpos[0] = i.startpos[0] - 5
			for i in drops:
				i.position[0] = i.position[0] - 5
			
	screen.fill((0, 150, 0))
	main = pygame.draw.circle(screen, (0, 0, 0), (320, 240), 30)
	for i in trees:
		pygame.draw.circle(screen, (0, 75, 0), i.startpos, i.size+3)
		pygame.draw.circle(screen, (0, 100, 0), i.startpos, i.size)
	for i in drops:
		pygame.draw.circle(screen, (241, 244, 66), i.position, 40)
		i.collect()
	print (inventory)
		
	pygame.draw.rect(screen, (0, 100, 0), (((borderx - 1000), (bordery - 1000)), ((1000 + 1000), (1000 + 1000))), 500)
	pygame.display.flip()