Yousrc – introduction

yousrc logo


Yousrc is an online resource that promises to teach programming skills by building simple programs that can easily be played on an android mobile phone via their own yousrc app.  Now I finally have an android phone with a large enough screen (touch wood!) I can have a play and try this out properly.

simple yousrc code

simple program

The resource contains many features useful to schools, including the ability to register as a teacher and then register your own students and provide them with their logins and monitor their accounts without having to go via students’ email addresses.  It also promises that all apps are moderated before publishing and therefore child-friendly, and this goes for all resources and forum posts as well.  I’m not sure how they would maintain that on a much larger scale, but for now all this is available for free, with an optional paid version offering more online space, more support and more teaching/learning resources.

Currently if you have students registered within your school they submit apps for your approval.  If you approve them, they then go to a member of the yousrc team for further checking, before they are published and available to anyone.  The site features some projects if you wish to see the sorts of things that have been produced.  This is an example game made by the project’s owner.

I’ll be starting by working through the teachers’ resources available from the site.  There are six lessons available to teachers, which take you from creating your first “Hello World” program to displaying, moving and bouncing an image, plus using input via mouse and adding sound effects.  These promise to introduce the basic programming structures: loops, if statements, functions, global and local variables etc.  By the end of the sixth lesson the student will have written a program that has a logo moving around the screen, making a sound as it bounces off the edges and stopping and ending the app if the logo is clicked on.

Yousrc uses its own language, ELC, and all sourcecode for published apps is freely available.  It makes use of the Java runtime environment.  Code is written into the browser, in an editing window which can be run fullscreen if preferred.  Code is colour coded for ease of understanding, and there is a built-in checker to pick up syntax errors.  Apps can then be run onscreen from the editor, and you can optionally see all variable values as the app is run.

a program to animate the logo

animating a logo

Running apps on your mobile phone entails installing the free yousrc android app and then logging in with your details.  You can then access all your apps, published or unpublished, or look at other published apps, although I couldn’t find a search feature and I found the main app rather slow to respond at times and very difficult to work with.  There is a search feature on the main website, however.

One issue could well be the difference between designing an app with mouse input and with touchscreen input, so I’ll be looking into how that is handled.  When an app is played on the phone, a touch pad appears at the right of it with arrow keys and a space key, or there is the option to switch to motion sensors.  I found dragging my finger onscreen had the same effect that moving the mouse would have done on the computer version of the game.

First impressions are that there is a lot of support available for this tool, and the language I’ve used so far is straightforward and recognisable, but it will take more experience before I really see what the software is capable of and how far students are likely to be able to take it.  There is also the issue of how different the language is from any of the standard languages, so again I’ll be looking at that as I proceed.  I’ve found nothing wildly different so far, however.

I hit a few technical problems with my system to start with, so I’ll be keeping an eye on that as I go on as well: one essential requirement for software for learning is that it is stable, but in my case it could well have been a browser add-on causing problems.

This is tougher to get going with than App Inventor, but it does look and feel a lot more like proper coding, and I suspect the learning would be more intensive (which is both good and bad, depending on circumstances!).  The selling point for me is being able to see your own work on your mobile phone, so I’ll be revisiting at some point soon to move on a little further.


Online learning – MOOCs

There are many ways to learn: attend college or university, try to teach yourself from a book or videos, and now a new way – MOOCs – massive open online courses.  These are very new to the scene, but many of the big universities are quickly picking up on the idea.   I’m currently enrolled in courses from two different providers, Udacity and Coursera.  Both provide their learning through videos and online questions with instant feedback, plus quizzes or other work to be completed independently and assessed (assessment is done either automatically or via peer assessment).

Udacity offers, among others,  CS101 introduction to computer science,  which is a basic introduction to programming via Python.  This course not only offers a good grounding in programming, but also does it via building a search engine, thus showing some of the secrets behind google; one of the first tasks you do is build your own web crawler to collect links.

Coursera offers Internet history, security and technology, which shows how computing and the internet developed and some of the issues involved, a course which requires no technical skills and is recommended for anyone who uses the internet regularly.

I do recommend you check these out: each course has thousands of students from around the world enrolled and learning, and the forums tend to be very supportive places.  If you keep up and complete the materials by the deadlines a certificate is usually offered, which is good to show what you have done but probably holds no actual merit; the main benefit is in the learning itself.

There are examples on the websites of students who have gained jobs following their studies and some impressive projects that students have built, and udacity is starting to offer formal tests of their learning in the on-line learning centres around the world.

One word of warning though: they do involve proper learning, and you will get the best out of them if you take them seriously and set aside time each week to work through the materials and attempt the tasks.



Processing – part 2

simple shapes drawn on screen

A variety of shapes

Time for another look at Processing.  I now have the book Getting Started with Processing, and it seems straightforward so far.  The language is described as a dialect of Java, with custom features for graphic drawing.  The code I’ve used so far can be built up one line at a time, making it feel a little like building up a sketch.  Commands include ellipse, rect, triangle, quad, arc etc, plus beginShape/endShape which draws a shape vertex by vertex.  The stroke, stroke colour, fill colour and transparency can all be set with parameters.

listing for drawing shapes

listing to draw shapes

The code is straightforward, simply the name of the shape followed by parameters which either refer to the on-screen co-ordinates or the dimensions of the shape.  I used a for loop to draw the series of lines – any regular drawing can reuse code in this way, and of course the use of variables can simplify the drawing process as well.

robot drawn with Processing

Simple robot

To draw arcs, the measurement is given in radians, but there is an easy way to convert degrees to radians if you prefer to measure that way.

So far so good; the fun will be learning how to animate the shapes and interact with them.


Virtual pet specification – details

virtual pet graphic

My first design for a virtual pet

If I’m to build a virtual pet game, I need to be very clear exactly what I’m expecting it to do.  Then I can start looking out for the code structures I need to implement.

I’m aiming for two products.  The simpler one will have a pet that the player can interact with, to feed and keep healthy.  The more complicated one will have a pet that can interact independently with its surroundings, and the player will need to make sure there is food available, for example, but the pet itself will decide when it wants to eat.

So for the simple version:

The pet will be awake three-quarters of the time and sleep the rest of the time.  It will have hunger, happiness and health, which will vary from 0 to 100.  All these will change over time, less so while asleep.  Hunger will be controlled by feeding it, health by giving it medicine and playing with it, and happiness by playing with it.  Waking it up when it is asleep will reduce happiness, but may be necessary if it is ill or starving, for example.

There will also be some interaction between the attributes: being too hungry will decrease happiness and health.  Hopefully I can encode this with maths, rather than needing extra if statements (making the change in happiness directly relative to the hunger and health values in some way).

There will be three buttons: feed, play and medicine.  Clicking these buttons will interact with the pet, changing the graphic and changing the appropriate value(s).

What I haven’t got for any of this is any incentive to keep the pet alive, no way to keep any kind of score.  I’m simply relying on the player wanting to keep the pet alive.  What I could do is add some sort of ageing system, whereby the maturity of the pet can be recorded.  Then the player can be trying to beat their own record of how long one pet has been kept alive.  That will go in the extended version, I think!

Code-wise: I will need a way to display graphics, plus buttons.  I need to respond to the pressing of the buttons by changing the graphics and the variables.  The variables will also change according to a timer that goes off regularly. There will be an element of randomness in the variable changes, particularly for illness, although hunger will be fairly steady.  A way of making it more complex would be to have variables changing at different rates according to activities, for example getting hungry quickly if playing and slowly if sleeping. I foresee lots of looping and lots of if statements in the code.

So I need to look for a way to display the elements, a way to run a timer to change the variables, a way to respond to button presses and code to loop and fork according to input from the buttons.

I know how to do this already in Scratch/BYOB.  It should be fairly straightforward to do it in App Inventor.  I have high hopes for Greenfoot.  Python seems a lot tougher, but there is a listing in the book I’m using that creates just such a virtual pet, that I should be able to adapt.  Processing is supposed to be good for graphic work – I’m hoping it’s a lot simpler than Flash, which would be another option for a project that involves lots of animation.  There are one or two further possibilities that I haven’t investigated yet!

One idea for Python (and possibly for any of the written languages) is to separate display from engine, as I did when I was first learning programming, so building an engine that will do the main processing, and a separate class that  controls the display, enabling the display/input to be updated later.  This means I will need to know how to create more than one class for a project, but will make it easier to update. I have access to the easygui library for Python which will display a series of buttons to click, so a rudimentary interface should be straightforward.

What I need to do now is write the algorithm for the pet’s behaviour, and then translate it into the different languages.

Once I’ve got working versions of the simple pet game, I can start on a more complicated version with the pet acting more independently.  This will require far more graphics and an element of artificial intelligence, which should be fun to play with and lead to the possibility of building up complexity gradually, for example by the player buying objects to add to the house.  Guess I’d better get going on the simple versions!


Greenfoot part 2

turtle game with snakes and lettuces

Turtle game with snakes and lettuces

I’m still progressing with the Greenfoot videos, and my turtle game has now developed to the point where I control the turtle who eats the lettuces, while the snakes move randomly around and eat the turtle.

The code is still straightforward, although I’m already using constructs like If statements, sensing keyboard input, generating random numbers and moving my code into functions called from the Act method rather than writing a very long Act method – I like the way that good code practice is encouraged from the start.  In the same way, documentation via comments is encouraged.

Turtle code stage 2

Turtle code stage 2

Greenfoot definitely has a more grown-up feel than most of the other things I’ve looked at so far, while still being game-based.  The game so far is already open to many variations, both in graphics and in behaviour, even at this early stage.

What I’ll be interested to see is the point where the code can be used more generally; the GCSE syllabus covers many of the basic code constructs, but not generally to use them in a games context.  Indeed, for most of the assessment tasks a GUI is not necessary, and they could be built to use a console.  If Greenfoot gets easily to the point where it can be used for more procedural stuff as well, then it would be a good choice, but if that’s a direction it doesn’t move in very easily, then my impression is that it would be difficult to use it at GCSE level (although of course Java itself could easily be used, I would imagine).  For a computer club, however, it would be great.  And here we come to the argument between teaching things that are useful and/or interesting and things that will get a qualification!

Michael Kölling also has teacher commentary videos on his site, giving tips and advice to teachers who are introducing the concepts to their students, and these have some very good ideas.  I think at this stage the problem can be to keep students focused on what they can do, and developing and practising that, rather than thinking about what they would like to do, and attempting things they’re not up to yet.

Indeed, that’s my problem at the moment as well, in all these different programs!

Michael does make a point of showing how to access the documentation of a class as he goes through his tutorials, emphasising that it’s more important to know how to find information that you need than to actually have it in your memory.  I thoroughly agree with that principle: learning how to learn is the most important skill that someone can learn, because once they know the key to that, they can do anything else with it.


Processing – another resource

I’d never heard of Processing until a few days ago, and then I came across three mentions of it in less than 12 hours, and that sort of coincidence is what makes me take interest.

circles drawn with Processing

Circles drawn with processing

Processing is a language tailored towards graphic programs, and that’s really all I know about it so far, apart from it being what Tom Scott uses, so it must be fairly useful and versatile.  I’ve now downloaded and installed it and written my first program, which displays circles under the mouse as it moves – black if the mouse button is pressed and white otherwise.

processing editor

Processing editor

I’ll be exploring Processing more over the coming days and weeks, and seeing just what it is capable of and what it’s like to learn. My first reaction was that the editor looks very like the Arduino code editor, and like in arduino coding, the programs are called sketches (on the Processing website, they’re referred to as sister projects).  The code is typed into the main area of the screen, while messages are displayed at the bottom.

Processing will run on all the major platforms, Windows, Linux and Mac, and it’s quick and easy to export the completed program either as an applet to be embedded in a web page or as a stand-alone application for any of the platforms.  The language looks straightforward so far, and the editor uses colour coding and indenting to make structure clear.


A frustrating time today + Python

I spent most of the morning returning my new android phone, which not only refused to connect to the App Inventor, but also stubbornly refused to connect to my router via wifi.  I obtained a replacement, which seemed to work, but after trying again to connect it to app inventor, again without result, it stopped talking to the router as well, with the same fault as the previous one – cycling between connecting, obtaining IP address and authenticating.

So it looks like that will be yet another return, and this time I would be asking for a different phone.  I find it difficult to understand why the cheap phone will connect just fine to the router, while this more expensive one, at more than 3 times the price, refuses to.

Neither phone will connect to the app inventor properly, but I believe that’s an issue about drivers.  Suddenly I find myself in an incredibly frustrating world of technical problems.

skiing game written in python

Simple skiing game

So I turned to the Hello World python book, because I’d just reached the point in the book where I’d read past the theory and was invited to type in a program to make a game, with the idea that you learn a lot just by copying code.

The theory is good: that’s how I learned a lot of my code, by typing it in.  But it’s a long program at a couple of pages in the book, there’s far too much in there that’s new to me, and I eventually gave in and looked for the example program that was provided.

It’s a simple game, with a skier skiing downhill and trying to catch the flags while avoiding the trees.  Control is via the left and right arrow keys on the keyboard.  It’s a good example of what the software can do, but I was rather disappointed at how much of the code was new, and how tough it was to type it in without errors.

I’m left both impressed by what python is able to do with a relatively short listing, and frustrated by the amount of new content that was in that listing.  I feel the book would have done much better to include more practice programs along with the theory in the previous chapters, and to have introduced the various concepts used in this game in a more gradual fashion before putting everything together.  Expecting anyone to type in many lines of code they don’t understand is asking for trouble!

In summary, I’ve had an unproductive and frustrating day, and came up hard today against the complexities of some of these systems we expect to run smoothly.  I’ll be taking another look at that listing in the book next time, and seeing if I can start to unpick it. Otherwise, I’ll be moving to a different resource.  I’ve also bought a few more books on various topics, and still have one or two more programs to introduce, before starting to go deeper into them all.