Exemplo n.º 1
0
    def draw(self):
        self.orientWorld()
        for item in self.simulation.world.all:
            Render.render(item)

        HUD.draw(self.zoomedShip)
        self.drawSidebar()
Exemplo n.º 2
0
def draw_hud():
    Render.clear_layer(layers['panel_console'])
    Render.clear_layer(layers['side_panel_console'])
    render_common()
    render_messages()
    render_status()
    render_stat_bars()
Exemplo n.º 3
0
def draw_hud():
    Render.clear_layer(layers['panel_console'])
    Render.clear_layer(layers['side_panel_console'])
    render_common()
    render_messages()
    render_status()
    render_stat_bars()
Exemplo n.º 4
0
 def Register(self, request):
     if request.COOKIES.has_key("sid"):
         if (request.COOKIES["sid"] != "") and (IDs.VerifySID(
                 sid=request.COOKIES["sid"]) == True):
             return Render.Render()._Page(
                 content="<script>location.href='%s';</script>" %
                 (Settings.FORUMURL),
                 setCookies=None)
         else:
             return Render.Render()._Page(content=Pages.Pages()._FullRender(
                 content=Pages.Pages()._Render(
                     name=Pages.Pages().pageKeys["user_register_page"]),
                 condit={
                     "user": False,
                     "sid_": None
                 }),
                                          setCookies=None)
     else:
         return Render.Render()._Page(content=Pages.Pages()._FullRender(
             content=Pages.Pages()._Render(
                 name=Pages.Pages().pageKeys["user_register_page"]),
             condit={
                 "user": False,
                 "sid_": None
             }),
                                      setCookies=None)
Exemplo n.º 5
0
def render_status():
    # RENDER HEALTH BARS
    pos = Pos(Constants.MAP_CONSOLE_WIDTH + 1, 25)
    # CLEAR HP AREA / Status Area
    #Render.set_foreground(layers['side_panel_console'], libtcod.black)
    #Render.set_background(layers['side_panel_console'], libtcod.black)
    # draw_rect(layers['side_panel_console'], 1, 3, 17, 14, True, libtcod.BKGND_SET)
    # draw_rect(layers['side_panel_console'], pos.x, pos.y, 10, 9, True, libtcod.BKGND_SET)

    # print GameState.player.status

    num_of_status = 0
    inc = 0

    count = 1
    for status in GameState.player.status.summary():
        if Utils.is_mouse_in(pos.x, pos.y - 1 + count, 17, 1):
            Render.print_line(layers['side_panel_console'],
                              pos.x,
                              pos.y - 1 + count,
                              str(status[1] / 100) + " Turns",
                              f_color='light green')
        else:
            Render.print_line(layers['side_panel_console'],
                              pos.x,
                              pos.y - 1 + count,
                              status[0],
                              f_color='green')

        count += 1
    '''
Exemplo n.º 6
0
    def draw(self):
        Render.clear_layer(5)
        self.opened = True
        print self.width, self.height



        x = 5
        y = 5

        button_text = 'Close'
        button = Button(button_text,
                        self.width / 2,
                        self.height - 3,
                        function=close_window,
                        target=Render.layers['overlay_console'])

        dragging = False
        click_x = None

        mouse = Input.mouse

        while True:

            Input.update()
            Render.clear_layer(Render.layers['overlay_console'])

            Render.draw_rect(Render.layers['overlay_console'], x, y,
                             self.width,
                             self.height,
                             frame=True,
                             f_color=terminal.color_from_argb(255, 100, 100, 255),
                             bk_color=terminal.color_from_argb(192, 32, 32, 128),
                             title="POP_UP TEST!")

            Render.print_rect(Render.layers['overlay_console'], x + 2, y + 2, self.width - 4, self.height - 4, self.text)

            if mouse.lbutton and x <= mouse.cx <= x + self.width and (mouse.cy == y or dragging):
                if click_x is None:
                    click_x = mouse.cx - x
                x = mouse.cx - click_x    # (width / 2)
                y = mouse.cy
                dragging = True
            else:
                dragging = False
                click_x = None

            if button.draw(x, y) == 'close':
                self.opened = False
                Render.clear_layer(Render.layers['overlay_console'])
                return

            # libtcod.console_flush()

            # graphics.draw_image(x, y, enlarge=True)
            # graphics.draw_image(x + 1, y + 1, enlarge=True)
            # graphics.clear()
            # graphics.draw_font(0,0)

            GameState.render_ui()
Exemplo n.º 7
0
def render_status():
    # RENDER HEALTH BARS
    pos = Pos(Constants.MAP_CONSOLE_WIDTH + 1, 25)
    # CLEAR HP AREA / Status Area
    #Render.set_foreground(layers['side_panel_console'], libtcod.black)
    #Render.set_background(layers['side_panel_console'], libtcod.black)
    # draw_rect(layers['side_panel_console'], 1, 3, 17, 14, True, libtcod.BKGND_SET)
    # draw_rect(layers['side_panel_console'], pos.x, pos.y, 10, 9, True, libtcod.BKGND_SET)

    # print GameState.player.status

    num_of_status = 0
    inc = 0


    count = 1
    for status in GameState.player.status.summary():
        if Utils.is_mouse_in(pos.x, pos.y - 1 + count, 17, 1):
            Render.print_line(layers['side_panel_console'], pos.x, pos.y - 1 + count, str(status[1]/100) + " Turns", f_color='light green')
        else:
            Render.print_line(layers['side_panel_console'], pos.x, pos.y - 1 + count, status[0], f_color='green')

        count += 1


    '''
def render_animations(animation_list):
    Render.clear_layer(10)
    for ani in animation_list:
        # print "Animating................."
        result = ani.play()
        if result == 'Done':
            # print "Want?"
            animation_list.remove(ani)
        terminal.refresh()
Exemplo n.º 9
0
def render_animations(animation_list):
    Render.clear_layer(10)
    for ani in animation_list:
        # print "Animating................."
        result = ani.play()
        if result == 'Done':
            # print "Want?"
            animation_list.remove(ani)
        terminal.refresh()
Exemplo n.º 10
0
def render_messages():
    Render.clear_layer(layers['messages'])
    y = 3 + Constants.MAP_CONSOLE_HEIGHT
    for line in GameState.get_msg_queue():
        if y < Constants.SCREEN_HEIGHT - 1:
            line_height = 1
            Render.print_rect(layers['messages'], Constants.MSG_X, y, Constants.MSG_WIDTH, line_height, line)

            y += line_height
Exemplo n.º 11
0
def pop_up(width=None, height=None, title=None, text=None):
    mouse = Input.mouse
    key = Input.key

    # calculate total height for the header (after auto-wrap) and one line per option
    if width is None:
        width = Constants.MAP_CONSOLE_WIDTH - 30

    if height is None:
        height = libtcod.console_get_height_rect(
            0, 0, 0, width, Constants.SCREEN_HEIGHT, text) + 7

    pop = libtcod.console_new(width, height)
    # print the header, with auto-wrap
    libtcod.console_set_default_foreground(pop, Constants.UI_PopFore)
    libtcod.console_set_default_background(pop, Constants.UI_PopBack)

    libtcod.console_print_frame(pop,
                                0,
                                0,
                                width,
                                height,
                                clear=True,
                                flag=libtcod.BKGND_SET,
                                fmt=title)

    Render.print_rect(pop, 3, 3, width - 6, height, text)

    # blit the contents of "window" to the root console
    x = Constants.MAP_CONSOLE_WIDTH / 2 - width / 2
    y = Constants.MAP_CONSOLE_HEIGHT / 2 - height / 2

    button_text = 'Click to Continue'
    button = Button(button_text,
                    width / 2,
                    height - 3,
                    function=close_window,
                    target=pop,
                    length=len(button_text))

    libtcod.console_blit(pop, 0, 0, width, height, 0, x, y, 1.0, .85)

    while True:
        libtcod.console_blit(pop, 0, 0, width, height, 0, x, y, 1.0, 0.0)
        libtcod.console_flush()
        libtcod.sys_check_for_event(
            libtcod.EVENT_KEY_PRESS | libtcod.EVENT_MOUSE, key, mouse)

        if button.draw(x, y) == 'close':
            return

        if key.vk == libtcod.KEY_ENTER and key.lalt:
            # Alt+Enter: toggle fullscreen
            libtcod.console_set_fullscreen(not libtcod.console_is_fullscreen())
        if key.vk == libtcod.KEY_ESCAPE or key.vk == libtcod.KEY_ESCAPE or key.vk == libtcod.KEY_SPACE:
            return
Exemplo n.º 12
0
def render_messages():
    Render.clear_layer(layers['messages'])
    y = 3 + Constants.MAP_CONSOLE_HEIGHT
    for line in GameState.get_msg_queue():
        if y < Constants.SCREEN_HEIGHT - 1:
            line_height = 1
            Render.print_rect(layers['messages'], Constants.MSG_X, y,
                              Constants.MSG_WIDTH, line_height, line)

            y += line_height
