Translating Bit Invader from Codea into JavaScript

Simon tried to reconstruct Bit Invader game (from Codea.io) in JavaScript, but got stuck at a certain point when he was programming the enemy to recognize the hero and the bullets. Here is how far he got. The project is available on Simon’s page in Codepen:

https://codepen.io/simontiger/project/editor/AdyVmr/

 

RGB Project in Codea using SVG Color Map

On Monday this week Simon spent hours converting hexadecimals into RGBA values for the 140 colors supported by all modern browsers and creating a color file in Codea. He used the w3schools color map available at https://www.w3schools.com/colors/colors_groups.asp and an html color codes converter http://html-color-codes.info/ 

Some of the color names were quite exotic (like Chartreuse or Bisque ), and we looked those up together in the dictionary. We also took a very close look at the relation between red, green and blue values and found out that red was added every time to make colors lighter, even in shades where you would not expect any red.

Simon later made a nice design pattern in Codea using the color file:

 

 

Diffusion-Limited Aggregation translated into Codea

Simon translated Daniel Shiffman’s Diffusion-limited Aggregation Coding Challenge into Codea. The coding challenge explores the generative algorithm “Diffusion-Limited Aggregation”, whose visual pattern is generated from random walkers clustering around a seed (or set of seed) point(s).

Unfortunately, every time the iPad falls asleep the application seems to stop, so we never got a sizable tree.

 

For Mom’s birthday 

For my birthday, Simon made me some Fireworks:

He made them look even better the following day, by adding trails:

The code is Simon’s translation into Lua (the language of the Codea app) of Daniel Shiffman’s Fireworks Coding Chalenge (JavaScript).

We’ve also thoroughly enjoyed our birthday weekend at Brugge and especially Knokke. Fine to discover such fabulous beaches in the neighborhood. Simon loves water. Perhaps, because it is somehow related to the fluidity and of his mind and because of the freedom water provides to his body.

Box2D into Codea, Java into Lua

Several recent translations of Box2D examples (from Daniel Shiffman’s book The Nature of Code) into Codea, that is Processing (Java) into Lua. Both Box2D and Codea are physics libraries.

Surface:

Revolute Joint (Windmill):

Car:

Translating examples from The Nature of Code into Lua (Codea)

This morning Simon attempted to make a more difficult translation in the Codea app of an example from Daniel Shiffman’s book The Nature of Code (Java) into Lua. It concerned the Gravitational Attraction example from Chapter 2 of the book, Forces. Simon is happy with Codea because “It’s really readable!”, “You don’t need semicolons and parenthesis!” and all logic operators are actually typed in words (“and”, “or”, “not”).

 

Unfortunately, the function Simon introduced as substitute for mouse pressed release on the touch screen didn’t seem to work:

Simon did successfully translate the simple harmonic motion example from Chapter 3, Oscillation: “I use trigonometry!”

For this example, he had to look up a complex formula for mapping a range to another range on the internet b1 + (s – a1)*(b2 – b1)/(a2-a1) “because map function doesn’t exist in Codea, so I wrote that function”.

Swapping the axes:

 

 

The Nature of Code Forces example translated into Lua

Another translation involving the Codea app, only this time Simon decided to translate an example from Daniel Shiffman’s book The Nature of Code (Java) into Lua. The example comes from Chapter 2 of the book, Forces, and focuses on creating forces in the Processing world. Forces are vectors that can be applied to objects, those can be either some forces made up specifically for a project or forces modelling those already present in the real world. The chapter discusses Newton’s second law in detail (Net Force equals mass times acceleration). I have noticed that, thanks to Daniel Shiffman, Simon knows the three Netwon laws very well by now.

Simon introduced gravity, restitution, mass (many objects of varying mass) and wind to his Lua sketch:

 

 

Here is a photo of Simon’s code after he added restitution (velocity times -0.8):

IMG_4718

In the second video, Simon also briefly talks about the force of friction (Frictio=µNv). He read about friction in the same chapter and became fascinated with it. Since he was telling me about it when we were outside today, I asked him to repeat it in the video.