Computer Science Canada

Turing Animation Trail

Author:  ofcourseitsdan [ Fri Apr 13, 2012 9:31 am ]
Post subject:  Turing Animation Trail

What is it you are trying to achieve?
I am trying to make brickbreaker


What is the problem you are having?
The ball leaves a trail, even with me updating the screen

Describe what you have tried to solve this problem
I've tried the View.Update and View.UpdateArea


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


Turing:

% % % % % % % % % % % % % % % % % % %
% % % % % % Brick Breaker % % % % % %
% % % % % % By % % % % % %% % % % % %
% % % % % % % % % % % % % % % % % % %

import "Collision.tu"

setscreen ("nobuttonbar,graphics:320;240,offscreenonly,position:center;center,title:Brick Breaker")

% Constants %
const BALL_WIDTH := 5
const BALL_LENGTH := 5

const PADDLE_LENGTH := 10
const PADDLE_WIDTH := 50

const DELAY := 10

% Variables %
var background : int
var chars : array char of boolean
var font : int := Font.New ("Agency FB:20")

var score : int := 0
var ammo : int := 0
var lives : int := 3
var highscore : int := 0

var x : int := 17
var y : int := 0
var x2 : int := 220
var y2 : int := 213

var ball_x : int := 20
var ball_y : int := 20
var ball_vx : int := 1
var ball_vy : int := 1

% Procedures %
procedure Graphics
    background := Pic.FileNew ("background.jpg")
    Pic.Draw (background, 0, 0, picXor)
end Graphics

procedure Draw_Ball (x1, y1 : int)
    Draw.FillOval (x1, y1, BALL_WIDTH, BALL_LENGTH, black)
end Draw_Ball

procedure Scores (score, ammo, lives : int)
    Draw.Text (intstr (score), 270, 162, font, black)     % Score
    Draw.Text (intstr (ammo), 270, 110, font, black)      % Ammo
    Draw.Text (intstr (lives), 270, 60, font, black)      % Lives
end Scores

% Main Execution %
Graphics

loop
    Scores (score, ammo, lives)

    ball_x := ball_x + ball_vx
    ball_y := ball_y + ball_vy

    if ball_x = x or ball_x = x2 then
        ball_vx := -ball_vx
    end if

    if ball_y = y or ball_y = y2 then
        ball_vy := -ball_vy
    end if

    Draw_Ball (ball_x, ball_y)

    % View.UpdateArea (x, y, x2, y2)
    View.Update
    Time.DelaySinceLast (DELAY)
end loop



Please specify what version of Turing you are using
4.1.1

Author:  Raknarg [ Fri Apr 13, 2012 11:44 am ]
Post subject:  RE:Turing Animation Trail

You need to include a cls somewhere in there.


: