Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module Graphics
- Sfml_Draw = Win32API.new('WOM32', 'sfml_draw', 'pllllll', 'i')
- Sfml_Draw_Rectangle = Win32API.new('WOM32', 'sfml_draw_rectangle', 'lllllllll', 'l')
- Sfml_Draw_Text = Win32API.new('WOM32', 'sfml_draw_text', 'plllllllllll', 'l')
- Sfml_Display = Win32API.new('WOM32', 'sfml_display', '', 'l')
- Sfml_Clear = Win32API.new('WOM32', 'sfml_clear', '', 'l')
- DRAW_TYPE_NORMAL = 0
- DRAW_TYPE_RECTANGLE = 1
- DRAW_TYPE_TEXT = 2
- module_function
- @sprites = []
- def self.load_texture(path)
- s = Win32API.new('WOM32', 'sfml_load_texture', 'p', 'p').call path
- size = [s.split(';')[0].to_i, s.split(';')[1].to_i]
- return size
- end
- def draw(filename, rec_x, rec_y, width, height, x, y)
- result = Sfml_Draw.call filename, rec_x, rec_y, width, height, x, y
- end
- def fill_rect(r, g, b, a, x, y, width, height, thickness)
- result = Sfml_Draw_Rectangle.call r, g, b, a, x, y, width, height, thickness
- end
- def draw_text(str, x, y, size, r, g, b, a, bold, underline, italic, regular)
- result = Sfml_Draw_Text.call str, x, y, size, r, g, b, a, bold, underline, italic, regular
- end
- def display
- result = Sfml_Display.call
- end
- def clear
- result = Sfml_Clear.call
- end
- def update
- clear
- #
- sprlist = @sprites.clone
- #test = Tick.tackPrecise
- sprlist.sort! { |a,b| a.z <=> b.z }
- sprlist.map!{|spr|;
- if spr.visible && !spr.bitmap.nil?
- spr.bitmap.draws.each{|draw|;
- if draw.type == DRAW_TYPE_NORMAL
- draw(draw.filepath, draw.rect.x, draw.rect.y, draw.rect.width, draw.rect.height, spr.x + draw.x, spr.y + draw.y)
- elsif draw.type == DRAW_TYPE_RECTANGLE
- #fill_rect(draw.r, draw.g, draw.b, draw.a, draw.x, draw.y, draw.width, draw.height, draw.thickness)
- elsif draw.type == DRAW_TYPE_TEXT
- draw_text(draw.text, spr.x + draw.x, spr.y + draw.y, draw.size, draw.r, draw.g, draw.b, draw.a, draw.bold, draw.underlined, draw.italic, draw.regular)
- end
- }
- end
- }
- #test2 = Tick.tackPrecise
- #p "AH"
- #p test2 - test
- display
- end
- def self.newSpr(spr)
- @sprites = [] if @sprites.nil?
- @sprites.push(spr)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement