示例#1
0
文件: main.py 项目: hedayaty/snake
def main():
	
	pygame.init()

	size = width, height = [640,480+16]
	renderer.init(size)
	pygame.display.set_caption("snake")
	menu.init()
	
	
	# number of player, game type, lives, mapname
	while 1:	
		gametype = menu.choose ("",																			\
		[{ "label" : "Single Player", "value": "1p"}, 									\
		 { "label" : "Multi Players Game", "value": "multi"},						\
		 { "label" : "Join a Network Game", "value" : "join"},					\
		 { "label" : "QUIT", "value": None}])	

		if gametype == None : 
			break
		
		if game.init (gametype):
			game.mainloop ()

	pygame.display.quit()
示例#2
0
def back_to_menu():

    menu.gen_player_labels()

    utils.logic = menu.logic
    utils.update = menu.update
    utils.render = menu.render
    menu.init()
示例#3
0
def init():
	font.init()
	img.init()
	anim.init()
	menu.init()
	instruct.init()
	game.init()
	map.init()
	end.init()
	director.director.push(menu.menu_scene)
示例#4
0
def init():
    font.init()
    img.init()
    anim.init()
    menu.init()
    instruct.init()
    game.init()
    map.init()
    end.init()
    director.director.push(menu.menu_scene)
示例#5
0
def main():
	### Configuration parameters
	# moved to config.py

	### Game startup
	#overwrite escape key
	viz.setOption('viz.default_key.quit','0')
	
	# Physics
	viz.phys.enable()
	#viz.phys.setGravity(0,0,0)

	# Initialize pointer tool
	# Unused?
	glove = viz.addChild('.\\dataset\\Hand\\handPoint_Reduced.ply')
	glove.disable([viz.PHYSICS, viz.DYNAMICS])

	glovePhys = glove.collideSphere()
	glove.setPosition([0,1,0])
	glove.setScale([1,1,1])

	# Initialize environment this will load the coliseum and sky
	sky = viz.addChild('sky_day.osgb')
	sky.collideMesh()
	sky.disable(viz.DYNAMICS)
	init.loadTemple()

	# Initialize pointer controls
	device = init.pointerInput(config.pointerMode, glove, sky)

	# Initialize display
	puzzle.model.display = init.DisplayInstance(config.dispMode,config.camMode,device,glove)
	#init.display(config.dispMode)

	# Initialize camera controls
	#init.cameraInput(config.camMode,config.dispMode, device, glove)

	# Launch menu system
	menu.init()
	puzzle.model.pointer = glove
	puzzle.model.pointer.setScale(0.015, 0.015, 0.015)
	puzzle.model.pointer.setEuler(0, -115, 0)
	
	# Override default escape key map to call main menu
	vizact.onkeydown(viz.KEY_ESCAPE, menu.toggle)
	
#	# Record moviefilms
#	viz.setOption('viz.AVIRecorder.maxWidth', '1280')
#	viz.setOption('viz.AVIRecorder.maxHeight', '720')
#	vizact.onkeydown(viz.KEY_F11, viz.window.startRecording, 'D:\\recording.avi')
#	vizact.onkeydown(viz.KEY_F12, viz.window.stopRecording)
	
	# Stuff to run on program termination
	vizact.onexit(puzzle.controller.end)
示例#6
0
def main():
    ### Configuration parameters
    # moved to config.py

    ### Game startup
    # overwrite escape key
    viz.setOption("viz.default_key.quit", "0")

    # Physics
    viz.phys.enable()
    # viz.phys.setGravity(0,0,0)

    # Initialize pointer tool
    # Unused?
    glove = viz.addChild(".\\dataset\\Hand\\handPoint_Reduced.ply")
    glove.disable([viz.PHYSICS, viz.DYNAMICS])

    glovePhys = glove.collideSphere()
    glove.setPosition([0, 1, 0])
    glove.setScale([1, 1, 1])

    # Initialize environment this will load the coliseum and sky
    sky = viz.addChild("sky_day.osgb")
    sky.collideMesh()
    sky.disable(viz.DYNAMICS)
    init.loadTemple()

    # Initialize pointer controls
    device = init.pointerInput(config.pointerMode, glove, sky)

    # Initialize display
    puzzle.model.display = init.DisplayInstance(config.dispMode, config.camMode, device, glove)
    # init.display(config.dispMode)

    # Initialize camera controls
    # init.cameraInput(config.camMode,config.dispMode, device, glove)

    # Launch menu system
    menu.init()
    puzzle.model.pointer = glove
    puzzle.model.pointer.setScale(0.015, 0.015, 0.015)
    puzzle.model.pointer.setEuler(0, -115, 0)

    # Override default escape key map to call main menu
    vizact.onkeydown(viz.KEY_ESCAPE, menu.toggle)

    # 	# Record moviefilms
    # 	viz.setOption('viz.AVIRecorder.maxWidth', '1280')
    # 	viz.setOption('viz.AVIRecorder.maxHeight', '720')
    # 	vizact.onkeydown(viz.KEY_F11, viz.window.startRecording, 'D:\\recording.avi')
    # 	vizact.onkeydown(viz.KEY_F12, viz.window.stopRecording)

    # Stuff to run on program termination
    vizact.onexit(puzzle.controller.end)
示例#7
0
def init(data):
    data.floor = PhotoImage(file="Images/floor.gif")
    data.heart = PhotoImage(file="Images/heart.gif")
    data.emptyHeart = PhotoImage(file="Images/emptyHeart.gif")
    data.coin = PhotoImage(file="Images/coin.gif")
    data.arrows = [
        PhotoImage(file="Images/leftArrow.gif"),
        PhotoImage(file="Images/upArrow.gif"),
        PhotoImage(file="Images/rightArrow.gif"),
        PhotoImage(file="Images/downArrow.gif")
    ]
    data.mode = "menu"
    menu.init(data)
示例#8
0
def keyPressed(event, data, canvas):
    if event.keysym == "Escape":
        data.pause = True
        data.selection = None
    elif data.pause:
        if event.keysym == "Escape":
            data.pause = False
        if event.keysym == "m":
            data.mode = "menu"
            menu.init(data)
        elif event.keysym == "s":
            name = simpledialog.askstring("Input",
                                          "Name of file (don't use ':'): ",
                                          parent=canvas)
            if ":" in name:
                messagebox.showerror("Error",
                                     "':' is not allowed in the level name")
            elif name is not None:
                save(name, data)
                messagebox.showinfo("Information", "Saved!")
示例#9
0
def start():
    pg.init()

    pg.display.set_mode((width, height), flags=pg.SCALED | pg.RESIZABLE)
    pg.display.set_caption('card game')

    save.init()
    image_handler.init()
    spritesheet.init()
    customsheet.init()
    menu.init()
    client.init()
    game.init()
    network.init()
    builder.init()
    ui.init()

    main_menu = ui.Menu(get_objects=menu.main_menu)
    main_menu.run()

    pg.quit()
示例#10
0
def keyPressed(event, data):
    if data.dead or data.won:
        if event.keysym == "Escape":
            data.mode = "menu"
            menu.init(data)
        return
    if data.pause:
        if event.keysym == "Escape": data.pause = False
        elif event.keysym == "m":
            data.mode = "menu"
            menu.init(data)
        return
    if event.keysym == "Escape":
        data.pause = True
    if event.keysym == "Up" and not data.up:
        data.up = True
    elif event.keysym == "Down" and not data.down:
        data.down = True
    elif event.keysym == "Right" and not data.right:
        data.right = True
    elif event.keysym == "Left" and not data.left:
        data.left = True
