Coder Social home page Coder Social logo

dxopal's Introduction

DXOpal

Game development framework for Opal, has similar API to DXRuby

How to use

see https://yhara.github.io/dxopal/

Development

  • rake build to make build/dxopal.js
  • rake build_min to make build/dxopal.min.js (You need npm install -g terser)
  • rake api to build yardoc
  • bundle exec dxopal server to preview website

License

MIT (including images and sounds under examples/)

Acknowledgements

  • Opal
  • DXRuby
  • Bxfr examples/apple_catcher/sounds/Explosion2.wav is made by this

Contact

https://github.com/yhara/dxopal

dxopal's People

Contributors

cranehouse avatar dependabot[bot] avatar hiy avatar kojix2 avatar sonota88 avatar vivit-jc avatar yhara 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

dxopal's Issues

`dxopal new` command

Currently you can use dxopal init to copy template files into the current directory, but I think dxopal new DIR is better (like rails new DIR).

Support touch events?

It is nice if our games supports mobile devices 😄

However, we need to design API for them because DXRuby does not have such events.

LoadError: cannot load such file -- dxopal

I tried releasing v1.4.0 but actually it raises this error:

ERROR: LoadError
LoadError: cannot load such file -- dxopal
at Object.Opal.load (http://localhost:7521/dxopal.min.js:1:34889)
at Function.Opal.require (http://localhost:7521/dxopal.min.js:1:35120)
at eval (eval at <anonymous> (http://localhost:7521/dxopal.min.js:1:2171179), <anonymous>:10:8)
at eval (eval at <anonymous> (http://localhost:7521/dxopal.min.js:1:2171179), <anonymous>:22:3)
at http://localhost:7521/dxopal.min.js:1:2171179
at Function.$Kernel_eval$1 (http://localhost:7521/dxopal.min.js:1:2171190)
at Function.$$require_remote (http://localhost:7521/dxopal.min.js:1:2204025)
at $$1 (eval at <anonymous> (http://localhost:7521/dxopal.min.js:1:2171179), <anonymous>:8:15)
at Object.Opal.yieldX (http://localhost:7521/dxopal.min.js:1:22606)
at Function.$$call (http://localhost:7521/dxopal.min.js:1:375302)

Unit testing

To prevent issues like #35, it is nice if we have an unit test like:

  1. Run Window.draw_xx
  2. Save it to a png file
  3. Compare it with the correct image (maybe made with DXRuby)

Input.keyevent_target= raises NameError in Opal 1.2.0

Hi. I tried to use DXOpal with Opal 1.2.0 and NameError was raised in Input.keyevent_target= (input.rb#L96).

uninitialized class variable @@keyevent_target in DXOpal::Input
    at Opal.class_variable_get (http://localhost:7521/build/dxopal.js:918:28)
    at Function.$Input_keyevent_target$eq$9 (http://localhost:7521/build/dxopal.js:26352:21)
    at Object.Opal.send2 (http://localhost:7521/build/dxopal.js:1773:17)
    at Opal.send (http://localhost:7521/build/dxopal.js:1763:17)
    at eval (eval at <anonymous> (http://localhost:7521/index.html:2:7), <anonymous>:11:3)
    at eval (eval at <anonymous> (http://localhost:7521/index.html:2:7), <anonymous>:13:3)
    at http://localhost:7521/index.html:32:7

It seems to be caused by the following change.

Rework class variables to support inheritance correctly by hmdne · Pull Request # 2251 · opal/opal
opal/opal#2251

Steps to reproduce

ruby -v
  => ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [x86_64-linux]

git log -1 --oneline
  => 45a9605 (HEAD -> master, tag: v1.5.2, origin/master, origin/HEAD) v1.5.2

Edit Gemfile

-gem 'opal'
-gem 'opal-sprockets'
-gem 'c_lexer'
+gem 'opal', '1.2.0'
+# gem 'opal-sprockets'
+# gem 'c_lexer'
bundle config set --local path 'vendor/bundle'
bundle install

bundle exec opal -v
  => Opal v1.2.0

bundle exec rake build
bundle exec dxopal server
# Open http://localhost:7521/index.html and see developer console.

Issues related to mouse events

Hi. I wrote sample code for a mouse event like this.

require 'dxopal'
include DXOpal

Window.load_resources do
  Window.loop do
    case
    when Input.mouse_release?(M_MBUTTON)
      p 'Middle mouse release'
    when Input.mouse_down?(M_MBUTTON)
      p 'Middle mouse down'
    when Input.mouse_release?(M_LBUTTON)
      p 'Left mouse release'
    when Input.mouse_down?(M_LBUTTON)
      p 'Left mouse down'
    end
  end
end

After that, I checked the operation with a browser.

I clicked the left mouse button.
The following is displayed on the browser console.

Left mouse down
Left mouse release

I clicked the middle mouse button.

Middle mouse down
Middle mouse release

I clicked the left mouse button again.

Left mouse down
Middle mouse release  (unexpected result)

The problem seems to be that the return value of ev.buttons (lib/dxopal/input.rb) when mouseup is always 0.

How to maximize the Window

idea:

Window.width = nil   # maxmize width
Window.height = nil  # maximize height
Window.load_resources do
  # ...

"XML parse error" on Firefox

(Note: this is already fixed but filing this as a note.)

The following error is shown in the developer console when I opened starter_kit/index.html on Mac Firefox 59.

2018-09-29 14 36 57

Error is not shown when I run it with the dxopal server command.

index.html: How to invalidate cache

From mobile browsers, disabling cache is not so easy as PC browsers (where you can just use DevTools.)

How about passing timestamp like main.rb?2020012702111234?

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.