You all did great work on Saturday, there was some quite complex thinking to be done to figure it out but you did great!
the player picks a level of difficulty and the computer chooses 2 random numbers to add (subtract or multiply- whichever you choose!) together and show the numbers to the player. Fr this we needed 2 SPRITES and 4 VARIABLES called SCORE, LEVEL, NUMBER1 and NUMBER2 as well as 2 BACKDROPS.
The player then has to enter an answer to the equation and the computer tells them whether they are wrong or right.
We repeated the ask/answer questions 5 or 10 times. Can you figure out where the REPEAT loop fits?
We also had a second sprite who reacted positively to correct answers BROADCAST and negatively to wrong answers BROADCAST. You can use whatever sprites you like and change their look whatever way you like. One coder added a puppy as their second and had him bark whenever an answer was correct.
After all the questions were asked we had the 1st Sprite SAY – Game Over! and BROADCAST Game over so that the backdrop changed and music played. There are two ways to change the backdrop- see below!
Can you improve our game??! Can you figure out how to subtract or multiply instead of add? Can you get the computer to add three numbers together or give the user 3 level options like: easy, medium or hard? The notes for the Maths Game are here: CDA-S9-Week_4_20-MathsGame.pdf
Hi Folks, this week we started to model a sword using the sword found here as inspiration.
This what the sword should look like when we’re finished
We got 85% of the way through modelling the blade this week. Next week we’ll finish the blade and construct the guard, handle and pommel. These should prove considerably easier than the blade which is the most complex part.
I’ve made a video version of the building of the blade, in so far as we got it to this week:
If anyone would like my Blender file with the part-completed blade, it can be found here.
Thank you again to you all for coming on Saturday and I hope you all had fun, which is what Coderdojo Athenry is all about!
We had some great new code to learn and to use all our coding concepts we have learned so far.
For the first time we wrote code to control our sprite, rather than it moving randomly as it did last week. For this we took a look at X,Y, axis and used this rather than the steps.
We also used our sensing blocks for the first time as we wanted something to happen when our character went off the path.
Thank you do everyone you came along on such a lovely day on Saturday, hope you all got to go outside when you went home and enjoyed the weather.
This week, we improved on our game from last week.
Most games reward us for achievements (Gaining:Scores/Money/Health) and penalise us for making mistakes (Losing:Lives, Health, Money)
To this we had to create a Variable. Remember my box with the blocks. A variable holds information for you that you can use again. Remember to always give it a name that is meaningful….
Everything we have learned so far we will be using in ,most of our games we will make in future sessions. Don’t worry if you didn’t understand everything, we will be going over it again and again.
Have fun with the code you have done. Maybe try making another game!
Thank you all for coming yesterday on such a lovely day.
This week we did a simple Piano.
We only had to draw two keys, and then could duplicate these and change the names. The same applied to the code. The code is the same for each key apart from one small change so the note is the appropriate for the key.
REMEMBER! You need to make four changes each time you duplicate:
Change the name of the spite to the next Note
Change the name of the TWO costumes
Change the NOTE played
Remember, no sessions for the next two weeks. Have a nice break and for anyone with confirmations to attend next week I hope the weather is extra nice for you.
This week we started our first game in earnest. Let’s talk about the design and the steps we took to begin implementing it.
Game Design
The game involves a simple play area with pins. The players tries to knock down the pins by controlling the direction and force at which the ball is projected. The number of pins knocked constitutes the score. The game shares element of classic games such as pinball, bowling and skittles, to name a few.
Setting up the play area
To establish the play area, we used a plane (for the ground) and four cubes stretched to size to provide the walls:
Because we don’t want gaps in our walls, we’ve been careful to be precise with the positions of everything.
Applying a Force to our Sphere
We added a sphere to our scene and made sure that it had a RigidBody body component. The RigidBody component makes it so that the physic engine takes care of the movement of the sphere.
To test adding a force to the sphere we added a temporary script to the sphere and had it add a force to the RigidBody as soon as the game starts.
Immediately it was clear that the force was too weak, so we added a property to the script which allowed us to scale the force. In testing 1000 proved to be a good value. Here is the script:
using UnityEngine;using System.Collections;publicclassPushSphere:MonoBehaviour{publicfloatPushStrength=1.0f;//Usethisfor initializationvoidStart(){Rigidbodyrb;rb=GetComponent<Rigidbody>();rb.AddForce(Vector3.back*PushStrength);}//Updateiscalledonceper framevoidUpdate(){}}
We also experimented with creating a physic material and assigning it to the sphere. Different levels of friction and bounciness give different behaviours.
Testing With a Single Pin
To test the sphere colliding with a pin we added a single cylinder to the scene. Like the sphere, we made sure it had a RigidBody component attached to it. When the game started the ball shot forward and knocked the pin, as we’d hoped.
Aimer
To aim our sphere and control the strength of our shot, we created an aimer. The aimer is composed of an empty object containing two cylinders, one pointing forwards and one pointing crossways.
We didn’t want the aimer cylinders interacting with anything so we made sure to remove the colliders from the cylinders.
We also wanted the aimer to be partially transparent so we created a new material, setting the Rendering Mode to “Transparent”, choosing a colour from the Albedo colour picker and setting the Alpha value to a value less than 255.
Project
Updated project files for this week’s project can be found here. This requires Unity Version 5.4.1f1 or later.
Great to see so many of you there on Saturday, 77 Ninjas!. Hope you had a good time. And a special welcome to our new Ninjas.
This week we created a Ghostcatcher game. We used the paint editor in Scratch for the first time. As I said on Saturday, It makes things easier if you think in shapes.
Using the code we have learned so far, we moved the Ghostcatcher with the mouse and the Ghosts randomly. We also added some sound.
We are going to continue on next week and improve this game, adding some Variables and some levels.
Operators in any programming language are used when you want to calculate something new: they operate on values. variables, or expressions to produce a new value.
Since ScriptCraft is built on the JavaScript langauge, it uses standard JavaScript operators. As it happens, many other programming languages (including C, C++ and Java) use the same operators or very similar ones.
Drone Functions:
As we have seen before, in ScriptCraft you use a drone to do your building for you. The drone has functions that are part of it.
Here are some of the main drone functions that are useful when building your mods:
This example is based on a very nice program writing by Ruaidhri from Coderdojo Athenry last year, updated slightly because some ScriptCraft commands have changed in the meantime.
// Copyright Ruaidhri from ModderDojo Athenry,
// slightly updated by Michael and Alex.
// Builds a pyramid with entrance and lights inside.
exports.pyramid = function()
{
echo('making a pyramid');
var d = new Drone(self); // 'self' means start drone beside me
d.up(1);
d.chkpt('begin');
var size=31;
// Make the walls
while (size > 0)
{
d.box0(blocks.sandstone,size,1,size);
d.right(1);
d.fwd(1);
d.up(1);
size=size-2;
}
// Entrance
d.move('begin');
d.right(15);
d.box(blocks.air,1,2,3);
// Lights inside
d.move('begin');
d.right(4);
d.fwd(4);
d.up(3);
d.turn(2);
var t = 0;
while (t<4)
{
d.hangtorch();
d.left(11);
d.hangtorch();
d.left(11);
d.turn(3);
t = t + 1;
}
d.move('begin');
}