acord-robotics / python-learning

Learning about python
http://acord.software/stellarios/python-discussion
1 stars 0 forks source link

Platformer #21

Open Gizmotronn opened 3 years ago

Gizmotronn commented 3 years ago
import pygame

from pygame.locals import *

 

pygame.init()

vec = pygame.math.Vector2  # 2 for two dimensional

 

HEIGHT = 450

WIDTH = 400

ACC = 0.5

FRIC = -0.12

FPS = 60

 

FramePerSec = pygame.time.Clock()

 

displaysurface = pygame.display.set_mode((WIDTH, HEIGHT))

pygame.display.set_caption("Game")

class Player(pygame.sprite.Sprite):

    def __init__(self):

        super().__init__() 

        self.surf = pygame.Surface((30, 30))

        self.surf.fill((128,255,40))

        self.rect = self.surf.get_rect(center = (10, 420))

 

class platform(pygame.sprite.Sprite):

    def __init__(self):

        super().__init__()

        self.surf = pygame.Surface((WIDTH, 20))

        self.surf.fill((255,0,0))

        self.rect = self.surf.get_rect(center = (WIDTH/2, HEIGHT - 10))

 

PT1 = platform()

P1 = Player()

all_sprites = pygame.sprite.Group()

all_sprites.add(PT1)

all_sprites.add(P1)

 

while True:

    for event in pygame.event.get():

        if event.type == QUIT:

            pygame.quit()

            sys.exit()

     

    displaysurface.fill((0,0,0))

 

    for entity in all_sprites:

        displaysurface.blit(entity.surf, entity.rect)

 

    pygame.display.update()

    FramePerSec.tick(FPS)
Gizmotronn commented 3 years ago
import pygame

from pygame.locals import *

import sys

import random

 

pygame.init()

vec = pygame.math.Vector2 #2 for two dimensional

 

HEIGHT = 450

WIDTH = 400

ACC = 0.5

FRIC = -0.12

FPS = 60

 

FramePerSec = pygame.time.Clock()

 

displaysurface = pygame.display.set_mode((WIDTH, HEIGHT))

pygame.display.set_caption("Game")

 

class Player(pygame.sprite.Sprite):

    def __init__(self):

        super().__init__() 

        #self.image = pygame.image.load("character.png")

        self.surf = pygame.Surface((30, 30))

        self.surf.fill((128,255,40))

        self.rect = self.surf.get_rect()

   

        self.pos = vec((10, 360))

        self.vel = vec(0,0)

        self.acc = vec(0,0)

 

    def move(self):