Tuesday 11 August 2015

Week 8 (4 Aug)

This week we discussed logic statements in Scratch and in particular AND lofic.  This is illustrated in Figure 1.
Figure 1.  A possible use of the AND logic in Scratch.  AND logic table is shown.  Both A AND B must be true for the combined statement to be true and the block within the If statement run.

We can use this kind of logic to determine if two events are true.  I asked the students this week to try to use an AND statement in their code.  An example application might be an game where you need to find specific items to completed specific tasks.  These items can be collected by a player and these items are sometimes called pick-ups.  This is particularly important when creating role-playing games (RPG).  For example, see the list shown in Figure 2a.
Figure 2(a) a simple list which could be combined with the AND logic function to check if to two items are available, and if so, the action that would result;  (b) an example of such an application, being  a key brought up to a door, at which point the door opens.
 It may be that each item must be collected in order to operate a specific thing and produce a specific result.  For example s shown in Figure 2b, a key must be collected and brought to a door in order for the door to open.  Try this AND concept with a simple RPG and let me know how it goes.

No comments:

Post a Comment