示例#11
0
def readmenu(ifile):
    # menu: [Menu, Item, Show as, Spectype, Spec1, Spec2]
    import UI,menu
    sheet=readcsv(ifile,100,False)
    menu.maintxt=sheet[0][0]
    currmenu=menu.maintxt
    for i in range(1,len(sheet)):
        if len(sheet[i])>2:     # skip useless lines
            values=["","",""]
            if sheet[i][0]!="-":
                if currmenu!="": currmenu=sheet[i][0]
            values[0]=currmenu
            if sheet[i][1] in UI.procs and UI.procs[sheet[i][1]][0]=="w":
                values[1]=sheet[i][1]
                values[2]=values[1] if len(sheet[i])<4 or sheet[i][3]=="" else sheet[i][3]
                if sheet[i][2].lower()=="boolean": values.append("boolean")
                elif sheet[i][2] in UI.procs and UI.procs[sheet[i][2]][0]!="w":
                    values.append(sheet[i][2])
                else:
                    if not isinstance(sheet[i][2],str): values=None
                    else:
                        spec=sheet[i][2].split('-')
                        if len(spec)<2: values=None
                        elif spec[0].isdigit() and spec[1].isdigit():
                            values.append(int(spec[0]))
                            values.append(int(spec[1]))
                            if len(spec)>2 and spec[2].isdigit():values.append(int(spec[2]))
                            else: values.append(1)
                        else: values=None
                if values: menu.definition.append(values)
                else: print ("%s: Don't understand spec %s, ignored %s" %(ifile,sheet[i][2],sheet[i]))
            else:
                print ("%s: Item %s unknown or not writable, ignored %s" %(ifile,sheet[i][1],sheet[i]))
        else:
            print ("%s: ignored %s" %(ifile, sheet[i]))
            gv.ConfigErr=True
    menu.init()
    return 
示例#12
0
        message = concealment.reverse(util.clean_message(code_entry.get()))
    elif cypher == 'trans number':
        message = transposition.trans_number(
            util.clean_message(code_entry.get()), key_entry.get())
    elif cypher == 'trans word':
        message = transposition.trans_word(
            util.clean_message(code_entry.get()), key_entry.get())
    elif cypher == 'caesar':
        message = substitution.caesar(util.clean_message(code_entry.get()),
                                      int(key_entry.get()))
    elif cypher == 'multiplicative':
        message = substitution.multiplicative(
            util.clean_message(code_entry.get()), int(key_entry.get()))
    elif cypher == 'affine':
        message = substitution.affine(util.clean_message(code_entry.get()),
                                      int(key_entry.get()))
    else:
        message = 'No Cypher was Selected'
    textbox.insert(END, message)


hide_widgets()

menubar = menu.init(root,
                    concealment_cyphers=concealment_cyphers,
                    transposition_cyphers=transposition_cyphers,
                    substitution_cyphers=substitution_cyphers,
                    decryption_mode=decryption_mode,
                    encryption_mode=encryption_mode)
root.config(menu=menubar)
root.mainloop()
示例#13
0
import pygame as pg
import new_classes
import menu

pg.init()
menu.init({
    'buttons': pg.font.SysFont('dejavuserif', 40),
    'title': pg.font.SysFont('lato', 60),
    'header': pg.font.SysFont('lato', 30),
    'text': pg.font.SysFont('dejavuserif', 20)
})

#clock
clock = pg.time.Clock()

#music
pg.mixer.music.load('mus.wav')
pg.mixer.music.play(
    -1
)  #setting it to negative ones mean play infinitly, other numbers just mean play x amount of times

#screen
SCREEN_WIDTH = 400
SCREEN_HEIGHT = 400
win = pg.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT))
pg.display.set_caption('Lights Out')

#player
player = new_classes.Player([0, 0], 20, 40)
player.set_surf(win)
jumping = False
示例#14
0
pgl.gl.glBlendFunc(pgl.gl.GL_SRC_ALPHA, pgl.gl.GL_ONE_MINUS_SRC_ALPHA)

pgl.resource.path = ["resources"]
pgl.resource.reindex()
pgl.resource.add_font("Gotham-Bold.otf")

rules = []

menu_functions = {
    "pause": toggle_pause,
    "reset": reset,
    "toggle_counter": toggle_counter,
    "set_speed": set_speed
}

main_menu, rule_menu = menu.init(window, batch, menu_functions, rules)
grid = Grid([5, 5], rules, batch, window, scale=25)
ant = Ant(2, 2, grid)

speed = 2

prev_highlight = None
paused = False
dragged = False
counter = None
mouse_menu = False
drag_x = drag_y = 0


