def __init__(self): sf2d.init() sftd.init() soc.init() sf2d.set_clear_color(sf2d.rgba8(0, 0, 0, 255)) # clear screens sf2d.start_frame(gfx.SCREEN_TOP) sf2d.end_frame() sf2d.start_frame(gfx.SCREEN_BOTTOM) sf2d.end_frame() self.bg_tile = self.load_texture('bg_tile') self.pc_icon = self.load_texture('computer') self.arrow = self.load_texture('arrow') self.python = self.load_texture('script') self._3ds = self.load_texture('3ds') self.progress = self.load_texture('progress') self.progress_bg = self.load_texture('progress_bg') self.success = self.load_texture('success') self.font = sftd.Font('romfs:/netload_assets/DroidSans-Bold.ttf', 20, color=sf2d.rgba8(0, 0, 0, 255)) self.state = STATE_WAITING for i in range(1, 9): self.spinner.append(self.load_texture('spinner%d' % i)) self.setup_socket()
def state_receiving(self): progress = float(self.downloaded) / float(self.filesize) self.font.draw_text(125, TOP_HEIGHT - 60, 'Receiving...') self.progress_bg.draw(CENTER_X, CENTER_Y, center=(128, 16)) self.progress.draw_quad_uv(72, 104, 72 + (256 * progress), 136, 0, 0, progress, 1, 0) old_color = self.font.color self.font.color = sf2d.rgba8(255, 255, 255, 255) self.font.draw_text(CENTER_X - 20, CENTER_Y - 13, str(int(progress * 100)) + '%') self.font.color = old_color try: chunk = self.client.recv(self.filesize) self.output.write(chunk) self.downloaded += len(chunk) if self.downloaded == self.filesize: self.output.close() self.client.close() self.client = None self.state = STATE_DONE globals()['monty_filename'] = self.filename globals()['monty_filetype'] = self.filetype except BaseException: pass
def __init__(self): sf2d.init() console.init(gfx.SCREEN_BOTTOM) print('App::__init__') sf2d.set_clear_color(sf2d.rgba8(0xDD, 0xDD, 0xDD, 255)) self.shit = self.load_texture('shit') self.yay = self.load_texture('yay3ds') self.yay_angle = 0
from citrus import * import sf2d import math sf2d.init() sf2d.set_clear_color(sf2d.rgba8(0x40, 0x40, 0x40, 0xFF)) console.init(gfx.SCREEN_BOTTOM) rads = 0.0 while apt.main_loop(): hid.scan_input() if hid.keys_down() & hid.KEY_START: break sf2d.start_frame(gfx.SCREEN_TOP, gfx.SIDE_LEFT) sf2d.draw_fill_circle(60, 100, 35, sf2d.rgba8(0, 255, 0, 255)) sf2d.draw_fill_circle(180, 120, 55, sf2d.rgba8(255, 255, 0, 255)) sf2d.draw_rectangle_rotate(260, 20, 40, 40, sf2d.rgba8(255, 255, 0, 255), 2.0 * rads) sf2d.draw_rectangle(20, 60, 40, 40, sf2d.rgba8(255, 0, 0, 255)) sf2d.draw_rectangle(5, 5, 30, 30, sf2d.rgba8(0, 255, 255, 255)) sf2d.end_frame() rads += 0.01
from citrus import * import sf2d import img def frame(): gfx.flush_buffers() gfx.swap_buffers() gsp.wait_for_vblank() sf2d.init() sf2d.set_clear_color(sf2d.rgba8(255, 0, 0, 255)) console.init(gfx.SCREEN_BOTTOM) png = img.load_png(open('/test.png', 'rb')) tex = sf2d.Texture(png[0], png[1], sf2d.TEXFMT_RGBA8, sf2d.PLACE_RAM, png[3]) x = 0 y = 0 while apt.main_loop(): hid.scan_input() if hid.keys_down() & hid.KEY_START: break held = hid.keys_held() if held & hid.KEY_DPAD_RIGHT: x += 1
if offset_3d == 0: return sf2d.start_frame(gfx.SCREEN_TOP, gfx.SIDE_RIGHT) draw_shit() tex_yay3ds.draw(200 + int(offset_3d / 2.0), 120, center=(tex_yay3ds.width / 2, tex_yay3ds.height / 2), angle=angle) sf2d.end_frame() sf2d.set_clear_color(sf2d.rgba8(200, 200, 200, 255)) sf2d.set_3d(True) angle = 0.0 while apt.main_loop(): hid.scan_input() down = hid.keys_down() if down & hid.KEY_START: break if down & hid.KEY_Y: print('\x1b[27;10HPlay: hello.wav') channel1.play(hello) if down & hid.KEY_X: print('\x1b[27;10HPlay: goal.wav ')
from citrus import * import sf2d import img def frame(): gfx.flush_buffers() gfx.swap_buffers() gsp.wait_for_vblank() sf2d.init() sf2d.set_clear_color(sf2d.rgba8(255, 0, 0, 255)) console.init(gfx.SCREEN_BOTTOM) png = img.load_png(open('/test.png', 'rb')) tex = sf2d.Texture(png[0], png[1], sf2d.TEXFMT_RGBA8, sf2d.PLACE_RAM, png[3]) x = 0 y = 0 while apt.main_loop(): hid.scan_input() if hid.keys_down() & hid.KEY_START: break held = hid.keys_held() if held & hid.KEY_DPAD_RIGHT: x += 1 elif held & hid.KEY_DPAD_LEFT: x -= 1
draw_shit() tex_yay3ds.draw(200 - int(offset_3d / 2.0), 120, center=(tex_yay3ds.width / 2, tex_yay3ds.height / 2), angle=angle) sf2d.end_frame() if offset_3d == 0: return sf2d.start_frame(gfx.SCREEN_TOP, gfx.SIDE_RIGHT) draw_shit() tex_yay3ds.draw(200 + int(offset_3d / 2.0), 120, center=(tex_yay3ds.width / 2, tex_yay3ds.height / 2), angle=angle) sf2d.end_frame() sf2d.set_clear_color(sf2d.rgba8(200, 200, 200, 255)) sf2d.set_3d(True) angle = 0.0 while apt.main_loop(): hid.scan_input() down = hid.keys_down() if down & hid.KEY_START: break if down & hid.KEY_Y: print('\x1b[27;10HPlay: hello.wav') channel1.play(hello ) if down & hid.KEY_X: print('\x1b[27;10HPlay: goal.wav ')
from citrus import * import sf2d import sftd sf2d.init() sftd.init() sf2d.set_clear_color(sf2d.rgba8(0, 0, 0, 255)) sf2d.swap_buffers() console.init(gfx.SCREEN_BOTTOM) font = sftd.Font('/Custard.ttf', 100, color=sf2d.rgba8(255, 255, 255, 255), line_width=100) box = font.calc_bounding_box('Hello, world!') print(box) # center the text on the top screen text_x = int((sf2d.screen['top']['width'] / 2.0) - (box[0] / 2.0)) text_y = int((sf2d.screen['top']['height'] / 2.0) - (box[1] / 2.0)) print('Text position: (%d, %d)' % (text_x, text_y)) print("""Font: size: %d color: %d line_width: %d""" % (font.size, font.color, font.line_width))
from citrus import * import sf2d import sftd sf2d.init() sftd.init() sf2d.set_clear_color(sf2d.rgba8(0, 0, 0, 255)) sf2d.swap_buffers() console.init(gfx.SCREEN_BOTTOM) font = sftd.Font('/Custard.ttf', 100, color=sf2d.rgba8(255, 255, 255, 255), line_width=100) box = font.calc_bounding_box('Hello, world!') print(box) # center the text on the top screen text_x = int((sf2d.screen['top']['width'] / 2.0) - (box[0] / 2.0)) text_y = int((sf2d.screen['top']['height'] / 2.0) - (box[1] / 2.0)) print('Text position: (%d, %d)' % (text_x, text_y)) print("""Font: size: %d color: %d line_width: %d""" % (font.size, font.color, font.line_width)) while apt.main_loop(): hid.scan_input()