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

Username:   Password: 
 RegisterRegister   
 [Help] Yet Again, proc and Loops, and loops in loops
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
razrdude




PostPosted: Mon Oct 30, 2006 6:05 pm   Post subject: [Help] Yet Again, proc and Loops, and loops in loops

Hey well whoever's been following my posts, Ive now added ship movements and have the ship moving around, but now the problem is that the scope is being drawn once only and its not moving with the mouse. I know its cuz of the cls and View Image but I do not know how to fix it. Ill post my code here, but its better if you dl the file cuz there are images. Thanks a lot for all help.

btw I have to do these:
1. Get scope to show and moving
2. Collision Detection, ship gets blasted
3. Ship spawn
4. Parameters maybe.
5. Instructions and Documentation

code:
%The GUI contains the predefined subprograms for creating & using a Graphical
%User Interface
import GUI
%Setcreen creates a window, enters graphic mode, changes the window to 1000
%x600 and turns of the cursor
setscreen ("graphics:1000;600,nocursor")

%This variable is an integers and allow the scope to be drawn anywhere
var x, y, button : int
var mspace1 : int
var spaceship : int
spaceship := Pic.FileNew ("shipf.bmp")
var spacex, spacey : int
var background : int
background := Pic.FileNew ("background.bmp")

spacex := 450
spacey := 300
% this loop is used to randomly generate direction of movement for the space ship
procedure draw (x, y : int)

    View.Set ("offscreenonly")
    loop
        randint (mspace1, 1, 4)
        if mspace1 = 1 then
            spacey := (spacey + 50)
        else
            if mspace1 = 2 then
                spacex := (spacex - 50)
            else
                if mspace1 = 3 then
                    spacey := (spacey - 50)
                else
                    if mspace1 = 4 then
                        spacex := (spacex + 50)
                    end if
                end if
            end if
        end if
        Pic.Draw (spaceship, spacex, spacey, picUnderMerge)
        delay (300)
        View.Update
        cls
        Pic.Draw (background, 0, 0, picUnderMerge)

       
        %Scope casting
        Draw.FillOval (x, y, 55, 55, black)
        Draw.FillOval (x, y, 50, 50, white)

        %Thick crosshair threads
        Draw.ThickLine (x - 50, y, x - 35, y, 3, black)
        Draw.ThickLine (x + 50, y, x + 35, y, 3, black)
        Draw.ThickLine (x, y - 50, x, y - 35, 3, black)
        Draw.ThickLine (x, y + 50, x, y + 35, 3, black)

        %Thin threads
        Draw.Line (x - 20, y, x + 20, y, red)
        Draw.Line (x, y - 20, x, y + 20, red)
       
       
    end loop % this ends the loop of movement
end draw

loop
    Mouse.Where (x, y, button)
    draw (x, y)
   
end loop


If you want to test to see if the scope is being made, put ur mouse on the middle of the screen and press F1 (run).
Thanks
Sponsor
Sponsor
Sponsor
sponsor
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  [ 1 Posts ]
Jump to:   


Style:  
Search: