Small Glitches
Author |
Message |
jayman
|
Posted: Sat Apr 28, 2007 10:50 am Post subject: Small Glitches |
|
|
OKAY...sorry about asking for to much previously.
I created my box with my ball bouncing inside of it..i tried researching mousewhere..i managed to get a paddle going ..still a couple of glitches..
would like assistance in making my ball ..."O".... bounce of this paddle that im controlling with my mouse inside of the box...help/point me in some direction please!
-thanks |
|
|
|
|
|
Sponsor Sponsor
|
|
|
chrisbrown
|
Posted: Sat Apr 28, 2007 6:41 pm Post subject: RE:Small Glitches |
|
|
good for you for taking the initiative, but just so you will thoroughly hate me, for future reference, post in the thread you already started when asking for help on the same topic. As well, if you could put what you have done so far into code tags, ie: [*Code*]Code here[*/Code*] except without the *s. Serach the tutorial section for Collision Detection. I'd link, but I'm too lazy right now. |
|
|
|
|
|
jayman
|
Posted: Mon Apr 30, 2007 10:54 am Post subject: Re: Small Glitches What i HAVE SO FAR |
|
|
HERE IS MY CODE SO FAR
code: |
var x,y,oldx,oldy,b,r,c :int:=0
%BOX
for column :10..70
locate (6,column)
put "*"..
locate (20,column)
put "*"..
end for
for row :6..20
locate (row,10)
put "*"..
locate (row,70)
put "*"
end for
%THe bounce program
var row, column :int
put "ENter starting row from 8-20 "
get row
put "Enter Starting column from 12-70 "
get column
var rowChange, columnChange :=1
loop
mousewhere (x,y,b)
if b=1 then
Text.LocateXY(x,y)
r:= Text.WhatRow
c:=Text.WhatCol
Draw.Line(x,y-20,x,y+20,1)
Draw.Line(oldx,oldy-20,oldx,oldy+20,0)
oldy:=y
oldx:=x
loop
if row=19 or row=7 then
rowChange:=-rowChange
end if
if column=69 or column=11 then
columnChange:=-columnChange
end if
locate (row,column)
put "O"..
delay(50)
locate (row,column)
put " "..
row :=row+rowChange
column :=column+columnChange
exit when column=10 or column =70
end loop
end if
end loop
|
|
|
|
|
|
|
Drakain Zeil
|
Posted: Mon Apr 30, 2007 4:17 pm Post subject: RE:Small Glitches |
|
|
I can't tell by looking at your code what that last endif is for. press f2 and line it up.
Here is your code, but what are you asking? |
|
|
|
|
|
jayman
|
Posted: Mon Apr 30, 2007 7:32 pm Post subject: Re: Small Glitches |
|
|
ah something is still wrong with it..the paddle should be moving at the control of the mouse and whenever it 'hits' the ball the ball just changes direction..nothing else needed |
|
|
|
|
|
chrisbrown
|
Posted: Tue May 01, 2007 4:46 pm Post subject: RE:Small Glitches |
|
|
You've made a lot of trouble for yourself by trying to combine text and screen coordinates. When you use locatexy, you are using text-based rows and columns. Graphics commands like Draw.Line use pixel coordinates. What you need to do is use Draw.Oval instead of "O" or get really advanced with div and mod. I'd suggest the first. As well, if you remove the second loop inside the first, and remove if b = 1 and the end if that goes with it, you will see the paddle follow the mouse. |
|
|
|
|
|
jayman
|
Posted: Wed May 02, 2007 11:17 am Post subject: Re: Small Glitches |
|
|
THANKS FOR THE HELP SO FAR..VERY APPRECIATED..
so the paddle finally follows the ball..
having som difficulties understanding concept of making the ball appear to bounce with Draw.Oval... |
|
|
|
|
|
chrisbrown
|
Posted: Wed May 02, 2007 9:10 pm Post subject: RE:Small Glitches |
|
|
Good stuff so far. What you want to do is check if the ball's coordinates are close to the paddle's (if abs(ballx - paddlex) < 5) or something to that effect, then reverse the travel of the ball. It's the same concept as checking for wall collision. |
|
|
|
|
|
Sponsor Sponsor
|
|
|
jayman
|
Posted: Mon May 07, 2007 11:24 am Post subject: Re: Small Glitches |
|
|
OK new addition..i got my game working...now i would like the paddle to be controlled by the keyboard....any directions? |
|
|
|
|
|
program_x
|
Posted: Mon May 07, 2007 1:22 pm Post subject: Re: Small Glitches |
|
|
uh... maybe... i think something like....
code: |
var ch:array char of boolean
loop
if ch(KEY_ARROW_DOWN) then
%movedown
elsif(KEY_ARROW_UP) then
%move up
end if
|
dont exactly quote me on this, as i am pretty sure this is how its worded, but im sorry if its not... |
|
|
|
|
|
richcash
|
Posted: Mon May 07, 2007 1:27 pm Post subject: Re: Small Glitches |
|
|
@program_x: you forgot the Input.Keydown(ch). It should go in the loop before the if statements. |
|
|
|
|
|
|
|