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

Username:   Password: 
 RegisterRegister   
 Pong Remake (Player2's Paddle won't show)
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
cptcool




PostPosted: Fri Mar 28, 2008 12:10 pm   Post subject: Pong Remake (Player2's Paddle won't show)

Hey, recently I have been trying to recreate the game pong and ran into some trouble showing the second player. I was wondering if someone would be so kind as to tell me what I did wrong. Help is appreciated.



Thanks in advance



Turing:


%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%PLAYER1%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%

View.Set("offscreenonly")



colourback (7)         



var x1, y1 : int                       
x1 := 50                               
y1 := 100
var chars1 : array char of boolean
loop
    Input.KeyDown (chars1)           
    if chars1 ('w') then
        y1 := y1 + 5
    end if


    if chars1 ('s') then
        y1 := y1 - 5
    end if

    drawfillbox (x1 - 10, y1, x1 + 10, y1 + 100, gray)   
    delay (10)                         
View.Update

 cls   

end loop
%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%PLAYER2%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%


var x2, y2 : int                   
x2 := 100                                 
y2 := 200
var chars2 : array char of boolean     
loop
    Input.KeyDown (chars2)           
    if chars2 ('8') then
        y2 := y2 + 5
    end if


    if chars2 ('5') then
        y2 := y2 - 5
    end if

    drawfillbox (x2 - 10, y2, x2 + 10, y2 + 100, gray)   
    delay (10)                         
View.Update
  cls

end loop


Sponsor
Sponsor
Sponsor
sponsor
michaelp




PostPosted: Fri Mar 28, 2008 3:04 pm   Post subject: RE:Pong Remake (Player2\'s Paddle won\'t show)

Since your loop for your player 1 loop is first, it stays in that loop and never reaches the second loop where player 2 is blitted onto the screen.
Sean




PostPosted: Fri Mar 28, 2008 4:17 pm   Post subject: Re: Pong Remake (Player2's Paddle won't show)

Use one major loop, and it will work fine, and you should see them clearly.
cptcool




PostPosted: Sat Mar 29, 2008 2:58 pm   Post subject: Re: Pong Remake (Player2's Paddle won't show)

Thanks for replying.


I tried using one loop for both the player paddles, but the new problem is that it is very flickery, and player 2 barely moves until he pops back into his spawn location. here is the syntax


Turing:


%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%PLAYER1%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%



View.Set("offscreenonly")



colourback (7)         



var x1, y1 : int                       
x1 := 50                               
y1 := 150
var chars1 : array char of boolean
loop
    Input.KeyDown (chars1)           
    if chars1 ('w') then
        y1 := y1 + 5
    end if


    if chars1 ('s') then
        y1 := y1 - 5
    end if

    drawfillbox (x1 - 10, y1, x1 + 10, y1 + 100, gray)   
    delay (10)                         
View.Update

 cls   


%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%PLAYER2%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%


var x2, y2 : int                   
x2 := 575                               
y2 := 150
var chars2 : array char of boolean     

    Input.KeyDown (chars2)           
    if chars2 ('o') then
        y2 := y2 + 5
    end if


    if chars2 ('l') then
        y2 := y2 - 5
    end if

    drawfillbox (x2 - 10, y2, x2 + 10, y2 + 100, gray)   
    delay (10)                         
View.Update
  cls

end loop
BigBear




PostPosted: Sat Mar 29, 2008 3:26 pm   Post subject: Re: Pong Remake (Player2's Paddle won't show)

You should take the variables for the second player out of the loop.
Also to removce the flashing just remove the first cls and View.Update.
Hope this helps.
cptcool




PostPosted: Sat Mar 29, 2008 3:45 pm   Post subject: Re: Pong Remake (Player2's Paddle won't show)

thank you very much for your help Smile
michaelp




PostPosted: Sat Mar 29, 2008 4:04 pm   Post subject: RE:Pong Remake (Player2\'s Paddle won\'t show)

No problem. Wink
Sean




PostPosted: Sat Mar 29, 2008 4:29 pm   Post subject: Re: Pong Remake (Player2's Paddle won't show)

You will need to set boundaries for your paddles, by checking it's y positions, just to ensure to doesn't float off the page.
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  [ 8 Posts ]
Jump to:   


Style:  
Search: