Remove element script and allow images to be pixel updated for similar behaviour
This commit is contained in:
+17
-9
@@ -4,8 +4,8 @@ main_scene = Scene.new
|
||||
|
||||
default_font = Font.new "assets/fonts/charybdis.ttf", 24, pixel_art: true
|
||||
|
||||
bg_image1 = Image.new "assets/images/menu_bg.png", pixel_art: true
|
||||
bg_image2 = Image.new "assets/images/game_over_dead_bg.png", pixel_art: true
|
||||
bg_image1 = Image.load "assets/images/menu_bg.png", pixel_art: true
|
||||
bg_image2 = Image.load "assets/images/game_over_dead_bg.png", pixel_art: true
|
||||
|
||||
bg_animation = Animation.new [bg_image1, bg_image2], fps: 5
|
||||
|
||||
@@ -20,9 +20,13 @@ rect = ElementRect.new 100, 25, 0xFF0000, position: {x: 50, y: 50}, z: 0, rotati
|
||||
|
||||
image_element = ElementImage.new bg_animation, position: {x: 0, y: 0}, z: -1, click_mode: :block, alpha: 1
|
||||
|
||||
script_element = ElementScript.new 100, 100, position: {x: 200, y: 200}, z: 2, click_mode: :block, alpha: 1
|
||||
image1 = Image.new 50, 50, pixel_art: true
|
||||
|
||||
pp text, rect, image_element, script_element
|
||||
image2_animation = Animation.from(image1)
|
||||
|
||||
image_element2 = ElementImage.new image2_animation, position: {x: 200, y: 200}, z: 0, click_mode: :block, alpha: 1
|
||||
|
||||
pp text, rect, image_element, image_element2
|
||||
|
||||
end_scene = Scene.new
|
||||
end_scene << rect
|
||||
@@ -60,12 +64,12 @@ App.update do |delta_time|
|
||||
|
||||
# puts "Delta time: #{delta_time}s"
|
||||
|
||||
|
||||
red_pixel = [0xFF, 0, 0, 255] # ARGB
|
||||
green_pixel = [0xFF, 0, 255, 0] # ARGB
|
||||
c_p = c_c % 2 == 0 ? red_pixel : green_pixel
|
||||
c_p = ((c_c / 10) % 2) == 1 ? red_pixel : green_pixel
|
||||
raw_bytes = (c_p * (50 * 50)).pack('C*')
|
||||
script_element.update(0, 0, 50, 50, raw_bytes)
|
||||
bg_image1.update(0, 0, 50, 50, raw_bytes)
|
||||
image1.update(0, 0, 50, 50, raw_bytes)
|
||||
|
||||
el = App.scene.elements_at(App.mouse_position)
|
||||
|
||||
@@ -83,14 +87,18 @@ App.update do |delta_time|
|
||||
elsif elem == text
|
||||
pp "Down over text element"
|
||||
end
|
||||
elem.position.x += 10
|
||||
dy = rand(-10..10)
|
||||
dx = rand(-10..10)
|
||||
elem.position.y += dy
|
||||
elem.position.x += dx
|
||||
end
|
||||
end
|
||||
|
||||
main_scene << text
|
||||
main_scene << rect
|
||||
main_scene << image_element
|
||||
main_scene << script_element
|
||||
main_scene << image_element2
|
||||
|
||||
App.start main_scene
|
||||
|
||||
time = Time.now - start
|
||||
|
||||
Reference in New Issue
Block a user