Doing multiple things at once.
Author |
Message |
Nitrix
|
Posted: Mon Jun 06, 2005 4:35 pm Post subject: Doing multiple things at once. |
|
|
Problem fixed. |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
Cervantes
![](http://compsci.ca/v3/uploads/user_avatars/1023105758475ab2e040bde.jpg)
|
Posted: Mon Jun 06, 2005 4:57 pm Post subject: (No subject) |
|
|
Looks like you've got the code you would use for a process, only you've switched to procedures. Think about how this works. You get to your main loop, clear the screen, then go into your draw_BG procedure, in which you go into an infinate loop. Thus, nothing else will ever happen, because you're in that loop forever.
We need to change some things:
Turing: |
const NPC_Vgr_Interceptor_speed := 30
var Map1 : int := Pic.FileNew ("testbg.bmp")
var Vgr_Interceptor : int := Pic.FileNew ("Vaygr_Interceptor.bmp")
var Y : int := 510
var X : int := 320
var offset : int := 0
var scroller : int := 0
setscreen ("graphics:nocursor:640;500")
loop
scroller - = 10
randint (offset, - 20, 20)
X := X + offset
Y := Y - NPC_Vgr_Interceptor_speed
cls
Pic.Draw (Map1, 0, scroller, picCopy)
Pic.Draw (Vgr_Interceptor, X, Y, picMerge)
View.Update
delay (50)
end loop
|
I got rid of the procedures because they were essentially one line of code each, or at least they should have been. You had drawing procedures, and yet the code in them was to do things like adjust the position of the objects and View.Update. That's not drawing. |
|
|
|
|
![](images/spacer.gif) |
[Gandalf]
![](http://compsci.ca/v3/uploads/user_avatars/189297994e4c716fec7f1.png)
|
Posted: Mon Jun 06, 2005 5:46 pm Post subject: (No subject) |
|
|
I see you are using your ship name, and possibly the actual ship from Homeworld
If you don't already know them, you should read up on the difference between procedures and process'. |
|
|
|
|
![](images/spacer.gif) |
Nitrix
|
Posted: Mon Jun 06, 2005 5:47 pm Post subject: (No subject) |
|
|
I took out the cls(big flickers) at the end of the program and it everything ran nicely. However for things like shooting,collision detection, and key input will still be procedures? or will they just be coded into the loop?
Oh and yes, I am using ships from Homeworld 2 . |
|
|
|
|
![](images/spacer.gif) |
Cervantes
![](http://compsci.ca/v3/uploads/user_avatars/1023105758475ab2e040bde.jpg)
|
Posted: Mon Jun 06, 2005 8:56 pm Post subject: (No subject) |
|
|
Whether you use procedures or not is up to you. I find them to be a nice way to add organization to your program; even if you don't use any parameters with them, I find them to be useful. Really though, it's up to you. ![Smile Smile](http://compsci.ca/v3/images/smiles/icon_smile.gif) |
|
|
|
|
![](images/spacer.gif) |
|
|