[Squeakland] missing from etoys?

Bill Kerr billkerr at gmail.com
Sun Oct 28 12:05:23 PDT 2007


A friend sent me this useful information:

have a look at http://wiki.squeak.org/squeak/488
(Keyboard support in EToys)
in particular
http://bike-nomad.com/squeak/DriveUsingKeyboard.002.pr
although that project doesnt seem to work properly it shows
how to structure the    world   keywatcher  -  script

-------------------------------------------------------------------------
keyWatcher
        self getLastKeystroke =3D '<left>' ~~ false
                ifTrue: [Car1 doScript: #turnLeft]
                ifFalse: [self getLastKeystroke =3D '<right>' ~~ false
                                ifTrue: [Car1 doScript: #turnRight]
                                ifFalse: [self getLastKeystroke =3D '<up>' =
~~
false
                                                ifTrue: [Car1 doScript:
#accelerate]
                                                ifFalse: [self
getLastKeystroke =3D '<down>' ~~ false
                                                                ifTrue:
[Car1 doScript: #brake]]]]


On 10/28/07, Bert Freudenberg <bert at freudenbergs.de> wrote:
>
> Hi Bill,
>
> the Etoys version wouldn't actually be too different from the Game
> Maker one. You wrote:
>
> > start moving in directions 000000010 with speed set to 10
> > play sound sndShot
>
> "start moving" is not the same as "move" obviously. So make a
> "moving" script for the bullet that ticks and moves it one step each
> time, and on space key press "start moving", that is, call "bullet
> startScript: #moving" from the "scripting" category.
>
> An alternative to this would be introducing a "moving" variable that
> would be set to true when the space key is hit, and testing this in
> each step to move the bullet.
>
> - Bert -
>
> On Oct 28, 2007, at 4:06 , Bill Kerr wrote:
>
> > thanks bert, karl
> >
> > but still can't get the functionality I want with only a global
> > lastKeyStroke
> >
> > eg. to make a simple shooter
> > I have one script to move the shooter right and left - using right
> > and left keys
> > Another script to prime the bullet, so it starts in the same
> > position as the shooter - I have arbitarily used the z key for this
> > Another script to shoot the bullet - I have used space bar for this
> >
> > But if I shoot the bullet and then move the shooter then the bullet
> > suddenly stops
> > And I want to make a sound once only when the bullet fires, can't
> > see how to do that because the script to fire the bullet has to
> > tick continually
> >
> > Converting my visual scripts to text:
> >
> > move
> >     World1 getLastKeystroke =3D '<right>' ~~ false
> >         ifTrue: [self setHeading: 90.
> >             self forward: 5].
> >     World1 getLastKeystroke =3D '<left>' ~~ false
> >         ifTrue: [self setHeading: -90.0.
> >             self forward: 5]
> >
> > prime
> >     World1 getLastKeystroke =3D 'z' ~~ false
> >         ifTrue: [Bullet setY: self getY.
> >             Bullet setX: self getX]
> >
> > shoot
> >     World1 getLastKeystroke =3D ' ' ~~ false
> >         ifTrue: [self setHeading: 0.0.
> >             self forward: 10]
> >
> >
> > By comparison it's much easier using GameMaker, which has localised
> > (to objects) keyboard and keypress events and distinct movement
> > and  speed actions
> >
> > Information about object: objBear
> >
> > Keyboard Event for <Left> Key:
> > move relative to position (-4,0)
> >
> > Keyboard Event for <Right> Key:
> > move relative to position (4,0)
> >
> > Key Press Event for <Space> Key:
> > create instance of object objBullet at position ( objBear.x,objBear.y)
> > ______________________________________________________
> >
> > Information about object: objBullet
> >
> > Create Event:
> > start moving in directions 000000010 with speed set to 10
> > play sound sndShot; looping: false
> >
> >
> > I see making a shooter, eg. a space invaders simulation, as a nice
> > first game activity for children, one that many find highly motivating
> >
> >
> > --
> > Bill Kerr
> > http://billkerr2.blogspot.com/
> >
> > On 10/28/07, karl <karl.ramberg at comhem.se> wrote: Bill Kerr wrote:
> > > I can't see any capability for keyboard commands
> > > (important requirement for serious game making)
> > Key input is a property of the world. Make a viewer on the world
> > and one
> > of the categories has keyboard input.
> >
> > Karl
> >
> > _______________________________________________
> > Squeakland mailing list
> > Squeakland at squeakland.org
> > http://squeakland.org/mailman/listinfo/squeakland
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://squeakland.org/pipermail/squeakland/attachments/20071029/b5043c=
b8/attachment.htm


More information about the Squeakland mailing list