
-----------------------------------
bgmrk
Fri Apr 07, 2006 5:46 pm

text help
-----------------------------------
i am trying to make pong game..however when i am using the font.Draw it won't let me put an integar variable....does it only allow int? or is it just strings?

Here is my code..you'll c the error when u try to run it...
setscreen ("graphics:500;500,nobuttonbar,nooffscreenonly")
%%%player
var boxx, width, score : int
var player : string
var chars : array char of boolean
boxx := maxx div 2 - 25
width := 50
%%ball
var x,y,dx,dy, radius : int
%board
var scorefont, playerfont,titlefont: int
titlefont:= Font.New ("Neuropol:24:Italic")
scorefont := Font.New ("Comic Sans MS:14:Bold")
playerfont := Font.New ("Baveuse:12")
%%program
loop
%put "Please enter your name: "..
%get player
cls
x:= maxx div 2
y := maxy div 2 - 50
dx := 1
dy := 1
radius := 5
score := 0
loop
%bord
drawbox (0,maxy - 50,maxx,0,black)
Font.Draw ("Pong",maxx div 2 - 50,maxy-24,titlefont,red)
Font.Draw ("Score:",50, maxy - 38, scorefont, green)
Font.Draw ("Player:",maxx - 175,maxy - 38,playerfont,blue)
Font.Draw (score, 100,maxy - 38, scorefont, green)
%ball
drawfilloval (x,y,radius,radius,black)

end loop
end loop


quick help would b very grateful

thanx

-----------------------------------
Cervantes
Fri Apr 07, 2006 5:53 pm


-----------------------------------
Font.Draw takes a number of parameters, the first of which is the text it wants to draw. The text is a string. It cannot be an integer.

To draw an integer, you have to convert it's value into a string. 5 would convert into "5". To do this, use the intstr function.


var num := 5
Font.Draw (intstr (num), 100, 100, Font.New ("Times New Roman:12"), black)


-----------------------------------
bgmrk
Fri Apr 07, 2006 6:27 pm


-----------------------------------
thanks that helped...but i ran into another problem :)

i don't want to use cls and draw everything over because that will take to long..so i figure why not draw a white box over where i want to refresh the screen however i'm not quite sure how to make it non flikery...any suggestions


setscreen ("graphics:500;500,nobuttonbar,nooffscreenonly")
%%%player
var boxx, width, score : int
var player : string
var chars : array char of boolean
boxx := maxx div 2 - 25
width := 50
%%ball
var x,y,dx,dy, radius : int
%board
var scorefont, playerfont,titlefont: int
titlefont:= Font.New ("Neuropol:24:Italic")
scorefont := Font.New ("Comic Sans MS:14:Bold")
playerfont := Font.New ("Baveuse:12")
%%program
loop
put "Please enter your name: "..
loop
get player
if length (player) > 6 then
put "Please enter a name 6 letters or less"
end if
exit when length (player)  maxx - radius - 2 or x < radius + 2 then
dx := -dx
end if
if y > maxx - 52 - radius or y < radius + 2then
dy := -dy
end if
View.Update
end loop
end loop


-----------------------------------
Cervantes
Fri Apr 07, 2006 6:33 pm


-----------------------------------
You'll want to be using View.Update.



setscreen ("graphics:500;500,nobuttonbar,nooffscreenonly")


Why are you turning 'offscreenonly' mode off? It needs to be on for View.Update to work.

-----------------------------------
bgmrk
Fri Apr 07, 2006 6:35 pm


-----------------------------------
opps that was a stupid mistake....thanx..i may need more help so if i do..instead of jsut making a new topic..i'll just post it here :)
thanx again

-----------------------------------
[Gandalf]
Fri Apr 07, 2006 7:02 pm


-----------------------------------
If you're only update one section of the screen, and speed is so important to you, you may also consider using View.UpdateArea(), which only updates a portion of the screen instead of the whole:
View.UpdateArea (x1, y1, x2, y2)

-----------------------------------
bgmrk
Fri Apr 07, 2006 8:03 pm


-----------------------------------
oo good point i never thought of that....:) :!:
