コード例 #1
0
import pymongo
import sys
import os
import ResourceLoader
import ClassHandler as ch

#getting maps from DB
brickimg = ResourceLoader.LoadImage('brick.png')
woodimg = ResourceLoader.LoadImage('wood.png')

collection = ''

deflevel = []
for row in range(20):
    deflevel.append([])
    for column in range(25):
        deflevel[row].append(".")


def preInit():
    global collection

    client = pymongo.MongoClient(
        "mongodb+srv://Player:[email protected]/test?retryWrites=true&w=majority"
    )
    db = client['TonksDB']
    collection = db['Levels']


def GetLevelNames():
    request = collection.find({}, {'_id': 0, 'name': 1})
コード例 #2
0
import pygame
import colorsys
import math
import random
import ResourceLoader as rs
import GraphicsHelper as gh

bulletimg = rs.LoadImage('bullet.png')

shotsnd = rs.LoadSound('Shot.ogg')
destroysnd = rs.LoadSound('destroy.ogg')
nickfont = pygame.font.Font('freesansbold.ttf', 14)

speed = 2.5
bulletspeed = 5


def FindNearest(tks,me):
    nearest = ''
    nearestdis = 20000000000000
    for tk in tks:
        if(tk != me.nick):
            dis = (me.x-tks[tk].x)**2+(me.y-tks[tk].y)**2
            if(dis < nearestdis):
                nearest = tks[tk]
                nearestdis = dis
    return nearest

def getSqrDistance(pos1,pos2):
    return (pos1[0]-pos2[0])**2+(pos1[1]-pos2[1])**2
コード例 #3
0
buttonfont = pygame.font.Font('freesansbold.ttf', 26)
titlefont = pygame.font.Font('freesansbold.ttf', 40)
p1col = ''
p2col = ''
play = True
tk1 = ''
tk2 = ''
powertimer = 0
powerup = None
bullets = []
blocks = []
lvl = ''
lvlname = ''
repairsound = rs.LoadSound('Repair.ogg')

brickimg = rs.LoadImage('brick.png')
woodimg = rs.LoadImage('wood.png')


def intersect(colbox1,colbox2):
     return(colbox2[0] <= colbox1[0]+colbox1[2] and colbox2[1] <= colbox1[1]+colbox1[3]) and (colbox2[0]+colbox2[2] >= colbox1[0] and colbox2[1]+colbox2[3] >= colbox1[1])

def Menu():
    global play
    play = False

def Restart():
    global gamestate
    global tk1
    global tk2
    global powertimer
コード例 #4
0
import random
import threading
import os

pygame.init()

UpdateClock = pygame.time.Clock()
screen = pygame.display.set_mode((600, 600))

titlefont = pygame.font.Font('freesansbold.ttf', 40)
namefont = pygame.font.Font('freesansbold.ttf', 30)
buttonfont = pygame.font.Font('freesansbold.ttf', 26)
levelfont = pygame.font.Font('freesansbold.ttf', 18)
selectedRoom = 1

tonkimg = rs.LoadImage('tonk.png')
bots = []
levels = []
botnames = {
    'Tonkinator': ['hasta la vista, baby'],
    'Bender': ['I\'m gonna make my own tanks,', 'with blackjack and hookers'],
    'Tomas the dank engine': ['Tomas has seen enough'],
    'Копатыч': ['Укуси меня пчела'],
    'GladOS':
    ['Killing you and giving you advice', 'aren\'t mutually exclusive']
}
for i in range(5):
    bots.append(rs.LoadImage('bots/bot' + str(i + 1) + '.png'))

p1col = gh.createcol(0)
p2col = gh.createcol(180)
コード例 #5
0
import pygame
import colorsys
import math
import random
import ResourceLoader as rs
import GraphicsHelper as gh

tonkimg = rs.LoadImage('tonk.png')
bulletimg = rs.LoadImage('bullet.png')

shotsnd = rs.LoadSound('Shot.ogg')
destroysnd = rs.LoadSound('destroy.ogg')
nickfont = pygame.font.Font('freesansbold.ttf', 14)

speed = 2.5
bulletspeed = 5


class powerup:
    def __init__(self, x, y, action):
        self.x = x
        self.y = y
        self.bounds = (self.x - 8, self.y - 8, 16, 16
                       )  #bounds for checking collision
        self.h = 0
        self.type = action

    def draw(self, screen):
        self.h %= 360
        #draw lightning:
        points = []