Creators: General Zod 3D!

This week in Creators we explored 3D and build an animation or two using it.  The final one was a “General Zod” simulation where we recreated a scene from a classic movie

Check it out here!

general-zod

This scene used the following elements:

  1. 3D Canvas! Our canvas was set up to use WEBGL – enabling this means you can use the 3D capabilities and shapes of p5
  2. Shapes – just the two shapes here:
    1. a “Box” which is your floating “prison”
    2. an “ellipsoid” which represents Krypton
  3. Lights!
    1. We looked at the different types of lights in WebGL (ambientLights, pointLights and directionLights) and for this scene I went with a few directionLights to light things from various directions
  4. Action!
    1. Positioning and moving the shapes is performed by transforms.  We moved the rather large planet to the bottom with translate and made the prison rotate and vanish off into space with a few rotate statements.
    2. Note that with 3D stuff, we have the use of a rotateX, rotateY, rotateZ since we can rotate in lots of ways!  I also added a rotation to Krypton above to make it more realistic.
  5. Texture!
    1. Krypton: We looked at adding textures which is an image that you paste onto the object.  The sphere above is textures with an image of Mars I found – not sure what Krypton is like I but I picture it as kind of orang-ish.
    2. Prison: For texturing the prison we did the same thing, but with a difference!  It still is using an image as the texture but it’s using the p5.dom library to control the web camera and take pictures from that every frame.  This allowed us to place ourselves “live” in the scene.

It is pretty amazing the animations and effects you can create with very little code using the p5 webGL library.  Happy coding!

Bodgers –Magic Ball

This week in the Bodgers group we revisited Pygame Zero and worked on a fortune telling game based on a Magic 8 ball.

I gave the group some artwork I prepared in the Paint.NET graphics editor and we wrote some code to animate them.

I’ve added the code and images to Dropbox here.

See you all on Saturday for Belts and Pizza, don’t forget to bring drinks.

Declan, Dave and Alaidh.

Rock-Paper-Scissors for 1 and 2 Players

The Plan

Michael led the Advancers group this week, as Oliver was unavailable. Our plan was to work on 3 versions of Rock-Paper-Scissors:

  1. A one-person version where you play against the computer
  2. A two-person version where you and a friend play against each other on one computer
  3. A two-person version where you and a friend play against each other on different computers, using cloud variables (we did not get around to this)

We began by thinking about how the game works, and what we would need.

In our design, we need three sprites:

  1. My Player
  2. Opponent (either another player or the computer, depending on the version)
  3. Controller (a sprite that displays instructions, does the countdown, and uses broadcasts to sync the start and end

We also need several variables, the most important of which are:

  • my-pick: what I pick (rock/paper/scissors)
  • other-pick: what the opponent picks
  • result: based on the picks, will be set to “I win”, “I lose”, or “Draw”
  • number: a random number in the range 1-3 that the computer picks, which we translate into either a value for other-pick of “rock”, “paper”, or “scissors”

One-Person Version

Here is the logic:

1player

The controller has 5 costumes: one with instructions and four with big numbers 3,2,1,0 for the countdown.

The controller looks after the countdown, and broadcasts messages at the start and end of the countdown. Here is the controller’s code:

code1

My sprite takes my keyboard input. When the countdown is over, it calculates who wins (result). Also, when the countdown is over, it says what I picked, waits 3 seconds, and then says who won.

Here is the start of its code – you will have to figure out the other combinations yourself!

code2

The opponent sprite is the computer. Its sprite picks a random number 1-3 and converts it into a word rock/paper/scissors. It also says what it picked when the time is up. Here is the code:

code3

Two-Person Version

Here is the design:

2player

In this version, the Controller and My Sprite are the same as in the one-player version, except you might want to change My Sprite to use keys 1,2,3 for Rock, Paper, Scissors.

The Opponent Sprite code is different than before, but it is simpler: the opponent is your friend who will press 7, 8, 9 for Rock, Paper, Scissors, so you just need the code to read those key-presses:

code4

Possible Enhancements

Here are some ideas:

  • You could add sound effects, celebrations, and different costumes
  • You could find the rules for a more complex version and implement it: Rock-Paper-Scissors-Lizard-Spock
  • You could figure out cloud variables!

Bodgers – Soldering & Crimping

Usually in the Bodgers group we use breadboards and jumper wires to connect our components together which is fine for prototyping, but today we looked at some techniques for making more permanent connections.

Soldering is a process in which two or more metal items are joined together by melting and then flowing a filler metal into the joint—the filler metal having a relatively low melting point. The metal to be soldered is heated with a soldering iron and then solder is melted into the connection. Only the solder melts, not the parts that are being soldered. Solder is a metallic “glue” that holds the parts together and forms a connection that allows electrical current to flow.

We started by soldering some header pins on stripboard, then we looked at using a desoldering pump to remove excess solder. Then we looked at stripping insulation from wire, soldering two wires together and using heat-shrink to re-insulate the wire.

An electrical crimp is a type of solderless electrical connection. Crimping is normally performed by first inserting the terminal into the crimp tool. The wire is then inserted into the terminal with the end of the wire flush with the exit of the terminal to maximize cross-sectional contact. Finally, the handles of the crimp tool are used to compress and reshape the terminal until it is cold-welded onto the wire. We crimped both insulated and uninsulated terminals onto some wire.

 

See you all next week.

Declan, Dave and Alaidh

Creators – Random Dungeon

This week we took a look at a technique for generating random dungeons. Although never mentioned on the day, this technique is often called “marching squares”. It looks at the four corners of a space at a time, some of which are open and some of which are closed, and picks a shape that blocks off the closed corners.

There are sixteen possible combinations of corners on and off. All of these can be covered with these five shapes (or a rotation of them) to represent the closed off areas:

marchs

Generating the Dungeon

We generated a 2D array (a list of lists) to store our dungeon layout. At each point we used a 2D Perlin noise value (using the noise() function) to calculate a value. The point was deemed to be either open or closed based on whether this value was higher or lower than a threshold value we specified. Varying this threshold value can make the dungeon more open, or more closed in.

Drawing the Dungeon

To draw these shapes we first defined each of them as a list of x, y points defining the shape.

We then used beginShape()vertex(), and endShape() functions to draw them at the correct size, location and orientation by scale(), transform() and rotate().

Once we were able to draw the shapes, we just needed to loop over our grid, inspecting each set of four adjacent corners in turn and drawing the appropriate shape.

Here’s a screenshot of one random dungeon. Dots (green for open, red for closed) are drawn to show the grid and the lines between the individual shapes are also shown for clarity:

d2

and here is is without these overlays:

d1

Download

The files for this week can be found on our GitHub repository.

Congratulations to our Ninjas at Coolest Projects 2019

Congratulations to everybody from CoderDojo Athenry who participated in the CoderDojo Coolest Projects International in the RDS Dublin on 04 May 2019.

We had three projects which all sparked a lot of interest with the public at the event. Adam presented his game “The MegaMaker”, David and Michael presented “FidoFinder” and “Go With The Flow” was presented by Mark.

 

Special congratulations to Adam who was runner up in the Games category and the Go With The Flow team represented by Mark who were runners up in the Hardware category.

 

Creators – Quiz and Hacking

Screenshot 2019-05-02 at 00.23.50.png

This week we had a quiz. There were three rounds on Technology, Creators 2019 and Pop Culture. There was a very high proportion of correct answers on all questions. The quizes can be found here, for anyone that wants them:

Creators 2019

Pop Culture

Technology

 

After that we set everyone a programming challenge: make an animated scene. People got busy and there was some good progress. We will continue with that next week. Mark and I (Kieran) got in on the action figuring out how to draw clouds. My attempt is shown in the image at the top of this post. The code can be found, as always, on the CoderDojo Athenry Creators 2018 GitHub.

Explorers Week 10 – Scrolling Backgrounds

Hi everyone

Thank you to everyone who came on Saturday.

We did scrolling backgrounds and this is very useful in any type of game and can add an extra dimension to your game whether its a driving game or a flying game.

We were scrolling horizontally so we were using the xpos but remember you can just as easily scrolling vertically by just using the ypos

Here are the notes in PDF form

CDA-S8 Week_10-scrollingbackgrounds.pdf

 

Enjoy the long weekend and we will see you all the week after.

Martha

Julie, Eoin and Ruaidhrí

Bodgers – Cool Projects

Hello again everyone.

In the Bodgers group we’re starting to put our projects together for the Coolest Projects Showcase.

“Coolest Projects International is a world-leading showcase for young innovators who make stuff with technology. If you’re up to 18 and you’re making something with technology for fun, to solve a problem, or as a creative outlet, then we want you to come out and share your project with us! This free event will take place in the RDS Main Hall, Dublin, Ireland on 5 May 2019.”

Find out more here: https://coolestprojects.org/

If you have any questions you can contact me at coderdojoathenry@gmail.com.

Don’t forget we’re off for the next 2 weeks, we’re back on 27-Apr-19.

see you all then.

Declan, Dave and Alaidh