I can't see any capability for keyboard commands (important requirement for serious game making)
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 = '<right>' ~~ false ifTrue: [self setHeading: 90. self forward: 5]. World1 getLastKeystroke = '<left>' ~~ false ifTrue: [self setHeading: -90.0. self forward: 5]
prime World1 getLastKeystroke = 'z' ~~ false ifTrue: [Bullet setY: self getY. Bullet setX: self getX]
shoot World1 getLastKeystroke = ' ' ~~ 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
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 = '<right>' ~~ false ifTrue: [self setHeading: 90. self forward: 5]. World1 getLastKeystroke = '<left>' ~~ false ifTrue: [self setHeading: -90.0. self forward: 5]
prime World1 getLastKeystroke = 'z' ~~ false ifTrue: [Bullet setY: self getY. Bullet setX: self getX]
shoot World1 getLastKeystroke = ' ' ~~ 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@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@squeakland.org http://squeakland.org/mailman/listinfo/squeakland
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 = '<left>' ~~ false ifTrue: [Car1 doScript: #turnLeft] ifFalse: [self getLastKeystroke = '<right>' ~~ false ifTrue: [Car1 doScript: #turnRight] ifFalse: [self getLastKeystroke = '<up>' ~~ false ifTrue: [Car1 doScript: #accelerate] ifFalse: [self getLastKeystroke = '<down>' ~~ false ifTrue: [Car1 doScript: #brake]]]]
On 10/28/07, Bert Freudenberg bert@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 = '<right>' ~~ false ifTrue: [self setHeading: 90. self forward: 5]. World1 getLastKeystroke = '<left>' ~~ false ifTrue: [self setHeading: -90.0. self forward: 5]
prime World1 getLastKeystroke = 'z' ~~ false ifTrue: [Bullet setY: self getY. Bullet setX: self getX]
shoot World1 getLastKeystroke = ' ' ~~ 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@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@squeakland.org http://squeakland.org/mailman/listinfo/squeakland
Bill Kerr wrote:
I see making a shooter, eg. a space invaders simulation, as a nice first game activity for children, one that many find highly motivating
I made a tutorial a long time ago about this. http://209.143.91.36/super/503
I think there are some issues with the layout of images and the text. Also it does not use keyboard but the joystick morph.
Karl
I've solved some of the problems but still have at least one big one
SUCCESS: Can move and shoot at the same time Can make a single sound when shooting Can simulate a key press
PROBLEMS: When I fire a second bullet the first bullet stops moving (main current problem) Can only create new bullets when an original bullet is on the screen (it would be nice to create from scratch but I suppose I can live with that)
Each new bullet is automatically named bullet1, bullet2, etc My script sets the timer running for a newBullet (Player variable) . So when a second bullet is created then the first bullet stops.
Each new bullet has its own player with it's own timer. So, what's a good way to manage firing multiple bullets and then tidying up as they reach the top of the screen or hit a target (without deleting all the siblings?) I'm finding that hard.
I've put my project here: http://www.squeakland.org/project.jsp?http://www.users.on.net/~billkerr/etoy...
prime self getNewBullet setHeading: 0.0. self getNewBullet setY: self getY + 10. self getNewBullet setX: self getX
shoot World2 getLastKeystroke = '<up>' ~~ false ifTrue: [self setNewBullet: Bullet1 getNewClone. self prime. Bullet1 beep: 'clink'. Bullet1 startScript: #move. World2 setLastKeystroke: '<down>'] "simulate keypress"
move Gun1 getNewBullet forward: 5
(I haven't included the code that moves the gun left and right)
I do have a delete siblings script which I use to tidy up but it's not integrated:
deleteSiblings self tellAllSiblings: #delete
Some bits of Karl's tutorial are dated but it was very useful - thanks. I had to go through and put newBullet in everywhere, it didn't work by just replacing <gun prime> with <gun's new bullet prime>, which is what Karl's tutorial seems to do. I had to replace each line of the <gun prime> procedure code with <gun's new bullet prime>
At any rate, many thanks for the help
Hmm, why don't you let the bullet clean up itself when it reaches the edge of the screen?
"managing multiple bullets" seems the wrong approach to me, fire-and- forget would manage itself.
- Bert -
On Nov 1, 2007, at 4:29 , Bill Kerr wrote:
I've solved some of the problems but still have at least one big one
SUCCESS: Can move and shoot at the same time Can make a single sound when shooting Can simulate a key press
PROBLEMS: When I fire a second bullet the first bullet stops moving (main current problem) Can only create new bullets when an original bullet is on the screen (it would be nice to create from scratch but I suppose I can live with that)
Each new bullet is automatically named bullet1, bullet2, etc My script sets the timer running for a newBullet (Player variable) . So when a second bullet is created then the first bullet stops.
Each new bullet has its own player with it's own timer. So, what's a good way to manage firing multiple bullets and then tidying up as they reach the top of the screen or hit a target (without deleting all the siblings?) I'm finding that hard.
I've put my project here: http://www.squeakland.org/project.jsp?http://www.users.on.net/ ~billkerr/etoy/shooter1.010.pr
prime self getNewBullet setHeading: 0.0. self getNewBullet setY: self getY + 10. self getNewBullet setX: self getX
shoot World2 getLastKeystroke = '<up>' ~~ false ifTrue: [self setNewBullet: Bullet1 getNewClone. self prime. Bullet1 beep: 'clink'. Bullet1 startScript: #move. World2 setLastKeystroke: '<down>'] "simulate keypress"
move Gun1 getNewBullet forward: 5
(I haven't included the code that moves the gun left and right)
I do have a delete siblings script which I use to tidy up but it's not integrated:
deleteSiblings self tellAllSiblings: #delete
Some bits of Karl's tutorial are dated but it was very useful - thanks. I had to go through and put newBullet in everywhere, it didn't work by just replacing <gun prime> with <gun's new bullet prime>, which is what Karl's tutorial seems to do. I had to replace each line of the <gun prime> procedure code with <gun's new bullet prime>
At any rate, many thanks for the help
-- Bill Kerr http://billkerr2.blogspot.com/
On Oct 29, 2007 7:06 AM, Karl < karl.ramberg@comhem.se> wrote: Bill Kerr wrote:
I see making a shooter, eg. a space invaders simulation, as a nice first game activity for children, one that many find highly
motivating
I made a tutorial a long time ago about this. http://209.143.91.36/super/503
I think there are some issues with the layout of images and the text. Also it does not use keyboard but the joystick morph.
Karl
Squeakland mailing list Squeakland@squeakland.org http://squeakland.org/mailman/listinfo/squeakland
thanks Bert, you are correct, I've got it working now
- Bill
On Nov 1, 2007 9:57 PM, Bert Freudenberg bert@freudenbergs.de wrote:
Hmm, why don't you let the bullet clean up itself when it reaches the edge of the screen?
"managing multiple bullets" seems the wrong approach to me, fire-and- forget would manage itself.
- Bert -
On Nov 1, 2007, at 4:29 , Bill Kerr wrote:
I've solved some of the problems but still have at least one big one
SUCCESS: Can move and shoot at the same time Can make a single sound when shooting Can simulate a key press
PROBLEMS: When I fire a second bullet the first bullet stops moving (main current problem) Can only create new bullets when an original bullet is on the screen (it would be nice to create from scratch but I suppose I can live with that)
Each new bullet is automatically named bullet1, bullet2, etc My script sets the timer running for a newBullet (Player variable) . So when a second bullet is created then the first bullet stops.
Each new bullet has its own player with it's own timer. So, what's a good way to manage firing multiple bullets and then tidying up as they reach the top of the screen or hit a target (without deleting all the siblings?) I'm finding that hard.
I've put my project here: http://www.squeakland.org/project.jsp?http://www.users.on.net/ ~billkerr/etoy/shooter1.010.pr
prime self getNewBullet setHeading: 0.0. self getNewBullet setY: self getY + 10. self getNewBullet setX: self getX
shoot World2 getLastKeystroke = '<up>' ~~ false ifTrue: [self setNewBullet: Bullet1 getNewClone. self prime. Bullet1 beep: 'clink'. Bullet1 startScript: #move. World2 setLastKeystroke: '<down>'] "simulate keypress"
move Gun1 getNewBullet forward: 5
(I haven't included the code that moves the gun left and right)
I do have a delete siblings script which I use to tidy up but it's not integrated:
deleteSiblings self tellAllSiblings: #delete
Some bits of Karl's tutorial are dated but it was very useful - thanks. I had to go through and put newBullet in everywhere, it didn't work by just replacing <gun prime> with <gun's new bullet prime>, which is what Karl's tutorial seems to do. I had to replace each line of the <gun prime> procedure code with <gun's new bullet prime>
At any rate, many thanks for the help
-- Bill Kerr http://billkerr2.blogspot.com/
On Oct 29, 2007 7:06 AM, Karl < karl.ramberg@comhem.se> wrote: Bill Kerr wrote:
I see making a shooter, eg. a space invaders simulation, as a nice first game activity for children, one that many find highly
motivating
I made a tutorial a long time ago about this. http://209.143.91.36/super/503
I think there are some issues with the layout of images and the text. Also it does not use keyboard but the joystick morph.
Karl
Squeakland mailing list Squeakland@squeakland.org http://squeakland.org/mailman/listinfo/squeakland
http://billkerr2.blogspot.com/2007/11/how-to-make-space-invaders-in-etoys.ht...
I've written it up step by step, with screenshots on my blog
cheers, - Bill
On Nov 2, 2007 11:20 AM, Bill Kerr billkerr@gmail.com wrote:
thanks Bert, you are correct, I've got it working now
- Bill
On Nov 1, 2007 9:57 PM, Bert Freudenberg bert@freudenbergs.de wrote:
Hmm, why don't you let the bullet clean up itself when it reaches the edge of the screen?
"managing multiple bullets" seems the wrong approach to me, fire-and- forget would manage itself.
- Bert -
On Nov 1, 2007, at 4:29 , Bill Kerr wrote:
I've solved some of the problems but still have at least one big one
SUCCESS: Can move and shoot at the same time Can make a single sound when shooting Can simulate a key press
PROBLEMS: When I fire a second bullet the first bullet stops moving (main current problem) Can only create new bullets when an original bullet is on the screen (it would be nice to create from scratch but I suppose I can live with that)
Each new bullet is automatically named bullet1, bullet2, etc My script sets the timer running for a newBullet (Player variable) . So when a second bullet is created then the first bullet stops.
Each new bullet has its own player with it's own timer. So, what's a good way to manage firing multiple bullets and then tidying up as they reach the top of the screen or hit a target (without deleting all the siblings?) I'm finding that hard.
I've put my project here: http://www.squeakland.org/project.jsp?http://www.users.on.net/ ~billkerr/etoy/shooter1.010.pr
prime self getNewBullet setHeading: 0.0. self getNewBullet setY: self getY + 10. self getNewBullet setX: self getX
shoot World2 getLastKeystroke = '<up>' ~~ false ifTrue: [self setNewBullet: Bullet1 getNewClone. self prime. Bullet1 beep: 'clink'. Bullet1 startScript: #move. World2 setLastKeystroke: '<down>'] "simulate keypress"
move Gun1 getNewBullet forward: 5
(I haven't included the code that moves the gun left and right)
I do have a delete siblings script which I use to tidy up but it's not integrated:
deleteSiblings self tellAllSiblings: #delete
Some bits of Karl's tutorial are dated but it was very useful - thanks. I had to go through and put newBullet in everywhere, it didn't work by just replacing <gun prime> with <gun's new bullet prime>, which is what Karl's tutorial seems to do. I had to replace each line of the <gun prime> procedure code with <gun's new bullet prime>
At any rate, many thanks for the help
-- Bill Kerr http://billkerr2.blogspot.com/
On Oct 29, 2007 7:06 AM, Karl < karl.ramberg@comhem.se> wrote: Bill Kerr wrote:
I see making a shooter, eg. a space invaders simulation, as a nice first game activity for children, one that many find highly
motivating
I made a tutorial a long time ago about this. http://209.143.91.36/super/503
I think there are some issues with the layout of images and the text. Also it does not use keyboard but the joystick morph.
Karl
Squeakland mailing list Squeakland@squeakland.org http://squeakland.org/mailman/listinfo/squeakland
HI,
Nice, You have found the rule that with Etoys we have to see What an object knows and can do for itself to put the scripts in the right objects. So the bullet knows when it reaches the barrier and can delete itself.
I found about the same solution trying to solve this project.
To let the gun move in the same direction after shooting, I have tested the heading value. If it is -90 I put <left> in the input buffer, if it is 90 I put <right>
With the test on the key pressed, I have added to set heading to 0 if the <down> is pressed, This will enable to put <down> again after shooting if heading is 0. This way the gun remains still if the down key was pressed before shooting and go no moving to right or left.
Best regards.
-------- Message d'origine-------- De: squeakland-bounces@squeakland.org de la part de Bill Kerr Date: ven. 02/11/2007 07:25 À: Bert Freudenberg Cc: Tony Forster; squeakland@squeakland.org; Paul T Objet : Re: [Squeakland] missing from etoys?
http://billkerr2.blogspot.com/2007/11/how-to-make-space-invaders-in-etoys.ht...
I've written it up step by step, with screenshots on my blog
cheers, - Bill
On Nov 2, 2007 11:20 AM, Bill Kerr billkerr@gmail.com wrote:
thanks Bert, you are correct, I've got it working now
- Bill
On Nov 1, 2007 9:57 PM, Bert Freudenberg bert@freudenbergs.de wrote:
Hmm, why don't you let the bullet clean up itself when it reaches the edge of the screen?
"managing multiple bullets" seems the wrong approach to me, fire-and- forget would manage itself.
- Bert -
On Nov 1, 2007, at 4:29 , Bill Kerr wrote:
I've solved some of the problems but still have at least one big one
SUCCESS: Can move and shoot at the same time Can make a single sound when shooting Can simulate a key press
PROBLEMS: When I fire a second bullet the first bullet stops moving (main current problem) Can only create new bullets when an original bullet is on the screen (it would be nice to create from scratch but I suppose I can live with that)
Each new bullet is automatically named bullet1, bullet2, etc My script sets the timer running for a newBullet (Player variable) . So when a second bullet is created then the first bullet stops.
Each new bullet has its own player with it's own timer. So, what's a good way to manage firing multiple bullets and then tidying up as they reach the top of the screen or hit a target (without deleting all the siblings?) I'm finding that hard.
I've put my project here: http://www.squeakland.org/project.jsp?http://www.users.on.net/ ~billkerr/etoy/shooter1.010.pr
prime self getNewBullet setHeading: 0.0. self getNewBullet setY: self getY + 10. self getNewBullet setX: self getX
shoot World2 getLastKeystroke = '<up>' ~~ false ifTrue: [self setNewBullet: Bullet1 getNewClone. self prime. Bullet1 beep: 'clink'. Bullet1 startScript: #move. World2 setLastKeystroke: '<down>'] "simulate keypress"
move Gun1 getNewBullet forward: 5
(I haven't included the code that moves the gun left and right)
I do have a delete siblings script which I use to tidy up but it's not integrated:
deleteSiblings self tellAllSiblings: #delete
Some bits of Karl's tutorial are dated but it was very useful - thanks. I had to go through and put newBullet in everywhere, it didn't work by just replacing <gun prime> with <gun's new bullet prime>, which is what Karl's tutorial seems to do. I had to replace each line of the <gun prime> procedure code with <gun's new bullet prime>
At any rate, many thanks for the help
-- Bill Kerr http://billkerr2.blogspot.com/
On Oct 29, 2007 7:06 AM, Karl < karl.ramberg@comhem.se> wrote: Bill Kerr wrote:
I see making a shooter, eg. a space invaders simulation, as a nice first game activity for children, one that many find highly
motivating
I made a tutorial a long time ago about this. http://209.143.91.36/super/503
I think there are some issues with the layout of images and the text. Also it does not use keyboard but the joystick morph.
Karl
Squeakland mailing list Squeakland@squeakland.org http://squeakland.org/mailman/listinfo/squeakland
squeakland@lists.squeakfoundation.org