
-----------------------------------
triumph
Sat Apr 23, 2005 7:12 pm

Help in animation
-----------------------------------
Could someone help me with some quick questions that I run into along the way? I don't want to bother the entire forums for simple things (I am a amateur TURING user) and I keep running into little things along the way while trying to complete a school project. I by no means want anyone to do this for me, or even to send me any code I just know I could do this alot faster when someone can answer me a very simple question instead of messing around for several hours trying to do it myself.

If anyone would be so kind please reply here or PM me and i'll msg you my MSN / AIM.

Thanks!

-----------------------------------
jamonathin
Sat Apr 23, 2005 7:20 pm


-----------------------------------
Don't worry about bothering.  If a mod thnks it's useless they'll dispose of it.  besides, it could help someone else out.

-----------------------------------
Cervantes
Sat Apr 23, 2005 7:33 pm


-----------------------------------
The question here is how small are these questions?  If they are really small, you probably won't be asking such questions for long.  :wink:

I'll leave the judgement up to you.  You can either post the questions on the board, or ask someone via MSN.  Feel free to ask me.  Check the MSN button for my e-mail address.  (And yes, that's the e-mail address I use for msn)

-----------------------------------
jamonathin
Sat Apr 23, 2005 7:39 pm


-----------------------------------
do all mods use @compsci.ca? cuz im sick of hotmail  :boom:

-----------------------------------
Cervantes
Sat Apr 23, 2005 7:52 pm


-----------------------------------
No, we use whatever we want.  If you want a compsci email, amass 2500 bits.  If you want an email somewhere other than hotmail, you can get gmail. PM if you want it.  

Now, let's get back to the topic of waiting for triumph to ask his questions.  :P

-----------------------------------
triumph
Sat Apr 23, 2005 10:51 pm


-----------------------------------
jamonathin helped me out with this earlier but my computer restarted out of nowhere in the middle of my program and I lost the peice of code he sent me.

I am trying to make it so the ovals  bounce off the walls when they hit the given parameters. I  am attempting something like this:




  if xball >= maxx then 
    xball := -1 
    end if 


xball being the x coordinate variable for  drawoval. I am just learning when it comes to turing :(  When jamonathin helped me I realised you had to use two variables, but I was also wondering... am I going to have to set paramters for each side so the ovals constantly bounce off everything they hit? (By the way, I am trying to make a single "scene" to a screen saver)

Thanks for your help.

-----------------------------------
Bacchus
Sun Apr 24, 2005 12:10 am


-----------------------------------
youd want to multiply it by -1 not set it to that
x:=x*-1 basically

-----------------------------------
Cervantes
Sun Apr 24, 2005 7:42 am


-----------------------------------
if you want to make the ball bounce off the wall, you have to reverse it's velocity.  Assuming it hits the right or left wall, we reverse it's velocity in the x plane.

if ballX - ballRadius = maxx then
    ballVelocityX *= -`
end if


If you want to move it to the other side of the screen:

if ballX - ballRadius = maxx then
    ballX -= maxx
end if


-----------------------------------
triumph
Sun Apr 24, 2005 10:58 am


-----------------------------------
I still cannot get it.

I replaced all my x,y radius' with the variable "ballradius" I put in the if statements and they still just fly off the screen.

  if xball - ballradius = maxx then
        ballvelocityx *= -1 
    end if
    
    if yball - ballradius = maxx then
        ballvelocityy *= -1
    end if

Whoa, I'm sorry ... I really suck at this  :?

-----------------------------------
shlitiouse
Sun Apr 24, 2005 11:35 am


-----------------------------------
Hmmmm, I'm by no means the best programmer around here, and I'm fairly new to it myself, but PM me your e-mail (MSN) and I'll be willing to help out with any questions you have, could be fun to have someone to work out a problem with.

-----------------------------------
Cervantes
Sun Apr 24, 2005 11:56 am


-----------------------------------
Are you using the ball's x and y velocities to update the ball's x and y positions?


xball += ballvelocityx
yball += ballvelocityy


Also, you should be using maxy in your second if statement, not maxx.

-----------------------------------
triumph
Sun Apr 24, 2005 1:25 pm


-----------------------------------
Let me just post my entire code up and tell me what I have done wrong.


%=============================================
% Variables for Scene 1
%=============================================
var xball, yball : int := 1
var ballcolor1 : int := 1
var ballcolor2 : int := 60
var ballradius : int := 40
var ballvelocityx : int := 1
var ballvelocityy : int := 1
%=============================================
setscreen ("graphics:max,max")
%=============================================
loop

    drawoval (xball + 10, yball + 150, ballradius, ballradius, ballcolor1)
    



    drawoval (xball + 20, yball + 30, ballradius, ballradius, ballcolor1)
  



    drawoval (xball + 30, yball + 250, ballradius, ballradius, ballcolor1)
  

    drawoval (xball + 30, yball + 350, ballradius, ballradius, ballcolor1)
  



    drawoval (xball + 130, yball + 30, ballradius, ballradius, ballcolor1)
    

    %=========================
   if xball - ballradius = maxx then 
        ballvelocityx *= -1 
    end if 
    
    if yball - ballradius = maxy then 
        ballvelocityy *= -1 
    end if

    %=========================




    xball := xball + 10
    yball := yball + 10
    
    ballcolor1 := ballcolor1 + 1
    ballcolor2 := ballcolor2 - 1
    xball += ballvelocityx
    yball += ballvelocityy

    delay (50)


    if ballcolor1 >= 225 then
        ballcolor1 := 1
    end if
    if ballcolor2 = maxy + 20







    cls
end loop
%===============================================


-----------------------------------
Cervantes
Sun Apr 24, 2005 4:44 pm


-----------------------------------
Let me just post my entire code up and tell me what I have done wrong.

No.  You can fix this yourself, and it will benefit you more if you do it, as opposed to us doing it for you.

For the moment, I would recommend only using one ball.  If you want more later, you should look into arrays.  But for now, just go with one.  
Why are you adding ten to the ball's x and y position each time through the loop?  Also, I would think carefully about the starting position of your ball.

-----------------------------------
triumph
Sun Apr 24, 2005 5:34 pm


-----------------------------------
The + 10 every time through the loop is so it updates it's position....? I didn't want you to do it for me if I wanted that I wouldn't of spent 3 and a half hours messing around with it. 

I'll keep at it.

-----------------------------------
Cervantes
Sun Apr 24, 2005 6:18 pm


-----------------------------------
Do you really want to move the balls ten pixels up and ten pixels right each time through the loop, forever and ever?  Seems to me that wouldn't allow you to make the balls bounce off the edges of the screen... :think:

-----------------------------------
triumph
Sun Apr 24, 2005 6:40 pm


-----------------------------------
It seems I have alot to learn. That's the only way I learned how to move objects. Our teacher (student teacher) teaches us nothing. He tells us to use the "help menu" for everything.

So basically it's all on your own.

-----------------------------------
jamonathin
Mon Apr 25, 2005 6:03 am


-----------------------------------
Also, pay attention to what you're changing in your if statements?  is it the xball := xball + 10, or is it the velocityx?  Whatever you're changing, is what should be moving the ball, and for right now, the only thing moving the ball.

-----------------------------------
triumph
Mon Apr 25, 2005 6:57 am


-----------------------------------
Where do you put the ballvelocity variable within this line:

drawoval (xball + 10, yball + 150, ballradius, ballradius, ballcolor1) 
    

I don't see where this "direction/speed" variable is inserted so it makes a difference within the code...

-----------------------------------
jamonathin
Mon Apr 25, 2005 8:52 am


-----------------------------------
nowhere, you add the ball velocity to the xball and yball.  

Hint:  The velocities should be 10 (or however speed) also.

-----------------------------------
triumph
Mon Apr 25, 2005 10:48 am


-----------------------------------
I got help from someone in my programming class and it worked out alot better.

Thanks anyways,
