Help with drawbox.... (i think thats the problem)
Author |
Message |
recneps
![](http://www.fcpocanada.com/canada1.gif)
|
Posted: Sat Dec 13, 2003 2:33 pm Post subject: Help with drawbox.... (i think thats the problem) |
|
|
am i just a newbie or can drawbox not use variables instead of numbers??
im making a pong program and here it is...
code: |
%position/direction variables
var x, y, dx, dy, score1, score2 : int
score1 := 0
score2 := 0
var midx : real := maxx * 0.5
var midy : real := maxy * 0.5
var p1x1, p1x2, p1y1, p1y2, p2x1, p2x2, p2y1, p2y2 : real
p1x1 := 0
p1x2 := 10
p1y1 := midy - 100
p1y2 := midy + 100
%clear screen
cls
%picture size
const pic_width := 10
const pic_height := 10
%set pos/dir variables
randint (x, 10, maxx - 10 - pic_width)
randint (y, 10, maxy - 10 - pic_height)
randint (dx, -3, 3)
randint (dy, -3, 3)
%smoother animation
setscreen ("offscreenonly")
%begin animation/gameplay
loop
cls
if x + dx < 0 or x + dx + pic_width > maxx then
dx := -dx %Change x direction if bounce
end if
if y + dy < 0 or y + dy + pic_height > maxy then
dy := -dy %change y direction if bounce
end if
x := x + dx %create the new positions
y := y + dy %create the new positions
drawoval (x, y, pic_width, pic_height, 7) %draw ball
%drawbox (p1x1, p1y1, p1x2, p1y2, 7)
View.Update %part of offscreenonly
delay (7)
exit when hasch
end loop
setscreen ("nooffscreenonly") %change screen back to normal
|
and it says error at
drawbox (p1x1, p1y1, p1x2, p1y2, 7)
"argument is wrong type". whats wrong with it? you can use viariables right? |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
AsianSensation
|
Posted: Sat Dec 13, 2003 3:11 pm Post subject: (No subject) |
|
|
drawbox doesn't take real numbers as it's parameters, make sure that either those coordinates are integers, or use
to round the real numbers into the closest integer, and then plug in the rounded value. |
|
|
|
|
![](images/spacer.gif) |
DanShadow
![](http://compsci.ca/v3/uploads/user_avatars/12142970654c996e83e6997.png)
|
Posted: Sat Dec 13, 2003 5:03 pm Post subject: (No subject) |
|
|
Hey AsianSensation...im having a problem that round could help with, could you private message me on how to use round in this situation:
code: |
var hp,maxhp:int:=20
var hp_percent:real:=0
hp_percent:=(hp/maxhp)*100
put "HP: ",hp,"/",maxhp," [",hp_percent,"%]"
|
If you can, thanks! |
|
|
|
|
![](images/spacer.gif) |
recneps
![](http://www.fcpocanada.com/canada1.gif)
|
Posted: Sat Dec 13, 2003 7:33 pm Post subject: how does round work? |
|
|
how does round work?
like
or what?[/code] |
|
|
|
|
![](images/spacer.gif) |
Tony
![](http://wiki.compsci.ca/images/f/f4/OniTony.gif)
|
Posted: Sat Dec 13, 2003 7:36 pm Post subject: (No subject) |
|
|
it's
code: |
round ( real value or expression that returns a real value )
|
Note: if you use division in your expression, then it will always return a real value, even if numbers divide evenly. |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
![](images/spacer.gif) |
DanShadow
![](http://compsci.ca/v3/uploads/user_avatars/12142970654c996e83e6997.png)
|
Posted: Sat Dec 13, 2003 8:30 pm Post subject: (No subject) |
|
|
Ah! I get it. So for me its like:
neat, tx |
|
|
|
|
![](images/spacer.gif) |
recneps
![](http://www.fcpocanada.com/canada1.gif)
|
Posted: Thu Dec 18, 2003 5:13 pm Post subject: thnx |
|
|
thanks that good to know in future, but since the boards were down for a bit (?) i figured out i could use div to give me whole numbers only ![Smile Smile](http://compsci.ca/v3/images/smiles/icon_smile.gif) |
|
|
|
|
![](images/spacer.gif) |
|
|