Exemplo n.º 13
0
def load_layer_to_console(console, xp_file_layer):
    if not xp_file_layer['width'] or not xp_file_layer['height']:
        raise AttributeError(
            'Attempted to call load_layer_to_console on data that didn\'t have a width or height key, check your data')

    for x in range(xp_file_layer['width']):
        for y in range(xp_file_layer['height']):
            cell_data = xp_file_layer['cells'][x][y]
            fore_color = libtcod.Color(cell_data['fore_r'], cell_data['fore_g'], cell_data['fore_b'])
            back_color = libtcod.Color(cell_data['back_r'], cell_data['back_g'], cell_data['back_b'])
            Render.draw_char(console, x, y, cell_data['keycode'], fore_color, back_color)
Exemplo n.º 14
0
def main():

    # Set up lighting and camera
    setup()

    # demonstrating the creation of a temple
    temple_1 = create(10, 10, 10, "temple")
    # A temple can be moved once created
    temple_1.location = (0, 0, 0)

    # Render the scene
    Render.render((15, 10, 8), (0, 0, 3), '//render.png')
Exemplo n.º 15
0
def pop_up(width=None, height=None, title=None, text=None):
    mouse = Input.mouse
    key = Input.key

    # calculate total height for the header (after auto-wrap) and one line per option
    if width is None:
        width = Constants.MAP_CONSOLE_WIDTH - 30

    if height is None:
        height = libtcod.console_get_height_rect(0, 0, 0, width, Constants.SCREEN_HEIGHT, text) + 7

    pop = libtcod.console_new(width, height)
    # print the header, with auto-wrap
    libtcod.console_set_default_foreground(pop, Constants.UI_PopFore)
    libtcod.console_set_default_background(pop, Constants.UI_PopBack)

    libtcod.console_print_frame(pop, 0, 0, width, height, clear=True,
                                flag=libtcod.BKGND_SET,
                                fmt=title)

    Render.print_rect(pop, 3, 3, width - 6, height, text)


    # blit the contents of "window" to the root console
    x = Constants.MAP_CONSOLE_WIDTH / 2 - width / 2
    y = Constants.MAP_CONSOLE_HEIGHT / 2 - height / 2


    button_text = 'Click to Continue'
    button = Button(button_text,
                    width / 2,
                    height - 3,
                    function=close_window,
                    target=pop,
                    length=len(button_text))

    libtcod.console_blit(pop, 0, 0, width, height, 0, x, y, 1.0, .85)

    while True:
        libtcod.console_blit(pop, 0, 0, width, height, 0, x, y, 1.0, 0.0)
        libtcod.console_flush()
        libtcod.sys_check_for_event(libtcod.EVENT_KEY_PRESS | libtcod.EVENT_MOUSE, key, mouse)

        if button.draw(x, y) == 'close':
            return

        if key.vk == libtcod.KEY_ENTER and key.lalt:
            # Alt+Enter: toggle fullscreen
            libtcod.console_set_fullscreen(not libtcod.console_is_fullscreen())
        if key.vk == libtcod.KEY_ESCAPE or key.vk == libtcod.KEY_ESCAPE or key.vk == libtcod.KEY_SPACE:
            return
Exemplo n.º 16
0
def render_stat_bars():

    pos = Pos(Constants.MAP_CONSOLE_WIDTH + 4, 35)

    # SHOW PLAYER STAT BARS
    Render.draw_box_bar(pos.x, pos.y, 14, '', GameState.get_player().fighter.hp, GameState.get_player().fighter.base_max_hp,
                        Color("178,0,45"),
                        Color("64,0,16"), layers['side_panel_console'])
    Render.draw_box_bar(pos.x, pos.y + 1, 14, '', GameState.get_player().fighter.sp, GameState.get_player().fighter.base_max_sp,
                        Color("0,30,255"),
                        Color("0,10,64"), layers['side_panel_console'])
    Render.draw_box_bar(pos.x, pos.y + 2, 14, '', GameState.get_player().fighter.xp, 1000,  # TODO: will be NEXT_LVL_XP
                   Color("255,255,0"),
                        Color("65,65,0"), layers['side_panel_console'])

    # RENDER MONSTER HEALTH BARS
    temp_y = 3
    for object in GameState.current_level.get_visible_objects():
        if object.fighter and object.base_speed != 0 and (object is not GameState.get_player()):  # and Fov.is_visible(obj=object)
            if temp_y < 17: # TODO: Make constant to scale UI
                Render.draw_box_bar(Constants.MAP_CONSOLE_WIDTH + 1, temp_y, 17, object.name, object.fighter.hp, object.fighter.max_hp,
                                    Color("0,255,0"),
                                    Color("0,64,0"),
                                    layers['side_panel_console'])
                temp_y += 2
Exemplo n.º 17
0
def follow_line(source,
                target,
                projectile='-',
                end_tile='*',
                color=libtcod.yellow):

    if Constants.ANIMATE_ON:
        line = Utils.get_line((source.x, source.y), (target.x, target.y))
        for loc in line:
            Render.clear_layer(Render.layers['animation_console'])
            map_x, map_y = loc

            GameState.render_all()

            x, y = Utils.to_camera_coordinates(map_x, map_y)

            if (x, y) == line[-1]:
                Render.draw_char(Render.layers['animation_console'], x, y,
                                 end_tile, color)

            else:
                Render.draw_char(Render.layers['animation_console'], x, y,
                                 projectile, color)

            terminal.refresh()
            # time.sleep(0.01325) # 0.01325
        Render.clear_layer(Render.layers['animation_console'])
Exemplo n.º 18
0
    def __init__(self):
        #vel and pos for player:
        self.velX = 0
        self.velY = 0
        self.posX = 0
        self.posY = 0
        self.pz = 0  #player z, will not change like y does
        self.cells, map_x, map_y = self.loadLevel(3)

        screen_x = map_x * SPRITE_SIZE * SIZE_MULTIPLIER
        screen_y = map_y * SPRITE_SIZE * SIZE_MULTIPLIER

        self.screen = pygame.display.set_mode((screen_x, screen_y))
        self.clock = pygame.time.Clock()
        self.renderer = Render.Render(self.screen, pygame, COLORS, SPRITE_SIZE,
                                      SIZE_MULTIPLIER, PLAYER_SIZE)
        self.mouseX = 0
        self.mouseY = 0
        self.renderSlice = 0

        self.portalCounter = 0

        self.currentDim = 0  #current Dimension

        self.inventory = [
        ]  #inventory is going to be organized like so: t, so depending on the block type you will know what to place down
Exemplo n.º 19
0
def test_OnlineGreedyWalk():
    Agt = Agnt.clsAgent(["up", "down", "left", "right"],
                        ["x", "y", "terminal"])
    Agt.SetParameter(["Mode", "epsilon"], ["Online", [1]])
    Agt.QModel.SetUp()
    Agt.QModel.batch = 200
    Env = EnvGrid.clsEnvironment(10, 10, -1)
    Env.SetTerminalState([9, 9], 0)
    Rnr = Render.clsGrid(10, 10, "")
    for i in range(1000):
        Agt.PerceiveEnv(Env.State(), Env.Reward())
        Agt.QModel.TrainToReward(Agt.Sequence)
        Env.Step(Agt.NextAction())
        # Rnr.show(Env.GridStateAsList(),text=str(i), tim=50)
    Agt.SetParameter(["epsilon"], [[0.2]])
    for i in range(1000):
        Agt.PerceiveEnv(Env.State(), Env.Reward())
        Agt.QModel.Train(Agt.Sequence, StopAt=[5.0e-03, 0])
        Env.Step(Agt.NextAction())
        print(i)
        # Rnr.show(Env.GridStateAsList(),text=str(i), tim=50)
    Agt.SetParameter(["epsilon"], [[1]])
    for i in range(100):
        Agt.PerceiveEnv(Env.State(), Env.Reward())
        Env.Step(Agt.NextAction())
        Rnr.show(Env.GridStateAsList(), text=str(i), tim=50)

    X = Agt.Sequence.ReturnStates(None)
    Y = Agt.QModel.Predict(X, rund=2)

    Agt.States.Update(X, Q=Y)
    Agt.States.Sort()
    Agt.States.Export("csv/test/exports/test_OnlineGreedyWalkQ.csv")
    Agt.Sequence.Export("csv/test/exports/test_OnlineGreedyWalkSeq.csv")
Exemplo n.º 20
0
def test_OnlineRandomWalk():
    Agt = Agnt.clsAgent(["up", "down", "left", "right"],
                        ["x", "y", "terminal"])
    Agt.SetParameter(["Mode", "epsilon"], ["Online", [1]])
    Agt.QModel.SetUp()
    Agt.QModel.batch = 50
    Env = EnvGrid.clsEnvironment(5, 5, -1)
    Env.SetTerminalState([4, 4], 0)
    Rnr = Render.clsGrid(5, 5, "")
    for i in range(100):
        Agt.PerceiveEnv(Env.State(), Env.Reward())
        Agt.QModel.TrainToReward(Agt.Sequence)
        Env.Step(Agt.NextAction())
        Rnr.show(Env.RetGridAsArray(), text=str(i), tim=50)
    for i in range(200):
        Agt.PerceiveEnv(Env.State(), Env.Reward())
        Agt.QModel.Train(Agt.Sequence)
        Env.Step(Agt.NextAction())
        Rnr.show(Env.RetGridAsArray(), text=str(i), tim=50)

    X = Agt.Sequence.ReturnStates(None)
    Y = Agt.QModel.Predict(X, rund=2)

    Agt.States.Update(X, Q=Y)
    Agt.States.Sort()
    Agt.States.Export("csv/test/exports/test_OnlineRandomWalkQ.csv")
Exemplo n.º 21
0
class PyCube:

	def __init__(self):
		self.render = Render(window_width,window_height)
	
	def main(self):
		# initialization
		pygame.init()
		fpsClock = pygame.time.Clock()
		window = pygame.display.set_mode( [window_width,window_height] )
		output = [0]*(window_width*window_height*3)

		# main loop
		while True:
			# handle events
			for event in pygame.event.get():
				if event.type == QUIT:
					pygame.quit()
					return
				elif event.type == KEYDOWN:
					if event.key == K_SPACE:
						self.render.toggleAccelerate()
				else:
					pass

			# handle keys
			# see http://www.pygame.org/docs/ref/key.html for keys
			keys = pygame.key.get_pressed()

			# operate the cube
			if keys[pygame.K_a]:
				self.render.world.rotate('y', -rotate_angle)				
			if keys[pygame.K_d]:
				self.render.world.rotate('y', rotate_angle)		
			if keys[pygame.K_w]:
				self.render.world.rotate('x', -rotate_angle)				
			if keys[pygame.K_s]:
				self.render.world.rotate('x', rotate_angle)	
			if keys[pygame.K_q]:
				self.render.world.rotate('z', rotate_angle)				
			if keys[pygame.K_e]:
				self.render.world.rotate('z', -rotate_angle)		

			# operate the view point			
			if keys[pygame.K_UP]:
				self.render.changeViewDist(-viewDist_change)
			if keys[pygame.K_DOWN]:
				self.render.changeViewDist(viewDist_change)

			# ======
			# draw
			# ======
			self.render.draw(window)

			pygame.display.update()

			fpsClock.tick(fps)
Exemplo n.º 22
0
def load_layer_to_console(console, xp_file_layer):
    if not xp_file_layer['width'] or not xp_file_layer['height']:
        raise AttributeError(
            'Attempted to call load_layer_to_console on data that didn\'t have a width or height key, check your data'
        )

    for x in range(xp_file_layer['width']):
        for y in range(xp_file_layer['height']):
            cell_data = xp_file_layer['cells'][x][y]
            fore_color = Color('{0},{1},{2}'.format(cell_data['fore_r'],
                                                    cell_data['fore_g'],
                                                    cell_data['fore_b']))
            back_color = Color('{0},{1},{2}'.format(cell_data['back_r'],
                                                    cell_data['back_g'],
                                                    cell_data['back_b']))
            Render.draw_char(console, x, y, cell_data['keycode'], fore_color,
                             back_color)
Exemplo n.º 23
0
 def __init__(self):
     self.screen = pygame.display.set_mode((SCREEN_X, SCREEN_Y))
     self.clock = pygame.time.Clock()
     self.renderer = Render.Render(self.screen, pygame, COLORS, SPRITE_SIZE,
                                   SIZE_MULTIPLIER)
     self.items = GenerateMap.getLevelMap(MAP_NAME, COLORS, SPRITE_SIZE,
                                          DEFAULT_ITEMS)
     self.mouseX = 0
     self.mouseY = 0
Exemplo n.º 24
0
def executeJob(job):
    global render
    jobstate = 'complete'

    # Run the job independently of the subjobs.
    # We will update the subjobs based on frames completed
    render = Render.Render(job)
    render.startRender()

    return jobstate
Exemplo n.º 25
0
	def Like(self, pid=None, uid=None):
		uid = str(uid)
		d = Database.Database().Execute(query="SELECT * FROM pythobb_thread_misc WHERE pid=?", variables=(pid,), commit=False, doReturn=True)[0]
		if not uid in d[3].split(","):
			n       = int(d[1] + 1)
			likedby = d[3].split(","); likedby.append(uid)
			likedby = ",".join(likedby)
			like = "like"
		else:
			n       = int(d[1] - 1)
			likedby = d[3].split(","); likedby.remove(uid)
			likedby = ",".join(likedby)
			like = "dislike"
		try:
			Database.Database().Execute(query="UPDATE pythobb_thread_misc SET likes=?,likedby=? WHERE pid=?", variables=(n,likedby,pid), commit=True, doReturn=True)
			JSON = Render.Render()._Page(content=Render.Render()._JSON(variable="Updated", boolean=None, data=[True, like], complete=True), setCookies=None, setContentType="application/json")
		except Exception as e:
			print e
			JSON = Render.Render()._Page(content=Render.Render()._JSON(variable="Updated", boolean=None, data=[False, "An error occured."], complete=True), setCookies=None, setContentType="application/json")
		return JSON
Exemplo n.º 26
0
 def ControlPanel(self, request):
     if request.COOKIES.has_key("sid"):
         if (IDs.VerifySID(sid=request.COOKIES["sid"]) == True):
             user_status, sid = True, request.COOKIES["sid"]
         else:
             return Render.Render()._Page(
                 content="<script>location.href='%s';</script>" %
                 (Settings.FORUMURL),
                 setCookies=None)
     else:
         return Render.Render()._Page(
             content="<script>location.href='%s';</script>" %
             (Settings.FORUMURL),
             setCookies=None)
     return Render.Render()._Page(content=Pages.Pages()._RenderUserCP(
         content=Pages.Pages()._Render(name="user_controlpanel"),
         condit={
             "user": user_status,
             "sid_": sid
         }),
                                  setCookies=None)
Exemplo n.º 27
0
	def doSearch(self, request):
		if request.COOKIES.has_key("sid"):
			if(IDs.VerifySID(sid=request.COOKIES["sid"])==True):
				user_status,sid = True,request.COOKIES["sid"]
			else:
				user_status,sid = False,None
		else:
			user_status,sid = False,None
		if request.POST["query"] != "":
			searchquery = request.POST["query"]
		else:
			return Render.Render()._Page(content="<script>location.href= \"%s\";</script>"%(Settings.FORUMURL), setCookies=None)
		return Pages.Pages()._RenderSearchResults(content=Pages.Pages()._Render(name="search_results"), results=self.Execute(query=searchquery), condit={"user":user_status, "sid_": sid})
Exemplo n.º 28
0
def Renders(script):
    Input = {
        'name': script["name"],
        'option': script["option"],
        'snmp': script["snmp"],
        'oid': script["oid"],
        'vars': script["vars"],
        'UNKNOWN': script["UNKNOWN"],
        'CRITICAL': script["CRITICAL"],
        'WARNING': script["WARNING"],
        'OK': script["OK"],
    }
    Render(Input).script()
Exemplo n.º 29
0
 def ProcessUserCP(self, request):
     reqData = {
         "Usertitle": request.POST["Usertitle"],
         "Avatar": request.POST["AvatarURL"]
     }
     print request.COOKIES
     if request.COOKIES.has_key("sid"):
         if (IDs.VerifySID(sid=request.COOKIES["sid"]) == True):
             user_status, sid = True, request.COOKIES["sid"]
         else:
             return Render.Render()._Page(
                 content="<script>location.href='%s';</script>" %
                 (Settings.FORUMURL),
                 setCookies=None)
     else:
         return Render.Render()._Page(
             content="<script>location.href='%s';</script>" %
             (Settings.FORUMURL),
             setCookies=None)
     try:
         uid = Database.Database().Execute(
             query="SELECT * FROM pythobb_user_data WHERE sessionid=?",
             variables=(sid, ),
             commit=False,
             doReturn=True)[0][0]
         for c in reqData:
             if (c == "Usertitle") and (reqData[c] != ""):
                 Database.Database().Execute(
                     query=
                     "UPDATE pythobb_user_data2 SET usertitle=? WHERE uid=?",
                     variables=(
                         str(reqData["Usertitle"]),
                         uid,
                     ),
                     commit=True)
             if (c == "Avatar") and (reqData[c] != ""):
                 Database.Database().Execute(
                     query=
                     "UPDATE pythobb_user_data2 SET avatar=? WHERE uid=?",
                     variables=(
                         str(reqData["Avatar"]),
                         uid,
                     ),
                     commit=True)
         JSON = Render.Render()._Page(content=Render.Render()._JSON(
             variable="Updated", boolean=True, data=None, complete=True),
                                      setCookies=None,
                                      setContentType="application/json")
     except Exception as e:
         print str(e)
         JSON = Render.Render()._Page(content=Render.Render()._JSON(
             variable="Updated",
             boolean=None,
             data=[False, "An error occured."],
             complete=True),
                                      setCookies=None,
                                      setContentType="application/json")
     return JSON
Exemplo n.º 30
0
def load_layer_to_layer(layer, x, y, xp_file_layer):
    if not xp_file_layer['width'] or not xp_file_layer['height']:
        raise AttributeError(
            'Attempted to call load_layer_to_console on data that didn\'t have a width or height key, check your data'
        )

    offset_x, offset_y = x, y

    for x in range(xp_file_layer['width']):
        for y in range(xp_file_layer['height']):
            cell_data = xp_file_layer['cells'][x][y]
            fore_color = libtcod.Color(cell_data['fore_r'],
                                       cell_data['fore_g'],
                                       cell_data['fore_b'])
            back_color = libtcod.Color(cell_data['back_r'],
                                       cell_data['back_g'],
                                       cell_data['back_b'])

            Render.draw_char(layer, x + offset_x, y + offset_y,
                             Utils.get_unicode(219), back_color, back_color)
            Render.draw_char(layer, x + offset_x, y + offset_y,
                             Utils.get_unicode(cell_data['keycode']),
                             fore_color, back_color)
Exemplo n.º 31
0
 def ProcessLogin(self, request):
     _RequestedUser = {
         "Username": request.POST["Username"],
         "Password": request.POST["Password"]
     }
     _return = Database.Database().Execute(
         query="SELECT * FROM pythobb_users WHERE username=?",
         variables=(_RequestedUser["Username"], ),
         commit=False,
         doReturn=True)
     uid, salt, password = _return[0][0], _return[0][2], _return[0][3]
     _UserData = Database.Database().Execute(
         query="SELECT * FROM pythobb_user_data WHERE uid=?",
         variables=(uid, ),
         commit=False,
         doReturn=True)
     if (Security.Security()._Hash(verify=True,
                                   string=(_RequestedUser["Password"] +
                                           salt),
                                   hash=password) == True):
         JSON = Render.Render()._Page(content=str(Render.Render()._JSON(
             variable="LoginAttempt",
             boolean=None,
             data=_UserData[0][1],
             complete=True)),
                                      setCookies=None,
                                      setContentType="application/json")
     else:
         JSON = Render.Render()._Page(content=str(Render.Render()._JSON(
             variable="LoginAttempt",
             boolean=False,
             data=None,
             complete=True)),
                                      setCookies=None,
                                      setContentType="application/json")
     return JSON
Exemplo n.º 32
0
def checkColl(n):
    global testpoints
    global ranges
    global distfront

    for i in range(0, len(ranges)):
        if (not render.getTrackmap(
                player.posx + ranges[i] * testpoints[n][0],
                player.posy + ranges[i] * testpoints[n][1])):
            if (n == 3):
                distfront = ranges[i]
            return True
    if (n == 3):
        distfront = 1.0
    return False
Exemplo n.º 33
0
 def Thread(self, request, tid):
     if request.COOKIES.has_key("sid"):
         if (IDs.VerifySID(sid=request.COOKIES["sid"]) == True):
             user_status, sid = True, request.COOKIES["sid"]
         else:
             user_status, sid = False, None
     else:
         user_status, sid = False, None
     return Render.Render()._Page(content=Pages.Pages()._RenderThread(
         content=Pages.Pages()._Render(name="thread_display"),
         condit={
             "user": user_status,
             "sid_": sid
         },
         tid=tid),
                                  setCookies=None)
Exemplo n.º 34
0
 def Home(self, request):
     RotateCSRFToken(request)
     if request.COOKIES.has_key("sid"):
         if (IDs.VerifySID(sid=request.COOKIES["sid"]) == True):
             user_status, sid = True, request.COOKIES["sid"]
         else:
             user_status, sid = False, None
     else:
         user_status, sid = False, None
     return Render.Render()._Page(content=Pages.Pages()._FullRender(
         content=Pages.Pages()._Render(name="index"),
         condit={
             "user": user_status,
             "sid_": sid
         }),
                                  setCookies=None)
Exemplo n.º 35
0
    def get_output(self, packet):
        Data.process(self, packet)
        Plan.state(self)

        if self.state == "kickoff":
            Exec.kickoff(self)

        elif self.state == "plan":
            Plan.targets(self)
            Plan.path(self)

            self.plan_pads = []
            Plan.convboost(self)

            #self.send_quick_chat(QuickChats.CHAT_EVERYONE, QuickChats.Reactions_Calculated)

            self.state = "exec"

        elif self.state == "exec":
            Exec.path(self)

            if len(self.guides) < 4 or dist2d(self.player.pos,
                                              self.guides[0]) > 200.0:
                self.state = "plan"

        #finding the size of the Rocket League window
        def callback(hwnd, win_rect):
            if "Rocket League" in win32gui.GetWindowText(hwnd):
                rect = win32gui.GetWindowRect(hwnd)
                win_rect[0] = rect[0]
                win_rect[1] = rect[1]
                win_rect[2] = rect[2] - rect[0]
                win_rect[3] = rect[3] - rect[1]

        self.RLwindow = [0] * 4
        win32gui.EnumWindows(callback, self.RLwindow)

        #Rendering
        Render.path(self)
        Render.debug(self)
        Render.targets(self)
        Render.turn_circles(self)

        return self
Exemplo n.º 36
0
 def _RenderForum(self, content=None, condit=None, fid=None):
     page = self._FullRender(content=content, condit=condit)
     _for = Database.Database().Execute(
         query="SELECT * FROM pythobb_forums WHERE fid=?",
         variables=(fid, ),
         commit=False,
         doReturn=True)[0]
     page = page.replace(
         "{[forums]}",
         self._RenderForumThreads(
             content=self._Render(name="forum_display_forum"),
             fid=fid)).replace("{[forumname]}", _for[2]).replace(
                 "{[forumdesc]}",
                 _for[3]).replace("{[fid]}",
                                  str(fid)).replace("{[forumurl]}",
                                                    Settings.FORUMURL)
     return Render.Render()._Page(content=page, setCookies=None)
Exemplo n.º 37
0
    def __init__(self, project_dir, create=False):
        self.project_dir = project_dir
        self.cam = Camera.Camera()
        self.image_list = []
        self.matcher_params = {
            'matcher': 'FLANN',  # { FLANN or 'BF' }
            'match-ratio': 0.75,
            'filter': 'fundamental',
            'image-fuzz': 40,
            'feature-fuzz': 20
        }

        # the following member variables need to be reviewed/organized
        self.ac3d_steps = 8
        self.render = Render.Render()
        self.dir_node = getNode('/config/directories', True)
        self.load(create)
Exemplo n.º 38
0
def follow_line(source, target, projectile='-', end_tile='*', color=libtcod.yellow):

    if Constants.ANIMATE_ON:
        line = Utils.get_line((source.x, source.y), (target.x, target.y))
        for loc in line:
            Render.clear_layer(Render.layers['animation_console'])
            map_x, map_y = loc

            GameState.render_all()

            x, y = Utils.to_camera_coordinates(map_x, map_y)

            if (x, y) == line[-1]:
                Render.draw_char(Render.layers['animation_console'], x, y, end_tile, color)

            else:
                Render.draw_char(Render.layers['animation_console'], x, y, projectile, color)

            terminal.refresh()
            # time.sleep(0.01325) # 0.01325
        Render.clear_layer(Render.layers['animation_console'])
Exemplo n.º 39
0
 def MakeProfile(self, request, uid):
     if request.COOKIES.has_key("sid"):
         if (IDs.VerifySID(sid=request.COOKIES["sid"]) == True):
             user_status, sid = True, request.COOKIES["sid"]
         else:
             user_status, sid = False, None
     else:
         user_status, sid = False, None
     return Render.Render()._Page(content=Pages.Pages()._FullRender(
         content=Pages.Pages()._Render("user_profile"),
         condit={
             "user": user_status,
             "sid_": sid
         },
         extra={
             "GET": "userprofile",
             "requesteduser": uid
         }),
                                  setCookies=None)
Exemplo n.º 40
0
    def __init__(self):
        # Initialize all API's object
        # Create necessay data structure
        self.answers = ['animal', 'deer', 'caribou']
        self.API_list = ['Amazon', 'Clarifai', 'Google', 'IBM']
        self.table = dict()
        self.aws = AWS.Rekonition()
        self.clarifai = Clarifai.Predict()
        self.google = Google.VisionAI()
        self.ibm = IBM.WatsonVisualRecognition()
        self.render = Render.Processing()

        # Files Path
        self.ImageFolderPath = os.getcwd() + os.sep + 'images'
        self.AnswerKeyPath = os.getcwd() + os.sep + 'anwsers.txt'

        # Table Control
        self.create_table()
        self.update_table()
Exemplo n.º 41
0
    def __init__(self):
        self.player_count = int(input("Player count?\n"))
        self.current_player = 0
        self.roll = 0

        self.intro = True
        self.intro_progress = 0
        self.intro_settlement = True
        self.intro_road = True

        f = open("coloursRGB.txt", "r")
        lines = f.readlines()
        self.players = [Player(i, tuple([int(x) for x in lines[i].split(",")])) for i in range(self.player_count)]
        f.close()

        random.shuffle(self.players)

        self.render_agent = Render.Render()
        self.board = Board.Map()
Exemplo n.º 42
0
    def _draw(self):

        self.current_frame += 0.1
        if self.current_frame >= self.delay:
            self.current_frame = 0
            self.frame = self.vector.next_pos()
            if self.random_chr:
                self.chr = random.choice(self._chr_list)
            else:
                self.chr = next(self.chr_list)
            if self.random_color:
                self.color = random.choice(self._color_list)
            else:
                #determin percentage of travel
                index = int((float(self.loops) / float(self.max_size))*len(self._color_list))
                # print "Loops: {0}, Max Size: {2}, Index: {1}".format(self.loops, index, self.max_size)

                self.color = self._color_list[min(index, len(self._color_list)-1)]
                # print "Loops: {0}, Max Size: {2}, Index: {1}".format(self.loops, index, self.max_size)
            self.loops += 1


        if self.frame:
            for cell in self.frame:
                cam_x, cam_y = Utils.to_camera_coordinates(cell[0], cell[1])
                # Determine where we should draw


                always_draw = True

                if (not GameState.current_level.is_blocked(cell[0], cell[1], ignore_mobs=True)\
                        and GameState.current_level.is_visible(pos=(cell[0], cell[1]))\
                        and cell != (GameState.player.x , GameState.player.y)) or always_draw == True:

                    if not self.random_chr:
                        # TEMP
                        self.color = terminal.color_from_argb(max(255-((255/self.max_loops)*self.loops),0), 255, 196, 128)
                        Render.print_line(10, cam_x, cam_y, "[align=center-center]{0}".format(self._chr_list[0]), f_color=self.color)
                    else:
                        if self.background:
                            #Render.draw_char(10, cam_x, cam_y, Utils.get_unicode(219), color=random.choice(self._color_list), alpha=64)
                            choice = random.choice(self._color_list)
                            #print "CHOICE: {0}".format(choice)
                            Render.draw_char(10, cam_x, cam_y, Utils.get_unicode(219),
                                             color=choice, alpha=64)
                        Render.draw_char(10, cam_x, cam_y, self.chr, color=self.color)

        else:
            #print "Animation Done."
            return 'Done'
Exemplo n.º 43
0
	def __init__(self):
		self.render = Render(window_width,window_height)
Exemplo n.º 44
0
def large_button(x, y, text, hover, length=None, target=0):

    animation_console = target

    if hover:
        color = Color('light azure')
    else:
        color = Color('azure')

    if length is None:
        length = len(text)
    text = text.center(length)

    x = x - ((length + 2) / 2)
    base_color = color
    value = 40
    adj = Color("{0},{0},{0}".format(value))
    color1 = base_color - adj - adj
    color2 = base_color - adj
    color3 = base_color


    #Render.draw_char(animation_console, x + 1, y, libtcod.CHAR_HLINE, color, libtcod.BKGND_NONE)

    Render.draw_char(animation_console, x, y - 1, Constants.BOX_NW, color1, libtcod.BKGND_NONE)
    Render.draw_char(animation_console, x, y, Constants.BOX_W, color2, libtcod.BKGND_NONE)
    Render.draw_char(animation_console, x, y + 1, Constants.BOX_SW, color3, libtcod.BKGND_NONE)

    for z in range(length):
        Render.draw_char(animation_console, x + z + 1, y - 1, Constants.BOX_S, color1, libtcod.BKGND_NONE)
        Render.draw_char(animation_console, x + z + 1, y, text[z], color2, libtcod.BKGND_NONE)
        Render.draw_char(animation_console, x + z + 1, y + 1, Constants.BOX_S, color3, libtcod.BKGND_NONE)

    Render.draw_char(animation_console, x + 1 + length, y - 1, Constants.BOX_NE, color1, libtcod.BKGND_NONE)
    Render.draw_char(animation_console, x + 1 + length, y, Constants.BOX_W, color2, libtcod.BKGND_NONE)
    Render.draw_char(animation_console, x + 1 + length, y + 1, Constants.BOX_SE, color3, libtcod.BKGND_NONE)
Exemplo n.º 45
0
def explosion(target, radius=3):
    if Constants.ANIMATE_ON:
        x, y = Utils.to_camera_coordinates(target.x, target.y)
        for r in range(0, radius):
            Render.render_all()
            if r >= 0:
                Render.draw_char(0, x, y, 'X', libtcod.red, libtcod.BKGND_NONE)
                print "1"
            if r >= 1:
                Render.draw_char(0, x - 1, y, 'X', libtcod.red, libtcod.BKGND_NONE)
                Render.draw_char(0, x + 1, y, 'X', libtcod.red, libtcod.BKGND_NONE)
                Render.draw_char(0, x, y - 1, 'X', libtcod.red, libtcod.BKGND_NONE)
                Render.draw_char(0, x, y + 1, 'X', libtcod.red, libtcod.BKGND_NONE)
                print "2"
            if r >= 2:
                Render.draw_char(0, x - 2, y, 'X', libtcod.red, libtcod.BKGND_NONE)
                Render.draw_char(0, x + 2, y, 'X', libtcod.red, libtcod.BKGND_NONE)
                Render.draw_char(0, x, y - 2, 'X', libtcod.red, libtcod.BKGND_NONE)
                Render.draw_char(0, x, y + 2, 'X', libtcod.red, libtcod.BKGND_NONE)

                Render.draw_char(0, x + 1, y + 1, 'X', libtcod.red, libtcod.BKGND_NONE)
                Render.draw_char(0, x - 1, y + 1, 'X', libtcod.red, libtcod.BKGND_NONE)
                Render.draw_char(0, x + 1, y - 1, 'X', libtcod.red, libtcod.BKGND_NONE)
                Render.draw_char(0, x - 1, y - 1, 'X', libtcod.red, libtcod.BKGND_NONE)
                print "3"
            libtcod.console_flush()
            print "sleep"
            time.sleep(0.025)
Exemplo n.º 46
0
def inspect_banner(x, y, banner_text, new_animation=True):

    animation_console = Render.layers['animation_console']
    # animation_console = 0

    # print "printing"

    color = libtcod.light_blue
    libtcod.console_set_default_foreground(animation_console, libtcod.lighter_blue)
    libtcod.console_set_default_background(animation_console, libtcod.green)
    libtcod.console_set_background_flag(animation_console, libtcod.BKGND_MULTIPLY)

    length = len(banner_text)

    back = libtcod.green

    Render.draw_char(animation_console, x + 1, y, libtcod.CHAR_HLINE, color, back)

    Render.draw_char(animation_console, x + 2, y - 1, libtcod.CHAR_NW, color, back)
    Render.draw_char(animation_console, x + 2, y, libtcod.CHAR_TEEW, color, back)
    Render.draw_char(animation_console, x + 2, y + 1, libtcod.CHAR_SW, color, back)

    if new_animation:
        for z in range(length):

            Render.draw_char(animation_console, x + z + 3, y - 1, libtcod.CHAR_HLINE, color, back)
            Render.draw_char(animation_console, x + z + 3, y, banner_text[z], color, back)
            Render.draw_char(animation_console, x + z + 3, y + 1, libtcod.CHAR_HLINE, color, back)
            # Render.update_animations()
            libtcod.console_flush()
            # time.sleep(0.05)
    else:
        for z in range(length):
            Render.draw_char(animation_console, x + z + 3, y - 1, libtcod.CHAR_HLINE, color, back)
            Render.draw_char(animation_console, x + z + 3, y, ' ', color, back)
            Render.draw_char(animation_console, x + z + 3, y + 1, libtcod.CHAR_HLINE, color, back)

    Render.draw_char(animation_console, x + 3 + length, y - 1, libtcod.CHAR_NE, color, back)
    Render.draw_char(animation_console, x + 3 + length, y, libtcod.CHAR_VLINE, color, back)
    Render.draw_char(animation_console, x + 3 + length, y + 1, libtcod.CHAR_SE, color, back)

    libtcod.console_set_default_foreground(animation_console, libtcod.lightest_blue)
    Render.print_line(animation_console, x + 3, y, libtcod.BKGND_NONE, libtcod.LEFT, banner_text)
    libtcod.console_flush()
Exemplo n.º 47
0
def play():

    while True:
        # Engine.Input.clear()
        Engine.Input.update()
        key = Engine.Input.key
        terminal.clear()
        terminal.color('white')
        # terminal.print_(terminal.state(terminal.TK_MOUSE_X), terminal.state(terminal.TK_MOUSE_Y),"HellowWorld")
        #test_anim.draw(terminal.state(terminal.TK_MOUSE_X),terminal.state(terminal.TK_MOUSE_Y))

        if key == terminal.TK_MOUSE_LEFT:
            x, y = terminal.state(terminal.TK_MOUSE_X), terminal.state(terminal.TK_MOUSE_Y)
            # animations.append(create_anim(x,y, Utils.heat_map_chrs, Utils.explosion_colors, number=50))
            #animations.append(Engine.Animation_System.Flame(x, y, size=25, density=70))
            choice = random.randint(0,5)

            # Engine.Animation_System.(Engine.Animation_System.A_FLAME, **kwargs)

            #choice = 0
            print choice

            # TODO: Cleaup Call. ADD KWARG support, Accept POS(x, y) instead of x,y. make all default variables overrideable via Kwargs

            animation_params={
                'origin': (x, y),
                'target': (x, y)
            }

            if choice == 0:
                    animations.append(
                            Engine.Animation_System.Animation('Flame', animation_params))   # , angle=random.randint(270, 270)))
            if choice == 1:
                    animations.append(
                            Engine.Animation_System.Animation('Burst', animation_params))
            if choice == 4:
                    animations.append(
                            Engine.Animation_System.Animation('Line', animation_params))
            if choice == 2:
                    animations.append(
                            Engine.Animation_System.Animation('IceBreath', animation_params))
            if choice == 3:
                    animations.append(
                            Engine.Animation_System.Animation('TinyFire', animation_params))
            if choice == 5:
                    animations.append(
                            Engine.Animation_System.Animation('Xmas', animation_params))

            #print len(animations)

        Render.draw_char(0, 15,15, '@')
        terminal.color('han')
        Render.draw_char(0, 17, 15, 'T')

        for ani in animations:
            result = ani.play()
            if result == 'Done':
                print "Want?"
                animations.remove(ani)

        #print len(animations)

        terminal.refresh()
Exemplo n.º 48
0
def skill_tree():
    key = libtcod.Key()
    mouse = libtcod.Mouse()

    # calculate total height for the header (after auto-wrap) and one line per option
    width = Constants.MAP_CONSOLE_WIDTH
    height = Constants.MAP_CONSOLE_HEIGHT

    st = libtcod.console_new(width, height)
    # print the header, with auto-wrap
    libtcod.console_set_default_foreground(st, Constants.UI_PopFore)
    libtcod.console_set_default_background(st, Constants.UI_PopBack)

    libtcod.console_print_frame(st, 0, 0, width, height, clear=True,
                                flag=libtcod.BKGND_SET,
                                fmt="Skill Tree")

    Render.print_rect(st, 4, 4, width, height, 'Insert Skill Tree')

    # blit the contents of "window" to the root console
    x = 0
    y = 0

    file = open('Assets\skill_tree.map', 'r')

    # fill map with "blocked" tiles
    #kills = [[' ' for y in range(Constants.MAP_CONSOLE_HEIGHT)] for x in range(Constants.MAP_CONSOLE_WIDTH)]

    skills = [[Skill(' ') for y in range(Constants.MAP_HEIGHT)] for x in range(Constants.MAP_WIDTH)]



    selected_x = 0
    selected_y = 0

    for y in range(Constants.MAP_CONSOLE_HEIGHT):
        line = file.readline()
        # print line
        x = 0
        for c in line:
            if c == 'S':
                selected_x = x
                selected_y = y
                skills[x][y] = Skill(c, True)
            else:
                skills[x][y] = Skill(c)
            x += 1

    # print selected_x, selected_y



    button_text = 'Exit'
    ct_button = Button(button_text,
                       width / 2,
                       height - 3,
                       length=6,
                       function=close_window)



    while True:

        libtcod.console_flush()
        libtcod.sys_check_for_event(libtcod.EVENT_KEY_PRESS | libtcod.EVENT_MOUSE, key, mouse)



        if key.vk == libtcod.KEY_LEFT:
            if skills[selected_x-1][selected_y].char == "-":
                selected_x -= 2
        elif key.vk == libtcod.KEY_RIGHT:
            if skills[selected_x + 1][selected_y].char == "-":
                selected_x += 2
        elif key.vk == libtcod.KEY_UP:
            if skills[selected_x][selected_y-1].char == "|":
                selected_y -= 2
        elif key.vk == libtcod.KEY_DOWN:
            if skills[selected_x ][selected_y+1].char == "|":
                selected_y += 2
        elif key.vk == libtcod.KEY_SPACE:
            skills[selected_x][selected_y].purchased = True

        if selected_y < 0:
            selected_y = 0
        if selected_x < 0:
            selected_x = 0

        offset = 20, 10

        for y in range(Constants.MAP_CONSOLE_HEIGHT):
            for x in range(Constants.MAP_CONSOLE_WIDTH):
                # print skills
                if selected_x == x and selected_y == y:
                    color = Color('purple')
                else:
                    if skills[x][y].purchased:
                        color = Color('green')
                    else:
                        color = Color('white')

                char = skills[x][y].char
                if char == "|":
                    Render.draw_char(st, x + x + offset[0], y + y + offset[1], libtcod.CHAR_VLINE, libtcod.white, Constants.UI_PopBack)
                elif char == "-":
                    Render.draw_char(st, x + x + offset[0], y + y + offset[1], libtcod.CHAR_HLINE, libtcod.white, Constants.UI_PopBack)
                elif char == ".":
                    if color == Color('purple'):
                        Render.draw_char(st, x + x + offset[0] + 1, y + y + offset[1] - 1, libtcod.CHAR_DNE,
                                         color, Constants.UI_PopBack)
                        Render.draw_char(st, x + x + offset[0], y + y + offset[1] - 1, libtcod.CHAR_DHLINE,
                                         color, Constants.UI_PopBack)
                        Render.draw_char(st, x + x + offset[0] - 1, y + y + offset[1] - 1, libtcod.CHAR_DNW,
                                         color, Constants.UI_PopBack)
                        Render.draw_char(st, x + x + offset[0] - 1, y + y + offset[1], libtcod.CHAR_DVLINE,
                                         color, Constants.UI_PopBack)
                        Render.draw_char(st, x + x + offset[0] + 1, y + y + offset[1], libtcod.CHAR_DVLINE,
                                         color, Constants.UI_PopBack)
                        Render.draw_char(st, x + x + offset[0] + 1, y + y + offset[1] + 1, libtcod.CHAR_DSE,
                                         color, Constants.UI_PopBack)
                        Render.draw_char(st, x + x + offset[0], y + y + offset[1] + 1, libtcod.CHAR_DHLINE,
                                         color, Constants.UI_PopBack)
                        Render.draw_char(st, x + x + offset[0] - 1, y + y + offset[1] + 1, libtcod.CHAR_DSW,
                                         color, Constants.UI_PopBack)
                    else:
                        Render.draw_char(st, x + x + offset[0] + 1, y + y + offset[1] - 1, ' ',
                                         color, Constants.UI_PopBack)
                        Render.draw_char(st, x + x + offset[0], y + y + offset[1] - 1, ' ',
                                         color, Constants.UI_PopBack)
                        Render.draw_char(st, x + x + offset[0] - 1, y + y + offset[1] - 1, ' ',
                                         color, Constants.UI_PopBack)
                        Render.draw_char(st, x + x + offset[0] - 1, y + y + offset[1], ' ',
                                         color, Constants.UI_PopBack)
                        Render.draw_char(st, x + x + offset[0] + 1, y + y + offset[1], ' ',
                                         color, Constants.UI_PopBack)
                        Render.draw_char(st, x + x + offset[0] + 1, y + y + offset[1] + 1, ' ',
                                         color, Constants.UI_PopBack)
                        Render.draw_char(st, x + x + offset[0], y + y + offset[1] + 1, ' ',
                                         color, Constants.UI_PopBack)
                        Render.draw_char(st, x + x + offset[0] - 1, y + y + offset[1] + 1, ' ',
                                         color, Constants.UI_PopBack)

                    Render.draw_char(st, x + x + offset[0], y + y + offset[1], chr(4),
                                     libtcod.white, Constants.UI_PopBack)




                elif char != ' ' and char != chr(10):
                    Render.draw_char(st, x + x + offset[0] + 1, y + y + offset[1] - 1, libtcod.CHAR_DNE, color, Constants.UI_PopBack)
                    Render.draw_char(st, x + x + offset[0], y + y + offset[1] - 1, libtcod.CHAR_DHLINE, color, Constants.UI_PopBack)
                    Render.draw_char(st, x + x + offset[0] - 1, y + y + offset[1] - 1, libtcod.CHAR_DNW, color, Constants.UI_PopBack)

                    Render.draw_char(st, x + x + offset[0] - 1, y + y + offset[1], libtcod.CHAR_DVLINE, color, Constants.UI_PopBack)

                    Render.draw_char(st, x + x + offset[0], y + y + offset[1], char, libtcod.red, Constants.UI_PopBack)

                    Render.draw_char(st, x + x + offset[0] + 1, y + y + offset[1], libtcod.CHAR_DVLINE, color, Constants.UI_PopBack)

                    Render.draw_char(st, x + x + offset[0] + 1, y + y + offset[1] + 1, libtcod.CHAR_DSE, color, Constants.UI_PopBack)
                    Render.draw_char(st, x + x + offset[0], y + y + offset[1] + 1, libtcod.CHAR_DHLINE, color, Constants.UI_PopBack)
                    Render.draw_char(st, x + x + offset[0] - 1, y + y + offset[1] + 1, libtcod.CHAR_DSW, color, Constants.UI_PopBack)



        if ct_button.draw(x, y) == 'close':
            return


        libtcod.console_blit(st, 0, 0, width, height, 0, 0, 0, 1.0, 1.0)
