Esempio n. 1
0
def main ():
    pygame.init()
    size = (800,600)

    game.setup()
    while True:
        game.events()
        game.loop()
        pygame.display.flip()
Esempio n. 2
0
def start():
  """
  Calls the game loop function and sets the launched variable to 1
  """

  global launched
  launched=1
  mmenu()
  game.loop()
Esempio n. 3
0
from plant import *

pygame.init()

last_tick = pygame.time.get_ticks()
screen = pygame.display.set_mode((500, 500))
game.screen = screen

clock = pygame.time.Clock()
myPlant = plant(
    "C:\\Users\\ragin\\Downloads\\TowerDefense\\TowerDefense\\assets\\plant.png",
    45, 100)

is_running = True
while is_running:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            is_running = False

    myPlant.draw()
    screen.fill((255, 230, 230))

    #milliseconds
    frame_duration = pygame.time.get_ticks() - last_tick
    last_tick = pygame.time.get_ticks()

    game.loop(screen, frame_duration)

    pygame.display.update()
    clock.tick(60)
Esempio n. 4
0
def start_game():
    game_board, current_player, next_player = game.setup()
    game.loop(game_board, current_player, next_player)
Esempio n. 5
0
import game

if __name__ == "__main__":
    game = game.Game((640, 480))
    game.loop()
Esempio n. 6
0
import pygame,rabbyt,sys
import game,data
import logging
logging.basicConfig(level=5,stream=sys.stdout,format='%(levelname)s: %(name)s - %(message)s')
log = logging.getLogger("core")
def init():
	log.info("Setting up")
	pygame.init()
	game.window = pygame.display.set_mode(game.config.size,game.config.screenargs)
	rabbyt.set_viewport(game.config.size)
	rabbyt.set_default_attribs()
	
	
if __name__ == '__main__':
	init()
	data.init()
	game.init()
	game.loop()
    player_answer = input("Start the Game? y/n : ")
    log.debug(f'Player amsver to "Start the Game? y/n : " is {player_answer}')

    if player_answer == 'y':
        player_answer = input('(1) new game or (2) saved game : ')
        log.debug(
            f'Player amsver to "(1) new game or (2) saved game : " is {player_answer}'
        )

        if player_answer == '1':
            new_game()
        elif player_answer == '2':
            saved_game()
        else:
            #To 'Start the Game?'
            log.info('incorect input')
            continue

        #Game logic
        game.loop(g_map)

        #End game
        log.info(f'You {gmap.cell_player} at position {game.player_position}')
        log.info(f'Treasure {gmap.cell_treasure}')
        log.info(f'Trap {gmap.cell_trap}')
        for line in g_map[::-1]:
            log.info(''.join(line))

    else:
        break
import game_map as m
import game


while (True):
    player_answer = input("Start the Game? y/n : ")

    if player_answer == 'y':
        game_map = m.new_map()
        game.player_position = m.fill_free_cell(game_map, m.cell_player)
        game.loop(game_map)

        m.cell_trap
        print(f'You {m.cell_player} at position {game.player_position}')
        print(f'Treasure {m.cell_treasure}')
        print(f'Trap {m.cell_trap}')
        for line in game_map[::-1]:
            print(line , '\n')

    else:
        break
Esempio n. 9
0
File: main.py Progetto: Pranz/gsgpy
# Grand strategy game taking place in a fantasy universe.
#
# Python 2.7
# All code except for the libtcod library written by Jesper Fridefors

import libtcodpy as libtcod
import os
import game

CWD = os.getcwd()
FONT_DIR = os.path.abspath(CWD + "/fonts")
DATA_DIR = os.path.abspath(CWD + "/data")

FONT     = "terminal12x12_gs_ro.png"

SCREEN_WIDTH  = 80
SCREEN_HEIGHT = 60

COLOR_TEXT = libtcod.Color(255,255,255)

if __name__ == "__main__":
	libtcod.console_set_custom_font(FONT_DIR + "/" + FONT, libtcod.FONT_TYPE_GREYSCALE | libtcod.FONT_LAYOUT_ASCII_INROW)
	libtcod.console_init_root(SCREEN_WIDTH, SCREEN_HEIGHT, "TownRPG", False)
	
	game.init_game()

	while not libtcod.console_is_window_closed():
		if game.loop():
			break
Esempio n. 10
0
def main(args):
    game.start()
    game.loop()
    print('game over')
    return 0
Esempio n. 11
0
def draw(stdscr, _state, _buffer):
	
	anim_time = 500
	height, width = stdscr.getmaxyx()
	inp = 0
	#map_dim = [0]
	#map_str = _buffer["map_str"]
	#mapr = gamebuffer.MapRead()
	max_h = 13
	max_w = 25
	pad_pos = 0
	
	curses.curs_set(False)
	curses.start_color()
	curses.init_pair(1, curses.COLOR_BLACK, curses.COLOR_WHITE)
	curses.init_pair(2, curses.COLOR_GREEN, curses.COLOR_WHITE)
	curses.init_pair(3, curses.COLOR_YELLOW, curses.COLOR_WHITE)
	curses.init_pair(4, curses.COLOR_BLUE, curses.COLOR_WHITE)
	curses.init_pair(5, curses.COLOR_WHITE, curses.COLOR_WHITE)

	colors = {
		'bg_white':curses.color_pair(1),
		'mp_green':curses.color_pair(2),
		'mp_yellow':curses.color_pair(3),
		'mp_blue':curses.color_pair(4),
		'mp_white':curses.color_pair(5),
			}

	
	
	#for i in range(len(map_str)):
		#s = str(map_str[i]) + "map"
		#_buffer["maps"][map_str[i]], map_dim[i] = mapr.read(map_str[i])
		#stdscr.addstr(i,0,s)
		
	stdscr.refresh()
	
	classes = {
		'sp':game.Spatial(),
		'tw':textwrap.TextWrapper(),
		}
	
	misc = {
		#'map_dim':map_dim,
		'stdscr':stdscr,
		'height':height,
		'width':width,
		}

	if width < max_w or height < max_h:
		ui_pholder(stdscr, misc)
		stdscr.clear()
	else:
		ui_greetscr(stdscr, misc)
		stdscr.clear()
		while True:
			
			
			stdscr.timeout(anim_time)
			height, width = stdscr.getmaxyx()
			misc["height"] = height
			misc["width"] = width
			
			if width < max_w or height < max_h:
				ui_pholder(stdscr, misc)
			else:
					
				try:
					pad_pos = tw["pad_pos"]
				except UnboundLocalError:
					pass
				
				dec = gamebuffer.decypher(_buffer, _state["loc"]["cur"][0], _state["loc"]["cur"][1])
				wi = window_geom(colors, classes, misc)
				st = strings_short(_state, _buffer, misc, classes, dec)
				tw = textwin_form(_state, wi, st, colors, classes, misc, pad_pos, inp)
				win_compose(height, width, wi, st, tw)
				
				ui_map(wi, _state, _buffer, colors, misc)
				refresh_all(stdscr, wi, tw, misc)
				
				inp = stdscr.getch()
				
				if inp != -1:
					_state=game.loop(inp, _state, _buffer)
		
				#UI menus.
				if inp == keymaps.new_win:
					ui_newwin(height, width, colors)
		
				if inp == keymaps.escape:
					break