Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Doing multiple things at once.
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Nitrix




PostPosted: Mon Jun 06, 2005 4:35 pm   Post subject: Doing multiple things at once.

Problem fixed.
Sponsor
Sponsor
Sponsor
sponsor
Cervantes




PostPosted: 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.
[Gandalf]




PostPosted: 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 Smile

If you don't already know them, you should read up on the difference between procedures and process'.
Nitrix




PostPosted: 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 Smile .
Cervantes




PostPosted: 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
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 5 Posts ]
Jump to:   


Style:  
Search: