Skip to content
Permalink
Browse files
organizing code + gravity + jumping
  • Loading branch information
dacostag committed Apr 27, 2020
1 parent 3530d7a commit 36592ab040b4c261f4cebc010fba9f87f05ef9ca
Show file tree
Hide file tree
Showing 20 changed files with 449 additions and 191 deletions.

Some generated files are not rendered by default. Learn more.

@@ -0,0 +1,22 @@
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
VIEW THIS USING A MONOSPACED FONT!!!
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

:: SPECIFIC INFO FOR THIS FONT ::

Heh, I'm a big fan of 8-bit things, so I made an 8-bit font. The original plan
was to make it a pixel-perfect low resolution font, and that part does work as
well, but as an additional bonus it looks pretty interesting if used at bigger
sizes in italic mode.

This font was made for making titles for my website and my pictures, so it has
certain specific optimizations. When used on-screen it will look the best with
font sizes starting with 9 and then any next 9. That is 9, 18, 27, 36, etc.

Enjoy, and don't forget to send feedback and tell me what characters you would
like to see added.

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

Revision: 0.80 | 26.01.2001
[EOF]
@@ -0,0 +1,53 @@
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
VIEW THIS USING A MONOSPACED FONT!!!
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

:: INTRODUCTION ::

Greetings, welcome to the readme file for my fonts. That's it. :)

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

:: TERMS OF USE ::

Currently all my fonts are freeware. That doesn't mean however, that you can
do whatever you want with them. Here are the rules for use and distribution:

1. You WILL NOT modify the fonts, the copyright notices, or this text file.
2. You WILL NOT sell the fonts in ANY way.
3. Whatever you do with it, you take full responsibility.

Those are the rules you MUST follow to use or distribute these fonts. If you
disagree, stop using the fonts immediately. If I grow aware of any violations
of these terms, expect legal action to be taken. So, you have been warned.

And, if you decide to use any of the fonts for commercial purposes, it would
be really nice to receive a product sample. I can make a special version of a
font exclusively for you as well. Just e-mail me if you are interested.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

:: ABOUT ME ::

Well, not much to say, really. I'm a guy from Latvia, called Joiro Hatagaya,
I like making fonts, 2D/3D graphics, music, games and programs and many other
things. Send me feedback to make me happy and give me energy to do more. :)

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

:: CONTACT INFORMATION AND WEBSITES ::

E-MAIL: JOIRO@HOTMAIL.COM | Please put "FONTS" in caps as the subject. Do not
send spam, or you WILL regret it.

WEBSITE: JOIRO.THE3DSTUDIO.COM | Come here to see some of my 3D work and find
out what other things I do.

NEW!!!
FONT WEBSITE: http://www.typesource.com/Presents/Hatagaya/Fonts.html | Yes! I
now have a special mini-website for my fonts only, where you can find all the
latest versions of these fonts and also brand new fonts. So go visit it! NOW!

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

Revision: 1.20 | 05.01.2001
[EOF]
Binary file not shown.
Binary file not shown.
195 first.py
@@ -0,0 +1,195 @@
import pygame
import random
import math
from pygame import mixer

# initialize pygame
pygame.init()

# screen resolutions
width = 800
height = 425
screen = pygame.display.set_mode((width, height)) # create screen

# Background
background = pygame.image.load('img/background.jpg')

# Soundtrack
mixer.music.load('31 Flashback.mp3')
mixer.music.play(-1)

# Title and Icon
pygame.display.set_caption("You should be in quarantine!")
icon = pygame.image.load('img/icon.png')
pygame.display.set_icon(icon)

# Player
playerImg = pygame.image.load('img/player.png')
playerX = 100
playerY = 360
playerX_change, playerY_change = 0, 0
score = 0

# Enemy
enemyImg = []
enemyX = []
enemyY = []
enemyX_change = []
enemyY_change = []
num_of_enemies = 6

for i in range(num_of_enemies):
enemyImg.append(pygame.image.load('img/enemy.png'))
enemyX.append(random.randint(150, width - 32))
enemyY.append(360)
enemyX_change.append(-0.7)
enemyY_change.append(0)

# Player spray Attack: Ready - spray attack isn't being seen / Fire - spray is moving
sprayImg = pygame.image.load('img/spray.png')
sprayX = 0
sprayY = 360
sprayX_change = 2
spray_state = "ready"

# Score text

score_value = 0
font = pygame.font.Font('8-BIT WONDER.ttf', 18)
textX, textY = 10, 10

# Game Over text
over_font = pygame.font.Font('8-BIT WONDER.ttf', 36)
game_over = False # game_over remains False until player loses the game


def show_score(x, y):
score = font.render("Score " + str(score_value), True, (245, 194, 66))
screen.blit(score, (x, y))


def game_over_text():
over_text = over_font.render("GAME OVER", True, (0, 0, 0))
screen.blit(over_text, (int(width / 2) - 160, int(height / 2) - 20))


def player(x, y):
screen.blit(playerImg, (x, y))


def enemy(x, y, i):
screen.blit(enemyImg[i], (x, y))


def player_attack(x, y):
global spray_state
spray_state = "fire"
screen.blit(sprayImg, (x + 10, y + 10))


def isCollision(x1, y1, x2, y2):
distance = math.sqrt((math.pow(x1 - x2, 2)) + (math.pow(y1 - y2, 2)))
if distance < 27:
return True
return False


# Game loop
running = True
while running: # leaves window opened
screen.fill((250, 152, 3)) # note: things appear on top of the things above it in the code
# background image
screen.blit(background, (0, 0))

for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False

# when key is being pressed, below are all the game keys
if event.type == pygame.KEYDOWN and game_over is False:
if event.key == pygame.K_LEFT:
playerX_change = -1
if event.key == pygame.K_RIGHT:
playerX_change = 1
if event.key == pygame.K_UP:
playerY_change = -1
if event.key == pygame.K_DOWN:
playerY_change = 1
if event.key == pygame.K_z:
if spray_state is "ready":
# spray_sound = mixer.Sound('quickfart.wav') #later change .wav to the spray sound
# spray_sound.play()
# get's current x, y coordinate of the player
sprayX = playerX
sprayY = playerY
player_attack(sprayX, sprayY)

if event.type == pygame.KEYUP:
if event.key == pygame.K_LEFT or event.key == pygame.K_RIGHT:
playerX_change = 0
if event.key == pygame.K_UP or event.key == pygame.K_DOWN:
playerY_change = 0

if event.type == pygame.KEYDOWN:
if event.key == pygame.K_SPACE:
game_over = False

playerX += playerX_change
playerY += playerY_change

# set boundaries so player doesn't leave the screen
if playerX <= 0:
playerX = 0
elif playerX >= width - 32:
playerX = width - 32
if playerY <= 0:
playerY = 0
elif playerY >= height - 32:
playerY = height - 32

# Enemy movement patterns
for i in range(num_of_enemies):

# Game over
player_collision = isCollision(playerX, playerY, enemyX[i], enemyY[i])
if player_collision:
score_value = 0
game_over = True

enemyX[i] += enemyX_change[i]
# set boundaries to define enemy movement
if enemyX[i] <= 0: # later change this value to any left boundary, like a wall on it's left
enemyX_change[i] = 0.7
elif enemyX[i] >= width - 32: # later change this value to any right boundary, like a wall on it's right
enemyX_change[i] = -0.7

# Collision between attack and enemy
attack_collision = isCollision(enemyX[i], enemyY[i], sprayX, sprayY)
if attack_collision:
sprayY = height
spray_state = "ready"
score_value += 1
enemyX[i] = random.randint(120, width - 32)
enemyY[i] = 360
enemydeath_sound = mixer.Sound('quickfart.wav') # later change .wav to the player being attacked sound
enemydeath_sound.play()

enemy(enemyX[i], enemyY[i], i)

# Spray attack movement
if sprayX >= width:
sprayX = 0
spray_state = "ready"

if spray_state is "fire":
sprayX += sprayX_change
player_attack(sprayX, sprayY)

# When player loses the game:
if game_over:
game_over_text()

player(playerX, playerY)
show_score(textX, textY)
# note: things appear on top of the things above it in the code
pygame.display.update()
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
@@ -0,0 +1,14 @@

###############################################################################

Platformer graphics (Deluxe) by Kenney Vleugels (www.kenney.nl)

------------------------------

License (CC0)
http://creativecommons.org/publicdomain/zero/1.0/

You may use these graphics in personal and commercial projects.
Credit (Kenney or www.kenney.nl) would be nice but is not mandatory.

###############################################################################

0 comments on commit 36592ab

Please sign in to comment.