Exemplo n.º 49
0
def beastiary(width=10, height=10, title=None, text=None):

    # calculate total height for the header (after auto-wrap) and one line per option
    if width is None:
        width = Constants.MAP_CONSOLE_WIDTH - 10

    if height is None:
        height = libtcod.console_get_height_rect(0, 0, 0, width, Constants.SCREEN_HEIGHT, text) + 7

    pop = libtcod.console_new(width, height)
    # print the header, with auto-wrap
    libtcod.console_set_default_foreground(pop, Constants.UI_PopFore)
    libtcod.console_set_default_background(pop, Constants.UI_PopBack)

    libtcod.console_print_frame(pop, 0, 0, width, height, clear=True,
                                flag=libtcod.BKGND_SET,
                                fmt=title)
    # blit the contents of "window" to the root console

    x = 0
    y = 0

    button_text = 'Click to Continue'
    button = Button(button_text,
                    width / 2,
                    height - 3,
                    function=close_window)

    img = libtcod.image_load('Images//cipher_warden_80x80_test_01.png')
    libtcod.image_set_key_color(img, Color(0, 0, 0))
    # show the background image, at twice the regular console resolution
    libtcod.image_blit_2x(img, pop, 9, 2)

    libtcod.console_set_default_foreground(pop, Constants.UI_PopFore)
    libtcod.console_set_default_background(pop, Constants.UI_PopBack)
    Render.print_rect(pop, 3, 3, width - 6, height, text)

    background = libtcod.console_new(Constants.SCREEN_WIDTH, Constants.SCREEN_HEIGHT)
    libtcod.console_blit(0, 0, 0, Constants.SCREEN_WIDTH, Constants.SCREEN_HEIGHT, background, 0, 0, 1.0, 1.0)

    dragging = False

    click_x = None

    while True:
        Input.update()
        mouse = Input.mouse

        Render.blit(background, 0)
        # libtcod.console_blit(background, 0, 0, Constants.SCREEN_WIDTH, Constants.SCREEN_HEIGHT, 0, 0, 0, 1.0, 1.0)
        libtcod.console_blit(pop, 0, 0, width, height, 0, x, y, 1.0, .85)

        if mouse.lbutton and x <= mouse.cx <= x + width and (mouse.cy == y or dragging):
            if click_x is None:
                click_x = mouse.cx - x
            x = mouse.cx - click_x    # (width / 2)
            y = mouse.cy
            dragging = True
        else:
            dragging = False
            click_x = None

        if button.draw(x, y) == 'close':
            return
        libtcod.console_flush()
Exemplo n.º 50
0
def display_mainMenu():
    # new_game()

    width = Constants.SCREEN_WIDTH
    height = Constants.SCREEN_HEIGHT

    Render.draw_rect(10, 0, 0, width, height,
                     frame=True,
                     f_color=Color('dark azure'),
                     bk_color=Color('darkest azure'),
                     title="DEEP FRIED SUPERNOVA v0.01")

    Render.print_rect(10, 4, 4, width, height, 'Welcome to Deep Fried Supernova')


    # blit the contents of "window" to the root console
    x = 0
    y = 0


    button_text = 'New Game'
    ng_button = Button(button_text,
                       width / 2,
                       height - 12,
                       length=16,
                       function=new_game,
                       target=10)

    button_text = 'Continue Game'
    ct_button = Button(button_text,
                       width / 2,
                       height - 9,
                       length=16,
                       function=continue_game,
                       target=10)

    button_text = 'Quit'
    qt_button = Button(button_text,
                       width / 2,
                       height - 6,
                       length=16,
                       function=close_window,
                       target=10)

    img = libtcod.image_load('diner_logo_sm.png')
    # libtcod.image_set_key_color(img, Color(0, 0, 0))

    # show the background image, at twice the regular console resolution
    #libtcod.image_blit_2x(img, mm, 37, 2)

    #libtcod.console_blit(mm, 0, 0, width, height, 0, 0, 0, 1.0, 1.0)

    while True:
        Input.update()

        if qt_button.draw(0,0) == 'close':
            return

        if ct_button.draw(0,0) == 'continue':
            return

        ng_button.draw(0, 0)
        terminal.refresh()
Exemplo n.º 51
0
def menu(header, options, width):
    key = libtcod.Key()
    mouse = libtcod.Mouse()
    if len(options) > 26:
        raise ValueError('Cannot have a menu with more than 26 options.')

    # calculate total height for the header (after auto-wrap) and one line per option
    header_height = libtcod.console_get_height_rect(Render.layers['map_console'], 0, 0, width, Constants.SCREEN_HEIGHT, header)
    if header == '':
        header_height = 0
    height = len(options) + header_height

    # create an off-screen console that represents the menu's window
    window = libtcod.console_new(width, height)

    # print the header, with auto-wrap
    libtcod.console_set_default_foreground(window, libtcod.white)
    libtcod.console_print_rect_ex(window, 0, 0, width, height, libtcod.BKGND_NONE, libtcod.LEFT, header)

    # print all the options
    y = header_height
    letter_index = ord('a')
    for option_text in options:
        text = '(' + chr(letter_index) + ') ' + option_text
        Render.print_line(window, 0, y, libtcod.BKGND_NONE, libtcod.LEFT, text)
        y += 1
        letter_index += 1

    # blit the contents of "window" to the root console
    x = Constants.SCREEN_WIDTH / 2 - width / 2
    y = Constants.SCREEN_HEIGHT / 2 - height / 2
    libtcod.console_blit(window, 0, 0, width, height, 0, x, y, 1.0, 0.5)

    # compute x and y offsets to convert console position to menu position
    x_offset = x  # x is the left edge of the menu
    y_offset = y + header_height  # subtract the height of the header from the top edge of the menu

    while True:
        # present the root console to the player and check for input
        libtcod.console_flush()
        libtcod.sys_check_for_event(libtcod.EVENT_KEY_PRESS | libtcod.EVENT_MOUSE, key, mouse)

        if mouse.lbutton_pressed:
            (menu_x, menu_y) = (mouse.cx - x_offset, mouse.cy - y_offset)
            # check if click is within the menu and on a choice
            if 0 <= menu_x < width and 0 <= menu_y < height - header_height:
                return menu_y

        if mouse.rbutton_pressed or key.vk == libtcod.KEY_ESCAPE:
            return None  # cancel if the player right-clicked or pressed Escape

        if key.vk == libtcod.KEY_ENTER and key.lalt:
            # Alt+Enter: toggle fullscreen
            libtcod.console_set_fullscreen(not libtcod.console_is_fullscreen())

        # convert the ASCII code to an index; if it corresponds to an option, return it
        index = key.c - ord('a')
        if 0 <= index < len(options):
            return index
        # if they pressed a letter that is not an option, return None
        if 0 <= index <= 26:
            return
Exemplo n.º 52
0
                screen.blit(text, textpos)
                textbox.draw(screen)
                textbox1.draw(screen)
                pygame.display.update()
                pygame.time.delay(2000)
                stop2=False
                while not stop2:
                    screen.fill(color1)
                    events2 = pygame.event.get()
                    textbox2.draw(screen)
                    textbox2.update(events2)
                    pygame.display.update()
                    if(textbox2.value.lower()=='w'):
                        stop2=True
                        pygame.quit()
                        Surface.mainfunction()
                    elif(textbox2.value.lower()=='r'):
                        stop2=True
                        pygame.quit()
                        Render.mainfunction()

    screen.fill(color1)
    textbox.update(events)
    textbox.draw(screen)
    screen.blit(text1, textpos1)
    screen.blit(text2, textpos2)
    pygame.display.update()

pygame.quit()
quit()
Exemplo n.º 53
0
def target_mode(source, target=None, ranged_componenet=None):

    """ Reset Params """
    targets = []
    target_x = 0
    target_y = 0
    if source is None:
        source = GameState.get_player()



    """ If no target supplied, Enter Targeting mode """
    if target is None:
        tile_effected = set([])
        # Utils.message('Choose Target. Left Click/Space to execute. Right Click/ESC to cancel.', libtcod.gold)

        ''' Get list of visible enemies to cycle through '''
        target_list = GameState.current_level.closest_monsters(ranged_componenet.max_range)
        if target_list:
            target_list = cycle(target_list)
            target = next(target_list)[0]

        ''' Used to detect mouse movement '''
        mouse = Input.mouse
        mouse_last_x, mouse_last_y = mouse.cx, mouse.cy
        mouse_moved = False

        while True:
            ''' Clear Screen '''
            Render.clear_layer(layers['overlay_console'])

            """
            Render.draw_rect(layers['overlay_console'], 0, 0,
                             Constants.MAP_CONSOLE_WIDTH,
                             Constants.MAP_CONSOLE_HEIGHT,
                             frame=True,
                             f_color=terminal.color_from_argb(255, 255, 100, 100),
                             bk_color=terminal.color_from_name('transparent'),
                             title="Targeting Mode - Right Click/ESC to Cancel")
            # """

            ''' Get Inputs '''
            Input.update()
            key = Input.key

            ''' determine if mouse moved, otherwise use auto-target '''
            if mouse.cx != mouse_last_x or mouse.cy != mouse_last_y:
                mouse_moved = True
                moues_last_x, mouse_last_y = mouse.cx, mouse.cy
            if mouse_moved:
                target_x, target_y = Utils.to_map_coordinates(mouse.cx, mouse.cy)
            elif target:
                target_x, target_y = target.x, target.y
            else:
                target_x, target_y = source.x, source.y

            ''' determine line of fire (You may not be able to hit every enemy you see) '''
            line = Utils.get_line((source.x, source.y),
                                  (target_x, target_y),
                                  walkable=True,
                                  ignore_mobs=True,
                                  max_length=ranged_componenet.max_range)
            for point in line:
                if point == (None, None):
                    break
                point = Utils.to_camera_coordinates(point[0], point[1])
                #libtcod.console_set_char_background(0, point[0], point[1], libtcod.lighter_blue, libtcod.BKGND_SET)
                Render.draw_char(layers['overlay_console'], point[0], point[1], 0x2588, terminal.color_from_argb(128, 64, 64, 255))

            if len(line) > 0:
                index = Utils.find_element_in_list((None, None), line)

                if index is None:
                    point = line[-1]
                else:
                    point = line[index - 1]

                circle = Utils.get_circle_points(point[0], point[1], ranged_componenet.aoe)
                if circle:
                    tile_effected = set(circle)

                    for points in circle:
                        points = Utils.to_camera_coordinates(points[0], points[1])
                        Render.draw_char(layers['overlay_console'], points[0], points[1], 0x2588, terminal.color_from_argb(128, 200, 32, 32))
                        Render.draw_char(layers['overlay_console'], points[0], points[1], 0xE000, terminal.color_from_argb(128, 255, 0, 0))

            if mouse.lbutton_pressed or key == terminal.TK_SPACE:
                # target_tile = (target_x, target_y)
                # print tile_effected
                for target in tile_effected:
                    # target = Map.to_map_coordinates(target[0], target[1])
                    monster = GameState.current_level.get_monster_at((target[0], target[1]))
                    if monster is not None:
                        print "Monster: " + str(monster) + " at " + str(target)
                        targets.append(monster)
                break

            if mouse.rbutton_pressed or key == terminal.TK_ESCAPE:
                break

            if key == terminal.TK_F:
                if target_list:
                    target = next(target_list)[0]

            GameState.render_ui()

        if not targets:  # no enemy found within maximum range
            Utils.message('Cancelled.', Color('red'))
            Render.clear_layer(layers['overlay_console'])
            return 'cancelled'
        else:
            targets = GameState.current_level.get_monsters_in_range_at(target, ranged_componenet.aoe)
    Render.clear_layer(layers['overlay_console'])

    # TODO: Allow targeting Empty tiles

    # zap it!
    if ranged_componenet.animation:
        ranged_componenet.animation_params['origin'] = (source.x, source.y)
        ranged_componenet.animation_params['target'] = (target_x, target_y)
        ranged_componenet.animation_params['target_angle'] = Utils.get_angle(source.x, source.y, target_x, target_y)

        GameState.add_animation(ranged_componenet.animation, ranged_componenet.animation_params)

    for target in targets:
        if target.fighter:
            # TODO: Combat should handle all messages......

            Utils.message('[color={1}]{2} [color={0}]takes [color={3}]{4} damage[color={0}].'
                          ''.format(Constants.COMBAT_MESSAGE_DEFAULT_COLOR,
                                    Constants.COMBAT_MESSAGE_MONSTER_NAME_COLOR,
                                    target.name,
                                    Constants.COMBAT_MESSAGE_DAMAGE_COLOR,
                                    ranged_componenet.owner.equipment.power_bonus))
            target.fighter.take_damage(ranged_componenet.owner.equipment.power_bonus)
    Render.clear_layer(5)
    return 'fired'
Exemplo n.º 54
0
def render_common():
    import Input

    pos = Pos(Constants.MAP_CONSOLE_WIDTH, 0)

    # ERRORS
    Render.set_foreground(layers['side_panel_console'], Color("0,70,140"))

    """ LEVEL NUMBER """
    Render.print_rect(layers['side_panel_console'], pos.x + 1, pos.y + 1, 17, 1, "Level 1".center(17, ' '))

    """ MOUSE X / Y """
    Render.print_rect(layers['side_panel_console'], pos.x + 9, pos.y + 18, 17, 2,
                               "X: " + str(Input.mouse.cx) + "  \nY: " + str(Input.mouse.cy) + "  ")

    """ STATS """
    color = Color("175,175,255")
    #print color
    Render.set_foreground(layers['panel_console'], color)
    #terminal.color('green')


    player = GameState.player

    Render.print_line(layers['side_panel_console'], Constants.MAP_CONSOLE_WIDTH + 5, 18, str(player.fighter.base_str).rjust(3))
    Render.print_line(layers['side_panel_console'], Constants.MAP_CONSOLE_WIDTH + 5, 19, str(player.fighter.base_def).rjust(3))
    Render.print_line(layers['side_panel_console'], Constants.MAP_CONSOLE_WIDTH + 5, 20, str(player.fighter.base_agl).rjust(3))
    Render.print_line(layers['side_panel_console'], Constants.MAP_CONSOLE_WIDTH + 5, 21, str(player.fighter.base_stm).rjust(3))
    Render.print_line(layers['side_panel_console'], Constants.MAP_CONSOLE_WIDTH + 5, 22, str(player.fighter.base_skl).rjust(3))
    Render.print_line(layers['side_panel_console'], Constants.MAP_CONSOLE_WIDTH + 5, 23, str(player.fighter.base_int).rjust(3))

    """ Items """
    ranged_items = [equip for equip in GameState.inventory if equip.ranged]
    equipped_ranged = [equip.name for equip in ranged_items if equip.equipment.is_equipped]
    if equipped_ranged:
        Render.print_line(layers['side_panel_console'], Constants.MAP_CONSOLE_WIDTH + 9, 20, equipped_ranged[0])


    """ CONTROLS """
    Render.print_line(layers['side_panel_console'], 59, 39, "Move/Attack:      NUMPAD/ARROWS")
    Render.print_line(layers['side_panel_console'], 59, 40, "Fire:                         F")
    Render.print_line(layers['side_panel_console'], 59, 41, "Pickup:                       G")
    Render.print_line(layers['side_panel_console'], 59, 42, "Pop-Up Test:                  B")
    Render.print_line(layers['side_panel_console'], 59, 43, "Decend:                       <")
    Render.print_line(layers['side_panel_console'], 59, 44, "Change Weapon:              [[/]]")
    Render.print_line(layers['side_panel_console'], 59, 45, "DEBUG:                        X")


    """ DUNGEON NAME """
    pos = Pos(0, Constants.MAP_CONSOLE_HEIGHT)

    Render.print_rect(layers['panel_console'], pos.x + 1, pos.y + 1, Constants.SCREEN_WIDTH - 19, 1,
               GameState.dungeon_name.center(57, ' '))