@window.event
def on_key_press(symbol, mod):
示例#15
0
# MAIN PROGRAM - Run this now!

# Hide matplotlib depreciation warning - temporary fix until pyisntaller updates
# Check https://github.com/pyinstaller/pyinstaller/issues/3959 for more
import warnings
warnings.filterwarnings('ignore')
# Import menu (which with it imports all other modules)
import menu

# Initiate Main Menu
menu.init()
示例#16
0

def controls():
    """Displays Controls Screen"""
    _display = pygame.display.set_mode((600, 300), 0, 32)
    pygame.display.set_caption('Ship Defence Controls')
    controls = pygame.image.load('images/controls.png')
    bgSize = controls.get_rect()
    _display.blit(controls, bgSize)


if __name__ == "__main__":
    surface = pygame.display.set_mode((600, 300))
    surface.fill((51, 51, 51))
    menu = menu.Menu()
    menu.init(['Start', 'Credits', 'Controls', 'Quit'], surface)
    menu.draw()
    pygame.key.set_repeat(199, 69)
    pygame.display.update()
    while 1:
        for event in pygame.event.get():
            if event.type == pygame.KEYDOWN:
                if event.key == pygame.K_UP:
                    menu.draw(-1)
                if event.key == pygame.K_DOWN:
                    menu.draw(1)
                if event.key == pygame.K_RETURN:
                    if menu.get_position() == 0:
                        game()
                    if menu.get_position() == 1:
                        credits()
示例#17
0
            if width > self.menu_width:
                self.menu_width = width
            self.menu_height += height
        x = self.dest_surface.get_rect().centerx - self.menu_width / 2
        y = self.dest_surface.get_rect().centery - self.menu_height / 2
        mx, my = self.pozycja_wklejenia
        self.pozycja_wklejenia = (x + mx, y + my)


if __name__ == '__main__':
    import sys
    surface = pygame.display.set_mode((854, 480))
    surface.fill((51, 51, 51))
    menu = Menu()

    menu.init(['Game Start', 'Difficulty', 'Character', 'Quit'],
              surface)  #necessary
    pygame.display.set_caption('TetandRis MENU')

    menu.draw()
    tmp = 0
    tmp2 = 0
    pygame.key.set_repeat(199, 69)
    pygame.display.update()
    tet = Tetandris()
    while 1:
        for event in pygame.event.get():
            if event.type == KEYDOWN:
                if event.key == K_UP:
                    menu.draw(-1)
                if event.key == K_DOWN:
                    menu.draw(1)
示例#18
0
    pygame.display.init()

if not pygame.font.get_init():
    pygame.font.init()

from global_defs import screen

#surface = pygame.display.set_mode((854, 480))
screen.fill((51, 51, 51))

pygame.mixer.pre_init(44100, -16, 2, 4096)
pygame.init()
FindSticks()

menu = menu.Menu()
menu.init(['Start', 'Options', 'Quit'], screen)  # necessary
#menu.move_menu(0, 0)  # optional
menu.draw()  # necessary

pygame.key.set_repeat(199, 69)  # (delay,interval)
pygame.display.update()
while 1:
	for event in pygame.event.get():
		if event.type == KEYDOWN:
			if event.key == K_UP:
				# here is the Menu class method
				menu.draw(-1)
			if event.key == K_DOWN:
				# here is the Menu class method
				menu.draw(1)
			if event.key == K_RETURN:
示例#19
0
def return_to_menu():
    
    utils.logic = menu.logic
    utils.update = menu.update
    utils.render = menu.render
    menu.init()
示例#20
0
文件: main.py 项目: gragas/fph
import pygame
from buffalo import utils

import menu
import storage

def main():

    while not utils.end:
        utils.logic()
        utils.update()
        utils.render()
        utils.delta = utils.clock.tick( utils.FRAMES_PER_SECOND )

if __name__ == "__main__":
    
    if not utils.init( 
        logic_func=menu.logic,
        update_func=menu.update, 
        render_func=menu.render,
        ):
        print('buffalo.utils failed to initialize')
        pygame.quit()
        exit()

    menu.init()
    storage.init()
    main()

    pygame.quit()