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

Username:   Password: 
 RegisterRegister   
 my enemy plane wouldnt shoot laser, help
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
yingmu




PostPosted: Sat Jun 11, 2005 10:09 am   Post subject: my enemy plane wouldnt shoot laser, help

heres my code, my enemy planeflys fine, but it wont "drop" a laser, plz help

code:

var x1,y1,x2: int:= 0
var y2:= maxy
var counter: int:= 1
var laserx1,lasery1,laserx2,lasery2:= 0
 
setscreen ("offscreenonly")
randint (x2,0,maxx)

loop
cls
x1:= x2-20
y1:= y2-20
drawfillbox (x1,y1,x2,y2,7)
if counter = 1 then
laserx2:= x1
lasery2:= y1
laserx1:= laserx2-5
lasery1:= lasery2-3
drawfillbox (laserx1,lasery1,laserx2,lasery2,7)
end if
if counter=0 then
laserx2+= 3
lasery2+= 3
laserx1:= laserx2+5
lasery1:= lasery2+3
drawfillbox (laserx1,lasery1,laserx2,lasery2,7)
end if
if (x1+x2)div 2 > maxx div 2 then
    x1-=1
    x2-=1
elsif (x1+x2) div 2 < maxx div 2 then
    x1+=1
    x2+=1
end if
y2-= 1
y1-= 1
counter:= 0
exit when y1 = 0
View.Update
end loop
   
       
Sponsor
Sponsor
Sponsor
sponsor
Cervantes




PostPosted: Sat Jun 11, 2005 10:53 am   Post subject: (No subject)

Hi.
Please, indent and comment your code before you post it. It makes helping you a lot easier.

The thing is, your "laser" is drawn. The problem is that it goes offscreen really, really soon after. Try adding a delay, and you'll see it breifly. Try making it so the "laser" goes down the screen, not up, and you'll see it.
It would be helpful for you to learn arrays, records, and then flexible arrays. That way, you can create laser/bullet objects. That would make creating multiple bullets/lasers easy, so the plane can shoot more than one thing at a time. You could even give it a machine gun type weapon. Smile

Check out the Turing Walkthrough.
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  [ 2 Posts ]
Jump to:   


Style:  
Search: