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

Username:   Password: 
 RegisterRegister   
 Making my ball move + collision (for collision, possibly give a tutorial link?)
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Velocity




PostPosted: Wed Dec 07, 2011 9:42 pm   Post subject: Making my ball move + collision (for collision, possibly give a tutorial link?)

What is it you are trying to achieve?
I want to make my ball move and i want to make it so that it bounces of my paddle and if it hits the side walls then it will also bounce of them in the correct angle.

What is the problem you are having?
I dont know anything in collision and i have no idea how to make my ball hit the paddle and bounce off it, or even how to make the ball move overall.


Describe what you have tried to solve this problem
I tried whatever i implemented into my program at the end... it runs but it doesnt do anything.


Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
All the relevant code is in the syntax.

Turing:


%Ilan Portman
%Grade 11 Final Project
%Brick Breaker vs AI
%December 7th, 2011
setscreen ("graphics:1024;950, nobuttonbar")
%---------------------------
%Player Co-ords          %
var x1, y1, x2, y2 : int  %
x1 := 250                    %
y1 := 25                      %
x2 := 350                    %
y2 := 50                      %
%---------------------------

%---------------------------
%Ball Co-ords             %
var ballx, bally : int      %
ballx := 512                %
bally := 200                %
%---------------------------

%----------------------------------------
%Game Basics                            %
var lives : int := 3                       %
var score : int := 0                      %
%Filler                                        %
%----------------------------------------

var arrowKeys : array char of boolean

loop
    Input.KeyDown (arrowKeys)

    if arrowKeys (KEY_RIGHT_ARROW) then
        x1 := x1 + 5
        x2 := x2 + 5
    end if
    if arrowKeys (KEY_LEFT_ARROW) then
        x2 := x2 - 5
        x1 := x1 - 5
    end if

    drawfillbox (x1, y1, x2, y2, red)
    delay (10)
    cls
    drawfillbox (250, 900, 350, 925, 101)
    drawfillbox (0, 457, 1050, 462, 51)
    drawfilloval (ballx, bally, 15, 15, 48)
end loop

if ballx >= 0 then
    ballx -= 5
end if
for ballxRange : 0 .. 800
    if ballx = ballxRange and bally < 1 then
        lives -= 1
    end if
end for
View.UpdateArea (0, 0, maxx, maxy)



Please specify what version of Turing you are using
4.1.1a
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Wed Dec 07, 2011 10:00 pm   Post subject: RE:Making my ball move + collision (for collision, possibly give a tutorial link?)

Turing Walkthrough links to a collision detection tutorial, but there are others if you search for them too.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Velocity




PostPosted: Wed Dec 07, 2011 10:05 pm   Post subject: RE:Making my ball move + collision (for collision, possibly give a tutorial link?)

thanks tony Smile and what about making my ball move :DDD
Insectoid




PostPosted: Wed Dec 07, 2011 10:07 pm   Post subject: RE:Making my ball move + collision (for collision, possibly give a tutorial link?)

...also in the Turing Walkthrough. There are dozens of tutorials on making things move. There are dozens of threads in the help section asking this same question.
Velocity




PostPosted: Wed Dec 07, 2011 10:19 pm   Post subject: RE:Making my ball move + collision (for collision, possibly give a tutorial link?)

I dont see the tutorial on making a ball move on there? and my math isnt too good :O i dont really understand how to tell the computer that if the x1 co-ord of the paddle hits the (0,0) co-ords of the screen, how do i make that the end zone and the same thing for y1 ... please explain Smile
Tony




PostPosted: Wed Dec 07, 2011 10:34 pm   Post subject: RE:Making my ball move + collision (for collision, possibly give a tutorial link?)

http://www.google.ca/search?q=site%3Acompsci.ca%2Fv3+intitle%3Amove
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Velocity




PostPosted: Wed Dec 07, 2011 10:41 pm   Post subject: RE:Making my ball move + collision (for collision, possibly give a tutorial link?)

thanks
Velocity




PostPosted: Wed Dec 07, 2011 10:42 pm   Post subject: RE:Making my ball move + collision (for collision, possibly give a tutorial link?)

so pretty much

if ball_x1 > 5
ball_x1 += 5
end if

?
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Wed Dec 07, 2011 10:49 pm   Post subject: RE:Making my ball move + collision (for collision, possibly give a tutorial link?)

I don't know. What do you think the above does?
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Velocity




PostPosted: Wed Dec 07, 2011 11:08 pm   Post subject: RE:Making my ball move + collision (for collision, possibly give a tutorial link?)

excuse my stupidity and thanks 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  [ 10 Posts ]
Jump to:   


Style:  
Search: