![]() All the conditional “if” statements have been coded already, you just need to write the code inside these blocks. Work through them the same way as before, looking for a method that may be suitable in the MotherShip class, before implementing it in your code. So open up the Ship class again, then look at the other points where you need to write code. However, as you have probably noticed, we're far from finished yet. Go back to the scenario window and test to ensure that the code you just entered behaves as you would want it to. So make the appropriate method call to move the ship left when the user holds down the left arrow. See anything useful there? Try and look for something that matches the English description of what you came up with earlier. Now scroll down until you see something like this: If not, open up MotherShip in the editor and select documentation view if you haven't already. If you poked around before in the documentation view of MotherShip, you might have some idea. So what code do we use to get the ship to do this? When the left key is held down, the ship should – move left? Sounds about right. ![]() We clearly need to put some code in here, but what? Well to start with, in plain English, think of what you want the Ship to do. This code is essentially saying, if the left key is held down, then execute the code in the curly braces. So let's start off by looking at the first bit of code we need to modify: To start with, let's get the ship doing what we want. We'll have to do something about that, so let's get started! Stage 2 – Adding functionality to the Ship After doing this, you should see that apart from the aliens shooting you every so often, not a lot happens! You can't shoot aliens by any means, the aliens don't move, you can't move, the score stays at 0 and the game never ends. Next, let's take a look at what the scenario does already. To switch from the source code view to the documentation view, look at the drop down box in the top right of the editor: Don't be put off if you don't understand the code, but it might be helpful for later to poke around in the Documentation view of some of the classes. You might also want to open up some of the classes and have a look at them. Here it should tell you the name of the project, the date it was written, the author, and it also tells you you need to follow a worksheet. With any scenario, it's often a good idea to look at the information that's provided – so click on the “Scenario Information" button. Once you have the scenario loaded into Greenfoot, compile all on the scenario to see the skeletal version of the game.īefore you dive into anything, spend a while familiarising yourself with the Greenfoot environment and the scenario. If you are working from home, you can get the space-invaders scenario from here. If you do not remember how to do this, refer back to Lab 1. The scenario is located in: /eng/class/notes/cse113/space-invaders. If you are working in the lab, you will need to copy the scenario directory to your home directory. The same problems occur if you are working in Bell 101 and you should use these instructions there as well. It's been half written, but it's up to you to finish it off and get it all working.ĭue to the problems we have been experiencing in Bell 340 with the keyboard and Greenfoot, we are asking that all students follow these directions for starting Greenfoot until further notice. Near enough everyone has heard of Space Invaders, since its first arrival 30 years ago it's been remade and rewritten an almost uncountable number of times. ![]() If I typed: s2g.py Terraheads (no arrow parenthesis around Terraheads) I got no syntax errors but it said “NameError: name ‘s2g’ is not defined” I have all of the files that the ReadMe file instructed in the ScratchFoot Master File.Are you in the command line or the Python interactive interpreter? The error message sounds like the latter.Lab 2 CSE 113 - Fall 2009 - Announcements Space Invaders Or wihout “python”: s2g.py Which gave me a syntax error under “”. Okay so what I typed was: python s2g.py which gave me a “Synta圎rror: invalid syntax” syntax error under ‘s2g.py’. ![]() $ cd path/to/files $ python sg2.py Terraheads2.sb2 TerraheadsReplace “path/to/files” with the actual location to the folder that contains Terraheads2.sb2īookOwl wrote:Can you copy and paste the whole error message? That would help a lot with figuring out what is wrong.First off I have no Idea how to program in python.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |