SlideShare a Scribd company logo
1 of 22
Download to read offline
过纯中 Eric-Guo 2021-08-15
How to
becoming a
Dragon Rider
使⽤ Dragon Ruby 教孩⼦们开
始 Ruby 游戏编程
Dragon Ruby History
https://dragonrubydispatch.com/2019/04/24/Issue-21.html
https://rubykaigi.org/2019/presentations/amirrajan.html#apr19
http://slides.com/amirrajan/game-dev-ruby-happiness-part-2#/5/0/4
Dragon Ruby quick overview
It’s closed source, but depend on all open source and will open source if bankrupt.
• https://trello.com/b/lx2oPd6h/public-board (Road map)
• Components
• SDL 2
• mRuby 3
• C-ext
• Author
• Amir Rajan (acquire RubyMotion from Laurent)
• Ryan Gordon
Other game engine
From https://news.ycombinator.com/item?id=26719105
• Unreal
• Powerful, but not your
fi
rst game engine
• Unity
• It’s a C# vs Ruby choose.
• Console support only on Unity Pro
• Pico-8
• A bit of too low res, not console supports
• Godot
• Free, but not good console supports
• Cocos Creator (国内)
Compare with Processing
The relationship of Processing, P5.js or Scratch
• Processing is an environment/programming language that is meant to make
visual, interactive applications extremely easy to write. It can be used for
everything from teaching children how to code to visualizing scienti
fi
c data.
• Scratch is a high-level block-based visual programming language and
website targeted primarily at children 8–16 as an educational tool for
programming.
• We can learning from those book, further more ruby allow extend C and web
server, which provide more feature set and the same time give same easy
usage feature.
Compare with Scratch
Blockly for DragonRuby: https://github.com/Rabios/dragonblocks
Why become a Dragon Rider?
Or why Dragon Ruby as child’s
fi
rst programming language?
• Writing literary instead of graphic (compare with Scratch)
• Scratch is still preliminary step.
• No type notation every where
• Consistent syntax (compare with python)
• Hot-reload
• I ❤ Ruby (personal reason)
Quick overview
Rule #1, 1280x720 60Hz ticks
def tick args
ticks = args.state.tick_count
text_w, text_h = args.gtk.calcstringbox(ticks.to_s, 5)
board_w = text_w
board_h = text_h
board_x = (1280 - board_w) / 2
board_y = (720 - board_h) / 2
args.outputs.labels << [board_x + board_w / 2, board_y + board_h, ticks, 5, 1, 0, 255, 0, 255]
args.outputs.lines << [board_x, board_y, board_x + board_w, board_y + board_h, 100, 100, 100, 255]
args.outputs.lines << [board_x, board_y + board_h, board_x + board_w, board_y, 50, 50, 50, 255]
args.outputs.borders << [board_x, board_y, board_w, board_h, 0, 0, 200, 255]
args.outputs.solids << [board_x+1, board_y+1, board_w-2, board_h-2, 35, 0, 50, 100]
end
Now let’s learning DragonRuby # 1
Ticks with resize text box
def tick args
ticks = args.state.tick_count
text_w, text_h = args.gtk.calcstringbox(ticks.to_s, 5)
board_w = text_w
board_h = text_h
board_x = (1280 - board_w) / 2
board_y = (720 - board_h) / 2
args.outputs.labels << [board_x + board_w / 2, board_y + board_h, ticks, 5, 1, 0, 255, 0, 255]
args.outputs.lines << [board_x, board_y, board_x + board_w, board_y + board_h, 100, 100, 100, 255]
args.outputs.lines << [board_x, board_y + board_h, board_x + board_w, board_y, 50, 50, 50, 255]
args.outputs.borders << [board_x, board_y, board_w, board_h, 0, 0, 200, 255]
args.outputs.solids << [board_x+1, board_y+1, board_w-2, board_h-2, 35, 0, 50, 100]
end
Tank Vs Zombie the Game Ruby
A game jam piece https://github.com/shanshaji/Tank-Vs-Zombie-Game-Ruby
Cake stack
17 year old high school boy written https://github.com/Rabios/cakestack
Learning DragonRuby # 2
Processing ManyLines with mouse and accumulation render
$gtk.reset
def tick(args)
clear_target = args.state.tick_count.zero? || args.inputs.keyboard.key_down.space
args.render_target(:accumulation).clear_before_render = clear_target
args.render_target(:accumulation).lines << {
x: 640,
y: 360,
x2: args.inputs.mouse.x,
y2: args.inputs.mouse.y,
r: 0,
g: 0,
b: 0,
a: 255
}
args.outputs.sprites << [ 0, 0, 1280, 720, :accumulation]
end
Learning DragonRuby # 3
static_solids and static_borders also works
# frozen_string_literal: true
def tick(args)
args.outputs.background_color = [63, 63, 63]
args.outputs.debug << [10, 720, "FPS #{args.gtk.current_framerate.round}"].label
if args.inputs.keyboard.key_down.space || args.inputs.mouse.click
args.outputs.static_solids.clear
args.outputs.static_borders.clear
end
return if args.state.tick_count.zero?
args.outputs.static_solids << [args.inputs.mouse.x, args.inputs.mouse.y, 100, 100, rand(255),
rand(255), rand(255)]
args.outputs.static_borders << [args.inputs.mouse.x, args.inputs.mouse.y, 100, 100, rand(255),
rand(255), rand(255)]
end
We need git and smaug to Dragon Rider
Create games and share packages with the DragonRuby community
• Installation step see https://smaug.dev
┌─[ 1:53PM][git]
└─▪ smaug dragonruby list
* DragonRuby Pro 2.26
* DragonRuby 2.26
* DragonRuby 3.0
* DragonRuby Pro 3.0
Thanks for using Smaug!
📦 Explore the package registry at https://smaug.dev/
🦗 Find a bug? File an issue: https://github.com/ereborstudios/smaug/issues
🙋 Have a question? Start a discussion: https://github.com/ereborstudios/smaug/discussions
💬 Want to chat? Join us on Discord: https://discord.gg/rwT64EtDee
Now we write a Calculator
It’s not a game still…
Snake game with DragonRuby GTK
https://gist.github.com/marcheiligers/173634708371635e257dfba84c39f774
Now we need read the 1.6M HTML manual
Good news is it’s all o
ffi
cial documents, no more.
• Visit http://docs.dragonruby.org
• Mirror in China: https://dragonruby.redwoodjs.cn
What’s DragonRuby essentially.
Or we still be able to think like children when programming?
• An SDL2 ruby runtime which running in 60 Hz.
• Turn key builds for Windows, MacOS, and Linux with seamless publishing to
Itch.io.
• Targets every platform: PC, Mac, Linux, Web Assembly, iOS, Android,
Nintendo Switch, XBOX One, and PS4 (console compilation requires a
business entity, NDA veri
fi
cation, contact Amir at amir.rajan@dragonruby.org
for more info).
Dragon Ruby input and output support
It’s limit but cross platform
• Input support: keyboard, mouse, controller (2 pair)
• Output support:
• Primitives (:solid, :sprite, :label, :line, :border.)
• Sounds
• Debug
• Triangle Primitives (Pro)
What’s new in DragonRuby 3.0
Performance from 30% to 200% faster.
• Rendering 5,000 sprites up to 80,0000, higher than Unity
• Arithmetic and comparison operations no longer attempt to coerce/infer types.
• DragonRuby’s “Level 1” Runtime has been updated to mRuby 3.0.
• DragonRuby Replay (Pro Feature) but mp4 generate in standard.
• VR support (Oculus Quest 2)
• All Screen Mode, HD Mode and Portrait Mode.
• M1 supported
More time and FAQ
Flappy dragon, Gorillas Basic and dynamic chart demo

More Related Content

Similar to Dragon Ruby 孩子的游戏编程.pdf

Rails Hardware (no conclusions!)
Rails Hardware (no conclusions!)Rails Hardware (no conclusions!)
Rails Hardware (no conclusions!)yarry
 
Defcon CTF quals
Defcon CTF qualsDefcon CTF quals
Defcon CTF qualssnyff
 
44CON 2013 - Browser bug hunting - Memoirs of a last man standing - Atte Kett...
44CON 2013 - Browser bug hunting - Memoirs of a last man standing - Atte Kett...44CON 2013 - Browser bug hunting - Memoirs of a last man standing - Atte Kett...
44CON 2013 - Browser bug hunting - Memoirs of a last man standing - Atte Kett...44CON
 
Continuous Delivery Workshop with Ansible x GitLab CI (2nd+)
Continuous Delivery Workshop with Ansible x GitLab CI (2nd+)Continuous Delivery Workshop with Ansible x GitLab CI (2nd+)
Continuous Delivery Workshop with Ansible x GitLab CI (2nd+)Chu-Siang Lai
 
DevOpSec_DockerNPodMan-20230220.pdf
DevOpSec_DockerNPodMan-20230220.pdfDevOpSec_DockerNPodMan-20230220.pdf
DevOpSec_DockerNPodMan-20230220.pdfkanedafromparis
 
Optimizing Parallel Reduction in CUDA : NOTES
Optimizing Parallel Reduction in CUDA : NOTESOptimizing Parallel Reduction in CUDA : NOTES
Optimizing Parallel Reduction in CUDA : NOTESSubhajit Sahu
 
Sacándole jugo a git
Sacándole jugo a gitSacándole jugo a git
Sacándole jugo a gitBerny Cantos
 
Docker and Your Path to a Better Staging Environment - webinar by Gil Tayar
Docker and Your Path to a Better Staging Environment - webinar by Gil TayarDocker and Your Path to a Better Staging Environment - webinar by Gil Tayar
Docker and Your Path to a Better Staging Environment - webinar by Gil TayarApplitools
 
How to control physical devices with mruby
How to control physical devices with mrubyHow to control physical devices with mruby
How to control physical devices with mrubyyamanekko
 
Rapid Game Development with RUby and Gosu – Ruby Manor 4
Rapid Game Development with RUby and Gosu – Ruby Manor 4Rapid Game Development with RUby and Gosu – Ruby Manor 4
Rapid Game Development with RUby and Gosu – Ruby Manor 4benko
 
Developing with the Go client for Apache Kafka
Developing with the Go client for Apache KafkaDeveloping with the Go client for Apache Kafka
Developing with the Go client for Apache KafkaJoe Stein
 
Год в Github bugbounty, опыт участия
Год в Github bugbounty, опыт участияГод в Github bugbounty, опыт участия
Год в Github bugbounty, опыт участияdefcon_kz
 
Middleware as Code with mruby
Middleware as Code with mrubyMiddleware as Code with mruby
Middleware as Code with mrubyHiroshi SHIBATA
 
Trace kernel code tips
Trace kernel code tipsTrace kernel code tips
Trace kernel code tipsViller Hsiao
 
Miscelaneous Debris
Miscelaneous DebrisMiscelaneous Debris
Miscelaneous Debrisfrewmbot
 
Docker and friends at Linux Days 2014 in Prague
Docker and friends at Linux Days 2014 in PragueDocker and friends at Linux Days 2014 in Prague
Docker and friends at Linux Days 2014 in Praguetomasbart
 
mloc.js 2014 - JavaScript and the browser as a platform for game development
mloc.js 2014 - JavaScript and the browser as a platform for game developmentmloc.js 2014 - JavaScript and the browser as a platform for game development
mloc.js 2014 - JavaScript and the browser as a platform for game developmentDavid Galeano
 
introduction-infra-as-a-code using terraform
introduction-infra-as-a-code using terraformintroduction-infra-as-a-code using terraform
introduction-infra-as-a-code using terraformniyof97
 
Troubleshooting real production problems
Troubleshooting real production problemsTroubleshooting real production problems
Troubleshooting real production problemsTier1 app
 

Similar to Dragon Ruby 孩子的游戏编程.pdf (20)

Rails Hardware (no conclusions!)
Rails Hardware (no conclusions!)Rails Hardware (no conclusions!)
Rails Hardware (no conclusions!)
 
Defcon CTF quals
Defcon CTF qualsDefcon CTF quals
Defcon CTF quals
 
44CON 2013 - Browser bug hunting - Memoirs of a last man standing - Atte Kett...
44CON 2013 - Browser bug hunting - Memoirs of a last man standing - Atte Kett...44CON 2013 - Browser bug hunting - Memoirs of a last man standing - Atte Kett...
44CON 2013 - Browser bug hunting - Memoirs of a last man standing - Atte Kett...
 
Continuous Delivery Workshop with Ansible x GitLab CI (2nd+)
Continuous Delivery Workshop with Ansible x GitLab CI (2nd+)Continuous Delivery Workshop with Ansible x GitLab CI (2nd+)
Continuous Delivery Workshop with Ansible x GitLab CI (2nd+)
 
DevOpSec_DockerNPodMan-20230220.pdf
DevOpSec_DockerNPodMan-20230220.pdfDevOpSec_DockerNPodMan-20230220.pdf
DevOpSec_DockerNPodMan-20230220.pdf
 
Optimizing Parallel Reduction in CUDA : NOTES
Optimizing Parallel Reduction in CUDA : NOTESOptimizing Parallel Reduction in CUDA : NOTES
Optimizing Parallel Reduction in CUDA : NOTES
 
Sacándole jugo a git
Sacándole jugo a gitSacándole jugo a git
Sacándole jugo a git
 
Docker and Your Path to a Better Staging Environment - webinar by Gil Tayar
Docker and Your Path to a Better Staging Environment - webinar by Gil TayarDocker and Your Path to a Better Staging Environment - webinar by Gil Tayar
Docker and Your Path to a Better Staging Environment - webinar by Gil Tayar
 
How to control physical devices with mruby
How to control physical devices with mrubyHow to control physical devices with mruby
How to control physical devices with mruby
 
Rapid Game Development with RUby and Gosu – Ruby Manor 4
Rapid Game Development with RUby and Gosu – Ruby Manor 4Rapid Game Development with RUby and Gosu – Ruby Manor 4
Rapid Game Development with RUby and Gosu – Ruby Manor 4
 
Developing with the Go client for Apache Kafka
Developing with the Go client for Apache KafkaDeveloping with the Go client for Apache Kafka
Developing with the Go client for Apache Kafka
 
Год в Github bugbounty, опыт участия
Год в Github bugbounty, опыт участияГод в Github bugbounty, опыт участия
Год в Github bugbounty, опыт участия
 
Middleware as Code with mruby
Middleware as Code with mrubyMiddleware as Code with mruby
Middleware as Code with mruby
 
RubyGems 3 & 4
RubyGems 3 & 4RubyGems 3 & 4
RubyGems 3 & 4
 
Trace kernel code tips
Trace kernel code tipsTrace kernel code tips
Trace kernel code tips
 
Miscelaneous Debris
Miscelaneous DebrisMiscelaneous Debris
Miscelaneous Debris
 
Docker and friends at Linux Days 2014 in Prague
Docker and friends at Linux Days 2014 in PragueDocker and friends at Linux Days 2014 in Prague
Docker and friends at Linux Days 2014 in Prague
 
mloc.js 2014 - JavaScript and the browser as a platform for game development
mloc.js 2014 - JavaScript and the browser as a platform for game developmentmloc.js 2014 - JavaScript and the browser as a platform for game development
mloc.js 2014 - JavaScript and the browser as a platform for game development
 
introduction-infra-as-a-code using terraform
introduction-infra-as-a-code using terraformintroduction-infra-as-a-code using terraform
introduction-infra-as-a-code using terraform
 
Troubleshooting real production problems
Troubleshooting real production problemsTroubleshooting real production problems
Troubleshooting real production problems
 

Recently uploaded

DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Jisc
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitolTechU
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceSamikshaHamane
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxRaymartEstabillo3
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxAvyJaneVismanos
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfMahmoud M. Sallam
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaVirag Sontakke
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...JhezDiaz1
 
Blooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxBlooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxUnboundStockton
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxDr.Ibrahim Hassaan
 

Recently uploaded (20)

DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptx
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in Pharmacovigilance
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
 
ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptx
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdf
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of India
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
 
Blooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxBlooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docx
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptx
 

Dragon Ruby 孩子的游戏编程.pdf

  • 1. 过纯中 Eric-Guo 2021-08-15 How to becoming a Dragon Rider 使⽤ Dragon Ruby 教孩⼦们开 始 Ruby 游戏编程
  • 2.
  • 4. Dragon Ruby quick overview It’s closed source, but depend on all open source and will open source if bankrupt. • https://trello.com/b/lx2oPd6h/public-board (Road map) • Components • SDL 2 • mRuby 3 • C-ext • Author • Amir Rajan (acquire RubyMotion from Laurent) • Ryan Gordon
  • 5. Other game engine From https://news.ycombinator.com/item?id=26719105 • Unreal • Powerful, but not your fi rst game engine • Unity • It’s a C# vs Ruby choose. • Console support only on Unity Pro • Pico-8 • A bit of too low res, not console supports • Godot • Free, but not good console supports • Cocos Creator (国内)
  • 6. Compare with Processing The relationship of Processing, P5.js or Scratch • Processing is an environment/programming language that is meant to make visual, interactive applications extremely easy to write. It can be used for everything from teaching children how to code to visualizing scienti fi c data. • Scratch is a high-level block-based visual programming language and website targeted primarily at children 8–16 as an educational tool for programming. • We can learning from those book, further more ruby allow extend C and web server, which provide more feature set and the same time give same easy usage feature.
  • 7. Compare with Scratch Blockly for DragonRuby: https://github.com/Rabios/dragonblocks
  • 8. Why become a Dragon Rider? Or why Dragon Ruby as child’s fi rst programming language? • Writing literary instead of graphic (compare with Scratch) • Scratch is still preliminary step. • No type notation every where • Consistent syntax (compare with python) • Hot-reload • I ❤ Ruby (personal reason)
  • 9. Quick overview Rule #1, 1280x720 60Hz ticks def tick args ticks = args.state.tick_count text_w, text_h = args.gtk.calcstringbox(ticks.to_s, 5) board_w = text_w board_h = text_h board_x = (1280 - board_w) / 2 board_y = (720 - board_h) / 2 args.outputs.labels << [board_x + board_w / 2, board_y + board_h, ticks, 5, 1, 0, 255, 0, 255] args.outputs.lines << [board_x, board_y, board_x + board_w, board_y + board_h, 100, 100, 100, 255] args.outputs.lines << [board_x, board_y + board_h, board_x + board_w, board_y, 50, 50, 50, 255] args.outputs.borders << [board_x, board_y, board_w, board_h, 0, 0, 200, 255] args.outputs.solids << [board_x+1, board_y+1, board_w-2, board_h-2, 35, 0, 50, 100] end
  • 10. Now let’s learning DragonRuby # 1 Ticks with resize text box def tick args ticks = args.state.tick_count text_w, text_h = args.gtk.calcstringbox(ticks.to_s, 5) board_w = text_w board_h = text_h board_x = (1280 - board_w) / 2 board_y = (720 - board_h) / 2 args.outputs.labels << [board_x + board_w / 2, board_y + board_h, ticks, 5, 1, 0, 255, 0, 255] args.outputs.lines << [board_x, board_y, board_x + board_w, board_y + board_h, 100, 100, 100, 255] args.outputs.lines << [board_x, board_y + board_h, board_x + board_w, board_y, 50, 50, 50, 255] args.outputs.borders << [board_x, board_y, board_w, board_h, 0, 0, 200, 255] args.outputs.solids << [board_x+1, board_y+1, board_w-2, board_h-2, 35, 0, 50, 100] end
  • 11. Tank Vs Zombie the Game Ruby A game jam piece https://github.com/shanshaji/Tank-Vs-Zombie-Game-Ruby
  • 12. Cake stack 17 year old high school boy written https://github.com/Rabios/cakestack
  • 13. Learning DragonRuby # 2 Processing ManyLines with mouse and accumulation render $gtk.reset def tick(args) clear_target = args.state.tick_count.zero? || args.inputs.keyboard.key_down.space args.render_target(:accumulation).clear_before_render = clear_target args.render_target(:accumulation).lines << { x: 640, y: 360, x2: args.inputs.mouse.x, y2: args.inputs.mouse.y, r: 0, g: 0, b: 0, a: 255 } args.outputs.sprites << [ 0, 0, 1280, 720, :accumulation] end
  • 14. Learning DragonRuby # 3 static_solids and static_borders also works # frozen_string_literal: true def tick(args) args.outputs.background_color = [63, 63, 63] args.outputs.debug << [10, 720, "FPS #{args.gtk.current_framerate.round}"].label if args.inputs.keyboard.key_down.space || args.inputs.mouse.click args.outputs.static_solids.clear args.outputs.static_borders.clear end return if args.state.tick_count.zero? args.outputs.static_solids << [args.inputs.mouse.x, args.inputs.mouse.y, 100, 100, rand(255), rand(255), rand(255)] args.outputs.static_borders << [args.inputs.mouse.x, args.inputs.mouse.y, 100, 100, rand(255), rand(255), rand(255)] end
  • 15. We need git and smaug to Dragon Rider Create games and share packages with the DragonRuby community • Installation step see https://smaug.dev ┌─[ 1:53PM][git] └─▪ smaug dragonruby list * DragonRuby Pro 2.26 * DragonRuby 2.26 * DragonRuby 3.0 * DragonRuby Pro 3.0 Thanks for using Smaug! 📦 Explore the package registry at https://smaug.dev/ 🦗 Find a bug? File an issue: https://github.com/ereborstudios/smaug/issues 🙋 Have a question? Start a discussion: https://github.com/ereborstudios/smaug/discussions 💬 Want to chat? Join us on Discord: https://discord.gg/rwT64EtDee
  • 16. Now we write a Calculator It’s not a game still…
  • 17. Snake game with DragonRuby GTK https://gist.github.com/marcheiligers/173634708371635e257dfba84c39f774
  • 18. Now we need read the 1.6M HTML manual Good news is it’s all o ffi cial documents, no more. • Visit http://docs.dragonruby.org • Mirror in China: https://dragonruby.redwoodjs.cn
  • 19. What’s DragonRuby essentially. Or we still be able to think like children when programming? • An SDL2 ruby runtime which running in 60 Hz. • Turn key builds for Windows, MacOS, and Linux with seamless publishing to Itch.io. • Targets every platform: PC, Mac, Linux, Web Assembly, iOS, Android, Nintendo Switch, XBOX One, and PS4 (console compilation requires a business entity, NDA veri fi cation, contact Amir at amir.rajan@dragonruby.org for more info).
  • 20. Dragon Ruby input and output support It’s limit but cross platform • Input support: keyboard, mouse, controller (2 pair) • Output support: • Primitives (:solid, :sprite, :label, :line, :border.) • Sounds • Debug • Triangle Primitives (Pro)
  • 21. What’s new in DragonRuby 3.0 Performance from 30% to 200% faster. • Rendering 5,000 sprites up to 80,0000, higher than Unity • Arithmetic and comparison operations no longer attempt to coerce/infer types. • DragonRuby’s “Level 1” Runtime has been updated to mRuby 3.0. • DragonRuby Replay (Pro Feature) but mp4 generate in standard. • VR support (Oculus Quest 2) • All Screen Mode, HD Mode and Portrait Mode. • M1 supported
  • 22. More time and FAQ Flappy dragon, Gorillas Basic and dynamic chart demo