Creators – Random Pin Placement

This week we worked on random pin placement for our game. We updated the existing PinManager component to randomly (as opposed to regularly) place a number of pins into the scene.

Arrays

An array is a way for a variable to hold more than one value. It’s a a very useful concept in programming; complex programs would be practically impossible without them. In C# arrays are declared as follows:

     int[] nums = new int[4];
     bool[,] grid = new bool[rows, cols];

The first line creates a one-dimensional array called nums which has four entries: nums[0], nums[1], nums[2] and nums[3].

The second line creates a two-dimensional array called grid. Note the size in this case depends on the values of the variables rows and cols. The first entry is grid[0,0] and the last is grid[rows – 1, cols – 1]. The total number of locations in this array is rows * cols.

Continue reading

Beginners Scratch – Week 7 – Breakout

***Next week we will be doing Animation! Please bring any miniature figures that you might want to use to create a short story through stop motion photography. We will also need some way to take photos and download the images to the computer – so parents need to remember a camera and download cables. I will bring a big load of modelling clay.***

Breakout is a variation of our previous game, Paddleball. We create a new scoring experience for our gamers by introducing blocks at the top of our screen that they get points for hitting.

CDA-S5-Challenge_04-Breakout-game view

Everyone already knew how to import or create the first two sprites – the paddle and the ball and most coders remembered from paddleball how to get the paddle to forever follow the mouse in only the x-direction. CDA-S5-Challenge_04-Breakout-paddle control

The code to move the ball was essentially the same as in the paddle ball game with a small change to broadcast the starting position to itself.CDA-S5-Challenge_04-Breakout-ball control 2

We then created two variables, one for the score which will go up when the ball hits a block sprite(can you copy this code from the Paddleball game code and use it in the ball sprite?) and one for lives which will go down every time the ball touches the end line we added under the paddle on the Backdrop. Can you figure out where to put the code to reduce lives by one when the ball touches a certain colour?CDA-S5-Challenge_04-Breakout-variables

Lastly, we created the block sprites and coded for them to fade away when they touched the ball. We use the EFFECT block of code in LOOKS.CDA-S5-Challenge_04-Breakout-brick script

The complete set of notes in .PDF format can be opened here:CDA-S5-Challenge_08_Breakout. You can play with my completed game on the http://scratch.mit.edu webpage. If you sign in as cdathenry1516 and use the password: cdathenry, you will be able to play all our games. If you have your own sign in name, just search for cdathenry1516 and you can see and play them all as well. Please put yours up there as well!CDA-S5-Challenge_04-Breakout-save to website

See you all next week!

Julie

 

 

Week 7 – Scratch Beginners – Christmas Scene-Animation

Hi everyone,

This session we got into the Christmas spirit and we created some animated Christmas Scenes.

CDA-S4-Week_07-ChristmasScene

Using costumes we could have the effect of movement, snow falling, dancing penguin, or flashing lights. We could also use the colour effect code to change colours.

Walking around the room I saw lots of great scenes, some dancing Santas, reindeer with noses that change colour and lots lots more.

Next week is our last week so we are going to have a “Show and Tell” and then some Pizza! If you would like to show us anything you have done so far this year, just let one of the mentors know on Saturday and we will get you up to show everyone. If you would rather not get up in front of the room that is fine, but I would love to see it so make sure to call me over to have a look.

NEXTWEEK

Looking forward to seeing you all there on Saturday. D’ont forget to get into the mood, wear something Christmasy..Jumper, Hat, Scarf, socks, earrings, whatever!

Here are the note from this weeks session. CDA-S4-Week_07-ChristmasScene.pdf

Python Games – Week 7: Collision Detection

Today the Python games group explored one of the most important things used in graphical computer games, collision detection. We also investigated the use of lists and for loops to manipulate sprites in our games. Our demo code is available here.

We are still working on our ocean game and we will add audio next week.

These are my slides from today python session_7

Scratch Beginners – Week 7 – Paint.net

Hello everyone,

Today we took a look at Paint.net, which is a drawing program. I quickly went through the menus but the best way to learn a program like this is to use it and experiment with it.

PAINTNET

The main reason we looked at it this week was because we will need it next week as we begin our modelling and stop/motion animation. After we take our photos we will be able to “clean them up before we bring them into Scratch as our Sprites.

snake

Next week, if the Moms and Dads could bring along a camera or phone along with the lead to attach these to your laptop.

And of course most important of all bring your imagination!

Here the full notes from todays session in PDF form. CDA-S3-Challenge07-LearnAboutPainting.pdf

ModderDojo Athenry Week 7: Learning More about Functions

In recent weeks, we have been writing JavaScript functions to build MineCraft structures using ScriptCraftJS.

Download our mods here: https://cdathenry.wordpress.com/2013/11/10/modderdojo-athenry-our-scriptcraftjs-minecraft-mods/

This week, we spent a bit more time learning about functions, since they are an extremely important part of any programming language. Slides below.

Function Parameters

Default Values for Parameters

Multiple Functions in a Mod (1)

Multiple Functions in a Mod (2)

Helper Functions and Standalone Functions

Why Use Multiple Functions?

Beginners Scratch – Challenge 7 – Buid Your Own Game!

These are the notes from our seventh challenge in Season 2 of Scratch Beginners, CoderDojo Athenry.

The challenge this week was to work on your own game. The coding concepts for this challenge are:

  1. Using the Scratch skills you have acquired for your own games
  2. Creativity and imagination
  3. Designing your own program.

A key point in developing your own game is to start simple, get the first idea tested and working, and then start adding more. We also spoke about the usefulness of planning on paper, rather than jumping straight into coding (which can be a tough one to sell!)

Here are the notes from the day (PDF): CDA-S2-Challenge07-YourGame.pdf

If you want to check how we did things in previous challenges, you can find the programs here: http://scratch.mit.edu/galleries/view/183379

We will continue to work on our own games next week, and I will post a link to a gallery of games that ninjas have produced.

Advanced Scratch – Week 7 – A fancy Piano

What are we going to learn this week:

Modularistion – How to make your code simpler and easier to look after.

Sequential Processing – review

Databases – storing static data to use later in the day.

Remember the Piano last week, where we ended up with the same code repeated again and again, all that copying, yeaagh!!!

Well this week we are going to have a look at doing the same thing but a little smarter.

This is the code that we ended up with last week, where everything was the same apart from the Mouses X position that we were checking.

Well we are going to look at making this a lot smarter.

Let’s imagine if we could get the notes on the Keyboard to got from 1 to 15 instead of 48 to 72, that should then make things a lot simpler. In order to do this we need to do a little number crunching, don’t worry if you don’t understand all of what follows.

My Piano Keyboard goes from X = -222 to x = +222 it would be easier if it went from 0 – to 444?

We can sort this out easily enough, we just make our own variable to store the Mouse X value, and add 222 to it, like this:

So our Keyboard is now 444 units wide and there are 15 keys on it, that means that each key takes up (444 / 15 ) 29.6 units.

If we divide the MouseX value by 29.6, we get the number of the Key that has been pressed (ranging from 0 to 14). For example if the User clicks on the third note, this would have an X value of around -150, we add 222 to that, which gives us 72, we then divide 72 by 29.6 which gives us 2.43, if we just take the number before the decimal point, this gives us 2, which is the third key 0,1,2. And to make it three we just add one.

Now to get just the number to the left of the decimal point is not as simple as rounding, as we always want to round DOWN. So the simplest way to do it in Scratch is to just treat as some text and find out where the “.” is. If it is in the third character then we take tw characters, otherwise we just take one. Fortunately we know that there will only be a maximum of two numbers on the left. And finally we add the one at the end so we end up with this…

Now this has got us a number from 1 to 15, how do we translate that into the correct Note to play?

We need a Database of all the possible Notes that can be played. We will store this information in a List, and fill it full of data when you click on the Green Flag.

The Notes go from 48 through to 72, with a few missing inbetween. What we want to do is have the Notes numbered from 1 to 15. This will make it easier to figure out what note to play when the user clicks on the keyboard.

We fill the list as like this…

So how does this all help us get rid of the big long repeated code block that we had before?

Well, instead of looking to see where the mouse is ourselves we just ask the code that does all the Maths to figure it out for use. We can use a Broadcast and Wait for this, so we have one “if mouse down” which asks the other code what Note should be played.

If you take out the Record and Playback code, this is everything you need…