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

Username:   Password: 
 RegisterRegister   
 Help with View.Update
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
neufelni




PostPosted: Wed Jun 08, 2005 11:06 am   Post subject: Help with View.Update

How can you use View.Update so that it does not slow everything down? I am making a game and need to use View.Update but it is slowing everything down.
Sponsor
Sponsor
Sponsor
sponsor
jamonathin




PostPosted: Wed Jun 08, 2005 11:26 am   Post subject: (No subject)

Send your code over, because you only need View.Update one (most of the time), and you could possibly have something else slowing it down. So, send ur code over, and if ur gonan send pics too, zip it or rar it, please and thank you.
neufelni




PostPosted: Wed Jun 08, 2005 1:09 pm   Post subject: (No subject)

jamonathin wrote:
Send your code over, because you only need View.Update one (most of the time), and you could possibly have something else slowing it down. So, send ur code over, and if ur gonan send pics too, zip it or rar it, please and thank you.


Here is my code, with View.Update in it. The ball and the paddle moved much faster when I did not have it in there, but I need it to get the paddle to stop flickering as much. Please help.

[code]
View.Set ("graphics: max; max, nocursor, nobuttonbar, offscreenonly")
colourback (black)
cls

var x : int := 250
var x2 : int := 300
var y : int := 100
var speed : int := 5
var x3, y3 : int := 1
var paddleinput : array char of boolean

Draw.FillBox (0, 0, 40, maxy, 46)
Draw.FillBox (0, maxy, maxx - 400, maxy - 40, 46)
Draw.FillBox (maxx - 400, maxy, maxx - 440, 0, 46)
Draw.FillBox (75, maxy - 200, 200, maxy - 220, 100)
Draw.FillBox (125, maxy - 160, 145, maxy - 260, 100)

loop
Draw.FillOval (x2, y, 10, 10, 7)
x2 += x3
y += y3
Draw.FillOval (x2, y, 10, 10, Rand.Int (1, 93))
delay (speed)
if x2 + 11 = maxx - 440 or x2 - 11 = 40 then
x3 := x3 * -1
elsif y + 11 = maxy - 40 then
y3 := y3 * -1
elsif y - 11 = 65 and x2 > x and x2 < x + 100 then
y3 := y3 * -1
elsif x2 - 11 = 200 or x2 + 11 = 75 and y > maxy - 260 and y < maxy - 160 then

end if

Draw.FillBox (x, 50, x + 100, 65, 14)
Input.KeyDown (paddleinput)
if paddleinput (KEY_RIGHT_ARROW) and x + 101 < maxx - 440 then
Draw.FillBox (x, 50, x + 100, 65, 7)
x := x + 1
delay (1)
elsif paddleinput (KEY_LEFT_ARROW) and x - 1 > 40 then
Draw.FillBox (x, 50, x + 100, 65, 7)
x := x - 1
delay (1)
end if
exit when y = 0
View.Update
end loop
[\code]
jamonathin




PostPosted: Wed Jun 08, 2005 1:10 pm   Post subject: (No subject)

Well, you weren't using View.Update properly, but thats not why it was slowing down. View.Update slows anything down, face it. So we work on everything else. You're moving everything by 1 pixel at a time, change it! use 2,3 or 7 pixels at a time.
Also, dont draw black overtop of what you're drawing, just redraw everything.

Don't use x = 100 or anything thing like that, use x >=100 or x <=100.

use only 1 delay in your program, and that delay goes right after your View.Update.

Everything I told you is in your program. Except for this.
Since your + shape is a little retarted, it would make collision difficult using co-ordinates. I suggest using whatdotcolor, or looking up the collision tutorial in the tutorial section

Anwyays, here's your code

code:
View.Set ("graphics: max; max, nocursor, nobuttonbar, offscreenonly")
colourback (black)
cls

var x : int := 250
var x2 : int := 300
var y : int := 100
var speed : int := 5
var x3, y3 : int := 3
var paddleinput : array char of boolean

loop
    cls
    Draw.FillBox (0, 0, 40, maxy, 46)
    Draw.FillBox (0, maxy, maxx - 400, maxy - 40, 46)
    Draw.FillBox (maxx - 400, maxy, maxx - 440, 0, 46)
    Draw.FillBox (75, maxy - 200, 200, maxy - 220, 100)
    Draw.FillBox (125, maxy - 160, 145, maxy - 260, 100)
    x2 += x3
    y += y3
    Draw.FillOval (x2, y, 10, 10, Rand.Int (1, 93))

    if x2 + 11 >= maxx - 440 or x2 - 11 <= 40 then
        x3 := x3 * -1
    elsif y + 11 >= maxy - 40 then
        y3 := y3 * -1
    elsif y - 11 <= 65 and x2 >= x and x2 <= x + 100 then
        y3 := y3 * -1
    elsif x2 - 11 >= 200 or x2 + 11 <= 75 and y >= maxy - 260 and y <= maxy - 160 then

    end if
    Input.KeyDown (paddleinput)
    if paddleinput (KEY_RIGHT_ARROW) and x + 101 < maxx - 440 then
        x += 3
    elsif paddleinput (KEY_LEFT_ARROW) and x - 1 > 40 then
        x -= 3
    end if
    Draw.FillBox (x, 50, x + 100, 65, 14)
    exit when y = 0
    View.Update
    delay (speed)
end loop
syphon4




PostPosted: Wed Jun 08, 2005 2:14 pm   Post subject: View.Update

your placement of your View.Update was the onlt thing wrong here this is what you want....

code:
View.Set ("graphics: max; max, nocursor, nobuttonbar, offscreenonly")
colourback (black)
cls

var x : int := 250
var x2 : int := 300
var y : int := 100
var speed : int := 5
var x3, y3 : int := 1
var paddleinput : array char of boolean

Draw.FillBox (0, 0, 40, maxy, 46)
Draw.FillBox (0, maxy, maxx - 400, maxy - 40, 46)
Draw.FillBox (maxx - 400, maxy, maxx - 440, 0, 46)
Draw.FillBox (75, maxy - 200, 200, maxy - 220, 100)
Draw.FillBox (125, maxy - 160, 145, maxy - 260, 100)

loop
    Draw.FillOval (x2, y, 10, 10, 7)
    x2 += x3
    y += y3
    Draw.FillOval (x2, y, 10, 10, Rand.Int (1, 93))
    View.Update
    delay (speed)
    if x2 + 11 = maxx - 440 or x2 - 11 = 40 then
        x3 := x3 * -1
    elsif y + 11 = maxy - 40 then
        y3 := y3 * -1
    elsif y - 11 = 65 and x2 > x and x2 < x + 100 then
        y3 := y3 * -1
    elsif x2 - 11 = 200 or x2 + 11 = 75 and y > maxy - 260 and y < maxy - 160 then

    end if

    Draw.FillBox (x, 50, x + 100, 65, 14)
    Input.KeyDown (paddleinput)
    if paddleinput (KEY_RIGHT_ARROW) and x + 101 < maxx - 440 then
        Draw.FillBox (x, 50, x + 100, 65, 7)
        x := x + 1
        delay (1)
    elsif paddleinput (KEY_LEFT_ARROW) and x - 1 > 40 then
        Draw.FillBox (x, 50, x + 100, 65, 7)
        x := x - 1
        delay (1)
    end if
    exit when y = 0
end loop
[Gandalf]




PostPosted: Wed Jun 08, 2005 3:31 pm   Post subject: (No subject)

Quote:
your placement of your View.Update was the onlt thing wrong here this is what you want....

No, jamonathin's code is what you really want, yours doesn't work properly. Maybe look up a tutorial on View.Update.
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  [ 6 Posts ]
Jump to:   


Style:  
Search: