Computer Science Canada Moving and Shooting at the same time |
| Author: | TheBboy [ Fri Dec 14, 2012 11:30 pm ] | ||
| Post subject: | Moving and Shooting at the same time | ||
What is it you are trying to achieve? I am try move the object and shoot another object at the same time. What is the problem you are having? If I don't press the shooting object first it would not work anymore. If I press it first it would work but then it would respond to any key, I want it so it would only respond to spacebar. Describe what you have tried to solve this problem I tired to look around the site for this solution could not find it. Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
Please specify what version of Turing you are using 4.1.1 |
|||
| Author: | Insectoid [ Sat Dec 15, 2012 10:03 am ] | ||
| Post subject: | RE:Moving and Shooting at the same time | ||
I'm sorry to tell you this, but you're going to have to completely restructure your program to make this work correctly. However, once you do that, all your future animations will be much easier and look much better. You should not be using processes for animations. That's your problem. Instead of doing one complete animation per process, you need to every animation in one procedure. It should look something like this:
|
|||
| Author: | TheBboy [ Sun Dec 16, 2012 4:25 am ] |
| Post subject: | Re: Moving and Shooting at the same time |
Is it possible to do it without boolean logic(by the way I am new to turing). What statements should I use? |
|
| Author: | Insectoid [ Sun Dec 16, 2012 10:06 am ] |
| Post subject: | RE:Moving and Shooting at the same time |
Of course you need boolean logic. There's not much you can do without it. Why would you want to avoid it? |
|
| Author: | TheBboy [ Sun Dec 16, 2012 12:30 pm ] |
| Post subject: | Re: Moving and Shooting at the same time |
Ok thanks for telling me. I asked beacuse I am new to programming in general. And at school my teacher didn't teach us about boolean. |
|
| Author: | TheBboy [ Tue Dec 18, 2012 6:49 am ] |
| Post subject: | Re: Moving and Shooting at the same time |
How do I stop my object from disappearing when I shoot The Code: var x, y, x1, y1 : int := 40 var key : array char of boolean procedure hi loop Input.KeyDown (key) % if key (KEY_UP_ARROW) then %up arrow y := y + 5 y1 := y1 + 5 end if if key (KEY_DOWN_ARROW) then %down arrow y := y - 5 y1 := y1 - 5 end if if key (KEY_LEFT_ARROW) then %left arrow x := x - 5 x1 := x1 - 5 end if if key (KEY_RIGHT_ARROW) then %right arrow x := x + 5 x1 := x1 + 5 end if if key (KEY_TAB) then%shooting for i : 1 .. 200 drawfilloval (x1, y1, 5, 5, purple) delay (10) drawfilloval (x1, y1, 5, 5, white) x1 := x1 + 5 end for end if drawfilloval (x, y, 10, 10, black) %object delay (50) drawfilloval (x, y, 10, 10, white) %clears the screen so it seems that the 'object' is moving end loop end hi hi |
|
| Author: | Insectoid [ Tue Dec 18, 2012 8:59 am ] | ||
| Post subject: | RE:Moving and Shooting at the same time | ||
This is your problem. What's the rest of your code doing while this bit is running? |
|||