Code Monkey home page Code Monkey logo

dragonruby-zif's People

Contributors

cbilski avatar danhealy avatar davebytemfg avatar dcrawl avatar imactia avatar kfischer-okarin avatar logankoester avatar marcheiligers avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dragonruby-zif's Issues

Newlines not handled in label.wrap

words = @full_text.gsub('\\', '').gsub("\n", '\\n').split(' ')
but then a couple lines later
lines = cur_word.split("\n")

so the "\n" is remove in the gsub above and the spit then doesn't find any.

here's a quick hack that might be wrong, but seems to work slightly better in my code, in the @wrapping_label example, something still seems off, but not sure why, but wanted to get this to you for a more correct fix. Probably there's a better way to inject newline label that's needed.

diff --git a/app/lib/zif/ui/label.rb b/app/lib/zif/ui/label.rb
index ed7bcca..a3cfff4 100644
--- a/app/lib/zif/ui/label.rb
+++ b/app/lib/zif/ui/label.rb
@@ -173,9 +173,20 @@ module Zif
           cur_word = words.shift
 
           # If this word contains newlines, split into new words and add the extras back to 'words'
-          lines = cur_word.split("\n")
-          words.unshift(*lines[1..-1]) if lines.length.positive?
-          cur_word = lines[0]
+          lines = cur_word.split('\\n')
+          if lines.length.positive?
+            words.unshift(*lines[1..-1])
+            cur_word = lines[0]
+          else
+            cur_rect = cur_label.rect
+            old_y = cur_label.y
+            cur_label = dup
+            cur_label.text = ''
+            cur_label.recalculate_minimums
+            cur_label.y = old_y - cur_rect[1]
+            new_labels << cur_label
+            next
+          end
 
           existing_text = cur_label.text
           cur_label.text = existing_text + (existing_text == '' ? '' : ' ') + cur_word
diff --git a/app/scenes/ui_sample.rb b/app/scenes/ui_sample.rb
index 03995fb..18dbaf9 100644
--- a/app/scenes/ui_sample.rb
+++ b/app/scenes/ui_sample.rb
@@ -57,7 +57,7 @@ module ExampleApp
       @cutout.y = 60 + 25
 
       @wrapping_label = FutureLabel.new(
-        'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.',
+        "Lorem ipsum\ndolor sit\n\namet, consectetur adipiscing elit, \n\nsed do eiusmod \n\n tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.",
         size:      -2,
         alignment: :left
       ).tap do |l|

Camera smoothness

The camera should work this smoothly when zooming & panning:

Kapture 2021-03-20 at 04 43 35

This is basic behavior from Godot Camera2D

Parallax Camera

It should be fairly easy to modify Zif::Camera to implement a parallax effect (e.g. flappy dragon)

This might be a good first project for a new contributor:

  1. Create a ParallaxLayer class based on SimpleLayer ActiveLayer
  2. Create an example scene similar to the World scene which initializes some ParallaxLayers
  3. Hook the new example scene into the sequence somewhere by registering the scene in main.rb and then modifying the @next_scene attributes on the existing example scenes.

Zif.roll modifer default should be zero

->  Zif.roll(dice: 1, sides: 1)
=> 3

That was unexpected until I looked up the def and then it made sense.

from zif.rb

  def self.roll(dice: 4, sides: 16, modifier: 2)

Might be better to default the modifier to zero.

Yes, I could also use the roll_raw call instead, but invoking the rule of least surprise.

UI elements should be resizable without recreating them

The UISample scene is recreating UI elements from scratch every tick, instead of resizing what has already been created. This is not very performant, so this sort of resizing isn't going to work well in an actual game. It would be nice if it was supported and it might be a good refactoring project.

Missing unit tests

Zif is doing very little interactively with DR so I am pretty sure I could get away with rspec tests and some minimal mocking. But it leaves it open for bugs that only occur in DR flavor ruby
On the other hand assert.true! is a little underwhelming

Can't Nest CompoundSprites

Due to expecting to call draw_override, there is an incompatibility when trying to add a Zif::CompoundSprite to the @sprites array on another Zif::CompoundSprite.

An example to illustrate this would be attempting to refactor the ExampleApp::FormField class to use a CompoundSprite for the background, like switching it to ExampleApp::MetalCutout instead of the simple white rectangle.

This class should probably be refactored a bit to handle this situation. The two major complications are:

  1. Only the top level CompoundSprite should be calling draw_override, and should reach into its descendants to draw them
  2. It must translate the positional and dimensional attributes down to the nested CompoundSprite (recursively). Specifically, the nested sprite should be positioned on screen relative to its parent's x/y and zoomed relative to its parentsource_w/h.

Add scenes to the Example App copying DR sample functionality

To demonstrate the benefit of using the framework, apples to apples comparisons of Zif code versus the samples provided in the DR documentation should be written. These are easy first contribution tasks!

Each sample should be contained within a Scene where possible. A Scene to select samples would be great.

Full paths should be allowed for all animations just like they are for sprites

This works:

    self.player_sprite = Zif::Sprite.new.tap do |s|
      s.x = player.x
      s.y = player.y
      s.w = player.size
      s.h = player.size
      s.path = 'sprites/spritesheet.png'
      s.source_h = 8
      s.source_w = 8
      s.source_x = 0 * 8
      s.source_y = 0 * 8
    end

this does not:

    player_sprite.new_tiled_animation(
      named: :walk,
      width: 8, 
      height:8, 
      path: 'sprites/spritesheet.png',

      durations: durations,
    )  

Recommend going with the principle of least surprise. Some devs will not use the normal DR conventions. Also recommend if a path is not found throwing an exception stating the problem, but I'm not sure if that's common with DragonRuby itself.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.