![]() Also, you would either have to retrieve the array from the world class, or just run the movement code for the body of the snake by calling a method in the world class and executing the head movement in the snake class. That is, start the act method with the following statement 'if (!"head".equals(segment)) return '. If in the Snake class, then only execute the code when the act is running for the lead segment (head) of the snake. To move the head, you could just call the move() method in your snake class for the head 'snake.move() '. code to move head (check for keystrokes, check for world edge, etc.)This code can be placed in the act method of the world class. If (last != null) tLocation(snake.getX(), snake.getY()) }My snake dies when its near the segments Playground.addObject(playground.snake, (), ()) SetLocation(getX() + speedX, getY() + speedY) Īctor body = getOneObjectAtOffset(speedX, speedY, Snake.class) Īctor food = getOneObjectAtOffset(0, 0, Food.class) If(Greenfoot.isKeyDown("down") & direction !="up") If(Greenfoot.isKeyDown("up") & direction !="down") ![]() If(Greenfoot.isKeyDown("right") & direction !="left") If(Greenfoot.isKeyDown("left") & direction !="right") Playground playground = (Playground)getWorld() * the 'Act' or 'Run' button gets pressed in the environment. * Act - do whatever the Snake wants to do. Private int speed, speedX, speedY, length * Write a description of class Snake here. 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.Import greenfoot.* // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) 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. Indeed, that’s my problem at the moment as well, in all these different programs! 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. 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. And here we come to the argument between teaching things that are useful and/or interesting and things that will get a qualification! For a computer club, however, it would be great. ![]() 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). Indeed, for most of the assessment tasks a GUI is not necessary, and they could be built to use a console. 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. The game so far is already open to many variations, both in graphics and in behaviour, even at this early stage. 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.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |