コード例 #1
0
    def update(self, dt, entities):
        delta_time = float(dt) / 1000
        # if the player pressed z move faster
        if inp.Input().keyFired(pygame.K_z):
            self.x_speed = 275
        else:
            self.x_speed = 230

        # input on the x-axis
        self.vel.x = inp.Input().horizontal() * self.x_speed * delta_time

        # flips mario depending on the direction mario is moving

        if self.currentDirection != self.direction:
            if self.currentDirection == "L":
                self.image = self.images.idle[0]
            elif self.currentDirection == "R":
                self.image = self.images.idleR[0]
            self.direction = self.currentDirection

        # make ground check to check if player hasn't fallen off platform
        # input on the y-axis
        if self.jumpPressed != inp.Input().vertical():
            self.jumpPressed = not self.jumpPressed
            if self.onGround and self.jumpPressed:
                if self.direction == "L":
                    self.image = self.images.jumpL[0]
                elif self.direction == "R":
                    self.image = self.images.jumpR[0]
                self.vel.y += (-inp.Input().vertical() *
                               self.y_speed) * delta_time
                self.onGround = False
        else:
            self.vel.y += self.gravity * delta_time

        # code for animations
        self.current_time += delta_time
        if self.current_time >= self.animation_time:
            if self.vel.x < 0  and self.currentDirection == "L" \
             and self.onGround:
                self.current_time = 0
                self.index = (self.index + 1) % len(self.images.runL)
                self.image = self.images.runL[int(self.index)]
            elif self.vel.x > 0 and self.currentDirection == "R"\
             and self.onGround:
                self.current_time = 0
                self.index = (self.index + 1) % len(self.images.runR)
                self.image = self.images.runR[int(self.index)]
            else:
                if self.onGround:
                    if self.currentDirection == "L":
                        self.image = self.images.idle[0]
                    elif self.currentDirection == "R":
                        self.image = self.images.idleR[0]

        # seperating the movement into x and y movement
        if self.vel.x != 0:
            self.move_single_axis(int(self.vel.x), 0, entities, delta_time)
        if self.vel.y != 0:
            self.move_single_axis(0, int(self.vel.y), entities, delta_time)
    def get_next_input(self, history):
        # refine the range to values that have a distance of at most kappa_i to the standard trace we picked
        close_values = self.input_distance.get_input_symbols_close_to_trace(
            self.standard_trace, history)

        if close_values.is_empty():
            # if there are no close values, get the set of all inputs
            input_domain = self.input_distance.get_values_domain()

            # return any of them
            return Input(input_domain.get_random_value())
        else:
            # pick any of the close values
            return Input(close_values.get_random_value())
コード例 #3
0
def get_output(probability):
    feature_name = probability_selector(probability)
    input_init = inputs.Input(probability, feature_name=feature_name)
    duration = input_init.get_duration()
    input_init.delete_duration()
    input_init.normalize()
    tra_feature, tra_label, vaildation_feature, vaildation_label, test_feature, test_label = input_init.data_generator(
    )
    vaild_list = input_init.vaild_list
    vaild_dur = []
    for vaild_num in vaild_list:
        vaild_dur.append(duration[vaild_num])

    optimal_net = ep.evolve(30,
                            1,
                            tra_feature,
                            tra_label,
                            vaildation_feature,
                            vaildation_label,
                            test_feature,
                            test_label,
                            type='random')
    w, b, e, r, predict, test = ep.Evolution().network_optimizer(tra_feature,
                                                                 tra_label,
                                                                 test_feature,
                                                                 test_label,
                                                                 optimal_net,
                                                                 18600,
                                                                 final=True)
    print(vaild_dur)
    return e, predict, test, vaild_dur
コード例 #4
0
 def __init__(self, size, generation_size):
     prevs = inp.Input()
     self.size = size
     self.generation_size = generation_size
     # for x in range(0,generation_size):
     #     self.generation_list.append(self.initialize_parameters(size))
     self.generation_list = prevs.prev
コード例 #5
0
ファイル: Game.py プロジェクト: Leitast/CN-course-practice
 def __init__(self):
     self.input = Input()
     self.input.game = self
     self.output = Output()
     self.player = Player()
     self.server = Server()
     self.server.game = self
     self.locations = dict()
     self.event = multiprocessing.queues.SimpleQueue()
コード例 #6
0
    def main(self):
        self.my_connection_thread = threading.Thread(
            target=self.connect_thread)
        self.my_connection_thread.start()

        self.my_receive_thread = threading.Thread(target=self.receive_thread)
        self.my_receive_thread.start()

        self.input_manager = Input.Input(self.my_socket)

        self.my_window.input_manager = self.input_manager

        self.my_window.window_draw()

        sys.exit(self.app.exec_())
コード例 #7
0
 def __init__(self):
     pygame.display.init()
     pygame.font.init()
     self.windowSize = (800, 600)
     self.windowMode = pygame.locals.DOUBLEBUF  # much better than default (0)
     self.displaySurface = pygame.display.set_mode(self.windowSize,
                                                   self.windowMode)
     self.running = True
     self.input = Input()
     self.group = Group()
     self.clearColor = (255, 255, 255)
     self.deltaTime = 0
     # display FPS
     self.fpsDisplay = False
     self.fps = 60
     self.fpsClock = pygame.time.Clock()
コード例 #8
0
ファイル: Main.py プロジェクト: Azuki-Azusa/A-Star
def h1h2():
    for i in range(10):
        table = Input.Input(1)
        print("h1(n):", end=' ')
        test = AStar.AStar(table, 1)
        time_start = time.time()
        test.run()
        time_end = time.time()
        print('Cost:', time_end - time_start, 's')

        print("h2(n):", end=' ')
        test = AStar.AStar(table, 2)
        time_start = time.time()
        test.run()
        time_end = time.time()
        print('Cost:', time_end - time_start, 's')
コード例 #9
0
def test_case(no, output_options, do_not_run_if_no_assertion=False):
    print("Start of Running Test case No " + str(no))
    p_list = []
    input_parameters = Input(no)
    assertions = AssertInput()
    try:
        input_parameters.read(p_list, assertions)
    except IOError:
        print("Test case not Found")
        return
    time_quantum = input_parameters.time_quantum
    if not len(
            assertions.assertion_set) == 0 or not do_not_run_if_no_assertion:
        process(p_list, time_quantum, assertions, output_options)
    else:
        print("No Assertion. Hence Not running the test case")
    print("End of Running Test case No " + str(no))
    print_line()
コード例 #10
0
ファイル: U_Net.py プロジェクト: switch23/U-Net
 def __init__(self, input_channel, num_class):
     super(U_Net, self).__init__()
     self.base_channel = 64
     self.input = Input.Input(input_channel, self.base_channel)
     self.encode1 = Encode.Encode(self.base_channel, 2 * self.base_channel)
     self.encode2 = Encode.Encode(2 * self.base_channel,
                                  4 * self.base_channel)
     self.encode3 = Encode.Encode(4 * self.base_channel,
                                  8 * self.base_channel)
     self.encode4 = Encode.Encode(8 * self.base_channel,
                                  8 * self.base_channel,
                                  16 * self.base_channel)
     self.decode1 = Decode.Decode(16 * self.base_channel,
                                  4 * self.base_channel)
     self.decode2 = Decode.Decode(8 * self.base_channel,
                                  2 * self.base_channel)
     self.decode3 = Decode.Decode(4 * self.base_channel, self.base_channel)
     self.decode4 = Decode.Decode(2 * self.base_channel, self.base_channel)
     self.output = Output.Output(self.base_channel, num_class)
コード例 #11
0
	def __init__(self, screen_size, fps):
		self._tmx_root = None  # Will be used to store the currently loaded tmx-file:
		self._fps = fps # Save fps
		self._CLOCK = pygame.time.Clock() # Create pygame.Clock for fps-control
		self._draw_tile_ids = False # DEBUG: Draw all ids:

		# Create instance of Graphics-Engine:
		self.graphics = Graphics(self,screen_size)
		# Create instance of World:
		self.world = World(self)
		# Create instance of input-engine
		self.input = Input(self)
		# Create actors-controller
		self.actors = GameActorController(self)
		# Create sound-controller (not jet programmed...)
		self.sound = Sound(self)

		# Finally, first map (temporary):
		self._load_tmx("Forest_N1_1.tmx")

		# Var changed by self.load_new_level. If not false, in the next update cycle, the level gets loaded.
		self._load_new_level = False
コード例 #12
0
def train(train_data, vocabulary, num_layers, num_epochs, batch_size, model_save_name, learning_rate=1.0, max_lr_epoch=10, lr_decay=0.93):
    # setup data and models
    training_input = ipt.Input(batch_size=batch_size,
                               num_steps=35, data=train_data)
    m = mdl.Model(training_input, is_training=True, hidden_size=650, vocab_size=vocabulary,
                  num_layers=num_layers)
    init_op = tf.global_variables_initializer()

    orig_decay = lr_decay
    with tf.Session() as sess:
        # start threads
        sess.run([init_op])
        coord = tf.train.Coordinator()
        threads = tf.train.start_queue_runners(coord=coord)
        saver = tf.train.Saver()

        for epoch in range(num_epochs):
            new_lr_decay = orig_decay ** max(epoch + 1 - max_lr_epoch, 0.0)
            m.assign_lr(sess, learning_rate * new_lr_decay)
            current_state = np.zeros(
                (num_layers, 2, batch_size, m.hidden_size))
            for step in range(training_input.epoch_size):
                if step % 50 != 0:
                    cost, _, current_state = sess.run([m.cost, m.train_op, m.state], feed_dict={
                                                      m.init_state: current_state})
                else:
                    cost, _, current_state, acc = sess.run(
                        [m.cost, m.train_op, m.state, m.accuracy], feed_dict={m.init_state: current_state})
                    print("Epoch {}, Step {}, cost: {:.3f}, accuracy: {:.3f}".format(
                        epoch, step, cost, acc))
            # save a model checkpoint
            saver.save(sess, OUTPUT_PATH + '\\' +
                       model_save_name, global_step=epoch)
        # do a final save
        saver.save(sess, OUTPUT_PATH + '\\' + model_save_name + '-final')
        # close threads
        coord.request_stop()
        coord.join(threads)
コード例 #13
0
ファイル: main.py プロジェクト: sylvainDNS/EpicMusicCreator
def test(model_path, test_data, reversed_dictionary, vocabulary):
    test_input = ipt.Input(batch_size=20, num_steps=35, data=test_data)
    m = mdl.Model(test_input, is_training=False, hidden_size=650, vocab_size=vocabulary,
                  num_layers=2)
    saver = tf.train.Saver()
    with tf.Session() as sess:
        # start threads
        coord = tf.train.Coordinator()
        threads = tf.train.start_queue_runners(coord=coord)
        current_state = np.zeros((2, 2, m.batch_size, m.hidden_size))
        # restore the trained model
        saver.restore(sess, model_path)
        # get an average accuracy over num_acc_batches
        num_acc_batches = 30
        check_batch_idx = 25
        acc_check_thresh = 5
        accuracy = 0
        for batch in range(num_acc_batches):
            if batch == check_batch_idx:
                true_vals, pred, current_state, acc = sess.run(
                    [m.input_obj.targets, m.predict, m.state, m.accuracy], feed_dict={m.init_state: current_state})
                pred_string = [reversed_dictionary[x]
                               for x in pred[:m.num_steps]]
                true_vals_string = [reversed_dictionary[x]
                                    for x in true_vals[0]]
                print("True values (1st line) vs predicted values (2nd line):")
                print(" ".join(true_vals_string))
                print(" ".join(pred_string))
            else:
                acc, current_state = sess.run([m.accuracy, m.state], feed_dict={
                                              m.init_state: current_state})
            if batch >= acc_check_thresh:
                accuracy += acc
        print("Average accuracy: {:.3f}".format(
            accuracy / (num_acc_batches-acc_check_thresh)))
        # close threads
        coord.request_stop()
        coord.join(threads)
コード例 #14
0
ファイル: PyChip8.py プロジェクト: pietromesadri/PyChip8
def main():
    renderer = Render.Renderer(64,32, 10)
    input = Input.Input()
    chip8 = Chip8.chip8(chip8_fontset)
    chip8.load_game("pong.rom")
    running = 1
    clock = pygame.time.Clock()

    renderer.clear_screen()
    
    while running:
        #clock.tick()
        chip8.emulate_cycle(renderer.sound)
        #if chip8.opcode != 0:
        #    print(chip8.opcode)
        if (chip8.draw_flag):
            renderer.draw_graphics(chip8.gfx, (255,255,255))

        running = input.event_handler()
        if input.key_down:
            chip8.key[input.key_pressed] = 1
        else:
            chip8.key[input.key_pressed] = 0
コード例 #15
0
ファイル: Stmt.py プロジェクト: motomaniak/InterpreterProgram
 def parse(self):
     x = int(self.t.peek())
     if x == 5:
         self.st = If.If(self.t, self.inData)
         self.st.parse()
     elif x == 8:
         self.case = 1
         self.st = Loop.Loop(self.t, self.inData)
         self.st.parse()
     elif x == 10:
         self.case = 2
         self.st = Input.Input(self.t, self.inData)
         self.st.parse()
     elif x == 11:
         self.case = 3
         self.st = Output.Output(self.t)
         self.st.parse()
     elif x == 32:
         self.case = 4
         self.st = Assign.Assign(self.t)
         self.st.parse()
     else:
         print "Something went wrong!."
         exit()
コード例 #16
0
# To change this license header, choose License Headers in Project Properties.
# To change this template file, choose Tools | Templates
# and open the template in the editor.

if __name__from keras.layers import Input, Dense
from keras.models import Model

# this is the size of our encoded representations
encoding_dim = 32  # 32 floats -> compression of factor 24.5, assuming the input is 784 floats

# this is our input placeholder
input_img = Input(shape=(784,))
# "encoded" is the encoded representation of the input
encoded = Dense(encoding_dim, activation='relu')(input_img)
# "decoded" is the lossy reconstruction of the input
decoded = Dense(784, activation='sigmoid')(encoded)

# this model maps an input to its reconstruction
autoencoder = Model(input_img, decoded)
コード例 #17
0
ファイル: ACE_main.py プロジェクト: WANGWEI011/NuclearData
import os
import Head
import Input as i
import Production as pro
import Output as o

info = Head.Info()
#调用Input()函数,和用户交互,获取输入信息
i.Input(info)

num = info.num_t
for j in range(0, num):
    #如果有多个温度,先确定温度点和对应的ACE文件后缀名
    temp = str(info.temperature[j])
    acename = str(info.ACEname[j])

    # message_total文件负责记录一次加工的所有信息,先清空
    message_total_file = info.note_path + 'meassage_total_' + temp + 'K'
    message_total = open(message_total_file, 'w')
    # 清空xsdir之前的信息
    xsdir_file = info.output_path + 'xsdir_' + temp + 'K'
    xsdir = open(xsdir_file, 'w')

    # 将输入文件中的所有核素名建一个列表
    inputfiles = os.listdir(info.input_path)

    # 开始循环
    for file in inputfiles:
        #加工对应核素的对应温度的ACE文件
        pro.produce(info, file, acename, temp, message_total)
        nuclide = pro.nuclide
コード例 #18
0
ファイル: Main.py プロジェクト: Candlemancer/Senior-Year
# Jonathan Petersen
# A01236750
# Shapes Assignment
# Driver Code

import AreaFinder
import Input
import Output

import os
import sys

if __name__ == "__main__":
    ingest = Input.Input()
    output = Output.Output()
    finder = AreaFinder.AreaFinder()
    inputType = ""
    outputType = ""

    print("Welcome to ShapeCalculator3000")

    print("What type of data would you like to input?")
    print("[1] JSON Data")
    print("[2] XML Data")
    print("[3] Quit")
    while (inputType not in ("1", "2", "3")):
        inputType = input("Choice [1, 2, 3]: ")
    if inputType == "1":
        ingest.setStrategy(Input.jsonStrategy)
    elif inputType == "2":
        ingest.setStrategy(Input.xmlStrategy)
コード例 #19
0
 def __init__(self):
     self.input = Input.Input(self)
     self.output = Output.Output(self)
コード例 #20
0
ファイル: __main__.py プロジェクト: aLoi3/comp260-server
if __name__ == '__main__':

    is_running = True
    is_connected = False

    my_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

    if Local_host:
        my_socket.bind(("127.0.0.1", 8222))
    else:
        my_socket.bind(("46.101.56.200", 9284))

    my_socket.listen(5)

    input_manager = Input.Input()
    input_manager.encryption_key = encryption_key

    my_database = Database.Database()

    my_accept_thread = threading.Thread(target=accept_clients,
                                        args=(my_socket, ))
    my_accept_thread.start()

    while is_running is True:
        client_and_message = ''

        clients_lock.acquire()

        while message_queue.qsize() > 0:
            try:
コード例 #21
0
def mainLoop(screen):
    frames = 0
    frameTime = 1000 / 60
    endLoop = 0
    background = 150, 150, 150
    black = 0, 0, 0
    inputs = Input.Input()
    #shipMap = Map.Map()
    #scene = Scene.Scene(size, "scenes/scene1.txt")
    #dialog = Dialog.Dialog(size, "Dialogs/dialog1.txt")
    gameStart = True
    trigger = None
    changeScreen = False
    isTriggered = [0,0,0,0,0,0,0,0] # global vars
    
    while not endLoop:
        startFrame = pygame.time.get_ticks()

        # inputs
        inputs.updateEvents()
        if inputs.quit == True:
            endLoop = 1
        if inputs.mouseRelX or inputs.mouseRelY:
            if currentType == 2 or currentType == 0:
                current.isHovered(inputs.getMousePos())
            pass
        if inputs.mouseButtons[0]:
            if currentType == 0:
                current.onClick(inputs.mouseX)
            if currentType == 1:
                trigger = current.isBoxClicked(inputs.getMousePos())
            if currentType == 2:
                trigger = current.getClickedRoom()
            if currentType == 3:
                trigger = 0
                
        if inputs.trig:
            trigger = inputs.trigger

        if gameStart:
            print('intro')
            current = Dialog.Dialog2(size, "Dialogs/dialog_intro.txt")
            currentType = 3
            currentIndex = 2
            gameStart = False

        if trigger is not None:
            changeState = None
            current, currentType, currentIndex, changeScreen, changeState = triggerManager(trigger, current, currentType, currentIndex, isTriggered)
            if changeState is not None:
                isTriggered[changeState] = 1
            trigger = None
            
        if changeScreen:
            screen.fill(black)
            pygame.display.flip()
            pygame.time.delay(500)
            changeScreen = False
        
        screen.fill(background)
        current.draw(screen)
        #shipMap.draw(screen)
        #dialog.draw(screen)
        pygame.display.flip()

        # manage framerate
        endFrame = pygame.time.get_ticks()
        loopTime = endFrame - startFrame
        if loopTime < frameTime:
            pygame.time.delay(frameTime - loopTime)
        frames += 1

    totalTime = pygame.time.get_ticks()
    avgFramerate = frames / (float(totalTime) / 1000)
    print("Frames : " + str(frames))
    print("Time Running : " + str(totalTime / 1000) + "s")
    print(avgFramerate)
コード例 #22
0
ファイル: Test.py プロジェクト: Andrew-Fryer/OEC_2020
# Test reading in data

import Output as output
import Input as input
import pandas as pd

data = pd.read_csv("./given-files/OEC_sample_input.csv", header=None)
starting_condition = output.Output(data.values[0])

data = pd.read_csv("./given-files/OEC_sample_ouput.csv", header=None)
input = input.Input(data.values[0])

print("end")
コード例 #23
0
ファイル: Main.py プロジェクト: Azuki-Azusa/A-Star
def h1():
    table = Input.Input(0)
    test = AStar.AStar(table, 1)
    test.run()
コード例 #24
0
import numpy
import sys
import Input

#get command line argument, the file name
file = sys.argv[1]

#read this file and store the information in an input object
input = Input.Input()
input.readFile(file)

circuit = input.getCircuit()
states = input.getStates()

stateList = circuit.run(states)

for i in range(0, len(stateList)):
    inputStates = stateList[i]
    for j in range(0, len(inputStates)):
        print(inputStates[j])
コード例 #25
0
 def __init__(self):
     
     # constants
     self.WIN_TITLE = "Pythonica"
     #self.WIN_WIDTH = 1024
     #self.WIN_HEIGHT = 576
     self.WIN_WIDTH = 1280
     self.WIN_HEIGHT = 720
     self.WIN_ICON_FILENAME = "Icon.png"
     self.FILL_COLOR = (0, 0, 0)
     
     # core variables
     self.isRunning = True
     self.uiComponents = []
     self.hoveredUI = None
     self.input = Input()
     self.updateDelay = 0.1 #1
     self.delayedUpdateAccumulator = 0
     self.lastEventTime = time.time()
     self.lastDrawTime = time.time()
     self.pyClock = pygame.time.Clock()
     
     # if activeGame is None, then use is in menu
     # if activeGame points to a Game, then in game
     self.activeGame = None
     
     # get rid of this line?
     self.activeGame = Game(self.WIN_WIDTH, self.WIN_HEIGHT)
     
     # pygame initialization
     pygame.init()
     self.pySurface = pygame.display.set_mode((self.WIN_WIDTH, self.WIN_HEIGHT))
     pygame.display.set_caption(self.WIN_TITLE)
     pygame.display.set_icon(load_img(self.WIN_ICON_FILENAME))
     
     # make the ui
     u = UITextComponent()
     u.set_size(self.WIN_WIDTH, self.WIN_HEIGHT / 6)
     u.set_pos(self.WIN_WIDTH * 0.5, self.WIN_HEIGHT - u.get_size_y() / 2)
     u.set_visible(True)
     u.name = "UI 1"
     u.text = "test text here test text here test text here "
     u.borderSize = 1
     self.uiComponents.append(u)
     
     u2 = UIComponent(400, 400, 100, 100)
     u2.set_visible(False)
     u2.name = "UI 2"
     self.uiComponents.append(u2)
     
     b = UIComponent(400, 100, 300, 100)
     b.set_visible(False)
     b.name = "Banner"
     b.img = load_img("TestBanner.png")
     self.uiComponents.append(b)
     
     # any sort of testing should be done here
     
     
     
     # begin the main program
     
     self.drawThread = threading.Thread(target=self.draw_loop)
     #self.drawThread.setDaemon(True)
     # threads should be killed manually
     #self.drawThread.start()
     self.event_loop()
コード例 #26
0
ファイル: Main.py プロジェクト: Azuki-Azusa/A-Star
def h2():
    table = Input.Input(0)
    test = AStar.AStar(table, 2)
    test.run()
コード例 #27
0
ファイル: Game.py プロジェクト: spywhere/Pew-Pew
    def startGame(self):
        if self._debugMode:
            print("Initializing game...")
        self._running = True
        self._mainWindow = tk.Tk()
        self._mainWindow.protocol("WM_DELETE_WINDOW", self.stopGame)
        self._mainWindow.title(self._title)
        self._mainWindow.resizable(0, 0)
        self._renderer = Renderer(self)
        self._gameInput = Input(self)
        try:
            self._mainCanvas = tk.Canvas(self._mainWindow,
                                         width=self._size[0],
                                         height=self._size[1],
                                         borderwidth=0)
            self._mainCanvas.pack()
            self._mainCanvas.update()
        except:
            self._mainWindow = None
            if self._debugMode:
                print("!!! Unexpected error occurred on startGame.")
            raise
        if self._debugMode:
            print("Game running...")
        lastTimer = self.getTimeMicros()
        lastTime = lastTimer
        renderDelta = 0
        updateDelta = 0
        frames = 0
        updates = 0
        microPerRender = 1000000 / self._targetFPS
        microPerUpdate = 1000000 / self._targetUPS
        while self._running:
            timeNow = self.getTimeMicros()
            timeDelta = (timeNow - lastTime)
            renderDelta += timeDelta
            updateDelta += timeDelta
            lastTime = timeNow

            if updateDelta > microPerUpdate:
                updateDelta -= microPerUpdate
                updates += 1
                if self._currentScene is not None:
                    self._gameScenes[self._currentScene].onUpdate(
                        self._gameInput, timeDelta / 1000000.0)
                self._gameInput._update()

            if not self._vSync or renderDelta > microPerRender:
                renderDelta -= microPerRender
                frames += 1
                if self._currentScene is not None:
                    self._renderer.clearAll(self._gameBG)
                    self._gameScenes[self._currentScene].onRender(
                        self._renderer, renderDelta)
                    if self._showFPS:
                        self._renderer.setColor(Color(255, 255, 255))
                        self._renderer.drawString((10, 5), self._infoText,
                                                  tk.NW, tk.LEFT)

            self.sleep(self._idleTime)

            if self.getTimeMicros() - lastTimer >= 1000000:
                self._PSInfo = [frames, updates, timeDelta / 1000.0]
                self._infoText = "%d FPS, %d UPS [%0.2fms]" % (
                    frames, updates, timeDelta / 1000.0)
                if self._debugMode:
                    print(self._infoText)
                frames = 0
                updates = 0
                lastTimer = self.getTimeMicros()
        if self._currentScene is not None:
            self._gameScenes[self._currentScene].onExit()
        tk.sys.exit(0)
コード例 #28
0
ファイル: Transaction.py プロジェクト: TimTosi/spelunker
	def setInputList(self, datFile):
		"""Sets input list."""
		for i in range(0, self.inputCount):
			input_ = Input.Input()
			input_.setInput(datFile)
			self.inputList.append(input_)
コード例 #29
0
ファイル: main.py プロジェクト: knowncold/8080
import Cpu
import Input
import pygame
import sys

cpu = Cpu.Cpu()

ROMPath = 'invaders.rom'  # it should be smaller than 8192bytes
cpu.loadROM(ROMPath)
cpu.InitMap()
cpu.reset()

io = Input.Input()

pygame.init()
width, height = 256, 224
size = height, width
black = 0, 0, 0

surface = pygame.display.set_mode(size)
pygame.display.set_caption('Invaders')
surface.fill(black)
pxArray = pygame.PixelArray(surface)


def refresh(processor, px_array):
    for i in range(height):
        index = 0x2400 + (i << 5)
        for j in range(32):
            v_ram = processor.get_memory()[index]
            index += 1