I made a game that Game Generator gave!(A war game where you invade dungeons and you can create miracles and curses)
Today, I made a game that this game generator gave. So first I tried and this is what it said "A war game where you invade dungeons and you can create miracles and curses" and I couldn't figure out what it meant by creating the curses and miracles. So I asked my brother what it meant and he said "It means that you could have the miracle or curse by 50/50. So I made the game,
Here is the code if you want it:
import random
import time
import pygame
gameDisplay = pygame.display.set_mode((800, 800))
pygame.init()
run = True
chest_pic = pygame.image.load('chest.png')
swish = pygame.image.load('swish_swish.png')
swish = pygame.transform.scale(swish, [26, 58])
background = pygame.image.load('dungeon floor.png')
chest_pic = pygame.transform.scale(chest_pic, [56, 56])
bullet_group = []
countdown = 500
show = False
space_detect = False
not_opening = False
miracle_or_curse = 2 # 1 = curse, 0 = miracle
class Chest:
x, y = random.randrange(30, 770, 1), random.randrange(30, 770, 1)
def show(self):
global show
global miracle_or_curse
if show:
gameDisplay.blit(chest_pic, [self.x, self.y])
if space_detect:
miracle_or_curse = random.randrange(0, 2, 1)
show = False
if not_opening:
show = False
class Player:
health = 10
x, y = 400, 400
keys = {'left': False, 'right': False, 'up': False, 'down': False}
def move(self): # key input
global swish
if self.keys['left']:
if self.x <= 0:
self.x = 800
self.x -= 0.4
if self.keys['right']:
if self.x >= 800:
self.x = 0
self.x += 0.4
if self.keys['down']:
if self.y >= 800:
self.y = 0
self.y += 0.4
if self.keys['up']:
if self.y <= 0:
self.y = 800
self.y -= 0.4
pygame.draw.rect(gameDisplay, (0, 0, 255), [self.x, self.y, 50, 50])
gameDisplay.blit(swish, [self.x + 25, self.y - 10])
textfont = pygame.font.Font('Assets/LEMONMILK-Bold.otf', 20)
def headwrite(text, xw, yw):
text1 = textfont.render(str(text), True, (255, 255, 255))
textpos = xw, yw
gameDisplay.blit(text1, textpos)
player = Player()
kill = False
chest = Chest()
stage = 1
color = random.randrange(0, 255, 1), random.randrange(0, 255, 1), random.randrange(0, 255, 1)
class Goblins:
health = stage
x, y = random.randrange(0, 800), random.randrange(0, 800)
def attack(self): # following system
if self.x <= player.x:
self.x += 0.2
if self.x >= player.x:
self.x -= 0.2
if self.y <= player.y:
self.y += 0.2
if self.y >= player.y:
self.y -= 0.2
def draw(self):
global space_detect
global kill
global stage
global color
global show
global not_opening
if self.health <= 0:
self.x, self.y = 100000000, 100000000
show = True
if space_detect or not_opening:
time.sleep(0.01)
space_detect = False
not_opening = False
show = False
color = random.randrange(0, 255, 1), random.randrange(0, 255, 1), random.randrange(0, 255, 1)
print("stage " + str(stage))
stage += 1
self.health = stage
self.x, self.y = random.randrange(0, 800), random.randrange(0, 800)
if kill:
if self.health != 0:
kill = False
self.health -= 1
if self.health != 0:
pygame.draw.rect(gameDisplay, color, [self.x, self.y, 50, 50])
enemy = Goblins()
def drawscore():
mytext = 'energy (your health):' + ' ' + str(player.health)
headwrite(mytext, 50, 50)
mytext = 'stage:' + ' ' + str(stage)
headwrite(mytext, 400, 50)
mytext = 'enemy_health: ' + str(enemy.health)
headwrite(mytext, 550, 50)
drawit = False
def draw():
global miracle_or_curse, this_is_text, drawit, not_opening, show
if not_opening:
drawit = True
print("sdasadsadasdas")
this_is_text = 'nah thanks,'
print(this_is_text)
if miracle_or_curse == 0:
drawit = True
this_is_text = 'MIRACLE!!'
print("asdas")
if miracle_or_curse == 1:
drawit = True
this_is_text = 'CUrrrrrSe!!'
print("asdas")
if not drawit:
this_is_text = ''
headwrite(this_is_text, player.x, 300)
coutdown = 0
while run:
gameDisplay.fill((217, 217, 217))
draw()
if drawit:
print(countdown, drawit)
if coutdown <= 500:
coutdown += 1
elif coutdown == 501:
coutdown = 0
print(coutdown)
drawit = False
if miracle_or_curse == 0:
miracle_or_curse = 2 # so that it doesn't trigger it again.
print("miracle")
player.health += 1 # prototypes
print(player.health)
if miracle_or_curse == 1:
miracle_or_curse = 2
print("curse")
player.health -= 1
print(player.health)
if (round(enemy.x) - round(player.x)) == 0 or (round(enemy.x) - round(player.x)) == 1 or (
round(enemy.y) - round(player.y)) == -1:
if (round(enemy.y) - round(player.y)) == 0 or (round(enemy.y) - round(player.y)) == 1 or (
round(enemy.y) - round(player.y)) == -1:
countdown += 1
if countdown >= 250:
player.health -= 1
print(player.health)
countdown = 0
if player.health == 0:
run = False
enemy.draw()
for event in pygame.event.get():
if event.type == pygame.QUIT:
run = False
if event.type in [pygame.KEYDOWN]:
if event.key == pygame.K_e:
space_detect = True
if event.key == pygame.K_r:
not_opening = True
if event.key == pygame.K_SPACE:
if (round(enemy.x) - round(player.x)) == 0 or (round(enemy.x) - round(player.x)) == 1 or (
round(enemy.y) - round(player.y)) == -1:
if (round(enemy.y) - round(player.y)) == 0 or (round(enemy.y) - round(player.y)) == 1 or (
round(enemy.y) - round(player.y)) == -1:
kill = True
if event.key == pygame.K_a:
player.keys['left'] = True
if event.key == pygame.K_w:
player.keys['up'] = True
if event.key == pygame.K_d:
player.keys['right'] = True
if event.key == pygame.K_s:
player.keys['down'] = True
if event.type in [pygame.KEYUP]:
if event.key == pygame.K_a:
player.keys['left'] = False
if event.key == pygame.K_w:
player.keys['up'] = False
if event.key == pygame.K_d:
player.keys['right'] = False
if event.key == pygame.K_s:
player.keys['down'] = False
player.move()
drawscore()
chest.show()
enemy.attack()
pygame.display.update()
And I made the video with it.
Comments
Post a Comment