This is an archived, read-only copy of the United-TI subforum , including posts and topic from May 2003 to April 2012. If you would like to discuss any of the topics in this forum, you can visit Cemetech's TI-BASIC subforum. Some of these topics may also be directly-linked to active Cemetech topics. If you are a Cemetech member with a linked United-TI account, you can link United-TI topics here with your current Cemetech topics.

This forum is locked: you cannot post, reply to, or edit topics. TI-Basic => TI-BASIC
Author Message
Awesome1


Advanced Member


Joined: 28 Jan 2004
Posts: 269

Posted: 25 May 2004 06:57:45 pm    Post subject:

TITLE IS SUPPOSED TO BE PONG INSTEAD OF PING...oops Wacko


Introduction:
I am making a 2 player pong game and im having trouble with the ball moving around...

Plan:
The first part was i was going to get the core movement of the paddles and ball to movie and then make a string that will detect when the ball hits the paddles and counts up according to who missed. Like player one misses the ball and player 2 gets a point and vice versa.

Problem:
I got the ball and paddles moving and such, but after it hits the left sidem i get an ERR:DOMAIN message. For some reason the G=0 when it's supposed to be greater than that. I have added and if then statement to store B-1->G but it messes the clearing part and leaves a trail...

Ask part:
Can someone please help me the the plan above and the problems that im having? I know pong is one of the simplest games ever to make but not for someone whos just starting to program games. TIA!!!

Source so far:

Code:
ClrHome
5->Y
5->Z
2->A
2->B
1->C
1->D
1->F
1->G
1->H
1->Y
Repeat K=15
getKey->K
If Ans:Output(Y,16,"one space
If Ans:Output(Z,1,"one space
Y+1(Ans=34 and Y<8)-1(Ans=25 and Y>1->Y
Output(Z,1,"[
Z+1(K=31 and Z<8)-1(K=21 and Z>1->Z
Output(Y,16,"]
Output(A,B,"0
Output(F,G,"one space
a+c->a
if a=1 or a=8
-c->c
b+d->b
if b=1 or b=16
-d->d
f+h->
if f=1 or f=8
-h->h
g+i->g
if g=1 or g=16
-i->i
end


Last edited by Guest on 25 May 2004 07:00:09 pm; edited 1 time in total
Back to top
Jeremiah Walgren
General Operations Director


Know-It-All


Joined: 24 May 2003
Posts: 1937

Posted: 25 May 2004 07:03:26 pm    Post subject:

You could try setting a conditional statement so that the ball will reflect (or something similar) before you get the domain error.

Last edited by Guest on 25 May 2004 07:04:11 pm; edited 1 time in total
Back to top
Awesome1


Advanced Member


Joined: 28 Jan 2004
Posts: 269

Posted: 25 May 2004 07:51:26 pm    Post subject:

I've tried that and still had problems, though i don't remember the the string nor do i have it...
Back to top
Fr0sty


Member


Joined: 27 Nov 2003
Posts: 202

Posted: 25 May 2004 09:04:18 pm    Post subject:

What happens when it hits the right side?
Back to top
Jeremiah Walgren
General Operations Director


Know-It-All


Joined: 24 May 2003
Posts: 1937

Posted: 25 May 2004 10:24:25 pm    Post subject:

Fr0sty wrote:
What happens when it hits the right side?

I'd imagine it disappears. Or that he hasn't gotten that far yet.
Back to top
Arcane Wizard
`semi-hippie`


Super Elite (Last Title)


Joined: 02 Jun 2003
Posts: 8993

Posted: 26 May 2004 05:00:28 am    Post subject:

Darth posted some good source code for pong, I suggest looking for his posts with "pong AND boolean".

Quote:
and then make a string that wil
Stop calling it string, it's code not a variable type.

Also, getcalc( is way too slow to use in a realtime basic game, especially with the having to be in pause mode and stuff and using the keyboard with two players is really annoying, because if one person presses a key the other can't move anymore. So you might not want to do 2 player version of pong

Oh, and I fixed the title for ya.
Back to top
Awesome1


Advanced Member


Joined: 28 Jan 2004
Posts: 269

Posted: 26 May 2004 06:12:12 am    Post subject:

Well not so much two player using the link, two player as in they use different buttons on the calc. In the program above one player presses up and down and the other presses [ALHPA] and [2nd].

Quote:
Quote:
(Fr0sty @ May 25 2004, 08:04 PM)
What happens when it hits the right side?


I'd imagine it disappears. Or that he hasn't gotten that far yet.


It seems to just not stay/follow the scrolling and wanders off on it's own....

EDIT
Can't seem to find the pong game darth made...as suggested before for me to look at... Neutral


Last edited by Guest on 26 May 2004 07:53:05 am; edited 1 time in total
Back to top
Arcane Wizard
`semi-hippie`


Super Elite (Last Title)


Joined: 02 Jun 2003
Posts: 8993

Posted: 26 May 2004 03:07:24 pm    Post subject:

Awesome1 wrote:
Well not so much two player using the link, two player as in they use different buttons on the calc. In the program above one player presses up and down and the other presses [ALHPA] and [2nd].

You didn't read what I said, did you? Let me point something out to you:
Also, getcalc( is way too slow to use in a realtime basic game, especially with the having to be in pause mode and stuff and using the keyboard with two players is really annoying, because if one person presses a key the other can't move anymore. So you might not want to do 2 player version of pong

k?

Quote:
Can't seem to find the pong game darth made...as suggested before for me to look at... Neutral
1) First thing we do when searching on a forum is locate the search function.
2) Found it? Now, let's open it, shall we? Click on the search function so it goes to the search page where you can select what to search for and stuff.
3) Type in "pong boolean" without the quotation marks.
4) Type in "Darth Android" in the "Filter by Member Name (optional)" field.
5) Select the TiBasic forum.
6) Select "Any Date".
7) Press "Perform the Search".
Cool Click on "or click here if you do not wish to wait" or wait.
9) Read the very first topic that comes up.
Back to top
Awesome1


Advanced Member


Joined: 28 Jan 2004
Posts: 269

Posted: 26 May 2004 07:44:05 pm    Post subject:

I got it to work now with my own code. Thanx for the help every one and sorry for not reading things properly...

Happy Programmin'
**Awesome1**
Back to top
Awesome1


Advanced Member


Joined: 28 Jan 2004
Posts: 269

Posted: 27 May 2004 01:08:18 pm    Post subject:

If any one wants to see the source of the completed pong game i have coded please leave a note. I don't this could be even more optimised...except for the flickering which im going to fix in the next version.
Back to top
houou249


Newbie


Joined: 09 Jul 2003
Posts: 17

Posted: 27 May 2004 02:24:22 pm    Post subject:

Sure, lets see this code, maybe we could make it even better.
Back to top
Awesome1


Advanced Member


Joined: 28 Jan 2004
Posts: 269

Posted: 27 May 2004 09:21:50 pm    Post subject:

Here is goes!!!
1361 bytes before modifications...

Quote:
Lbl 9
CrlHome
ZStandard
AxesOff
Horizontal 10
Horizontal -10
Vertical -10
Vertical 10
Horizontal 7.5
Text(1,5"C-Pong BASIC
Text(1,63,"1 Player
Text(55,43,"Exit
Text(55,12,"Play
Text(55,70,"INFO.
Text(47,2,"v.00t
Line(-2.6,-10,-2.6,-7.5
Line(3,-10,3,-7.5
Line(-12,-7.5,-2.5,-7.5
Line(3,-7.5,-3,-7.5
Line(3,-7.5,10.5,-7.5
Circle(0,0,6
Pxl-On(17,58
Pxl-On(17,59
Pxl-On(18,60
Pxl-On(18,61
Pxl-On(18,62
Pxl-On(19,63
Pxl-On(20,64
Pxl-On(21,65
Pxl-On(21,66
Pxl-On(22,67
Repeat K=11 or K=12 or K=13 oe K=14 or K=15
getKey->K
End
If K=11 or K=12:Goto 1
If K=13:Goto 2
If K=14 or K=15:Goto 3
End
Lbl 3
0->K
ClrDraw
Horizontal 10
Horizontal -10
Vertical 10
Vertical -10
Horizontal 7.5
Text(1,28,"Information
Text(55,6,"Go Back
Text(55,66,"------
Line(-2.6,-10,-2.6,-7.5
Line(3,-10,3,-7.5
Line(-12,-7.5,-2.5,-7.5
Line(3,-7.5,-3,-7.5
Line(3,-7.5,10.5,-7.5
Text(10,2,"This is just a test version.
Text(17,2,"Press [2nd] to quit playing.
Text(24,2,"Don't miss more than 5!
Text(32,2,"Have Fun!
Text(47,2,"v.00t
Repeat K=11 or K=12 or K=13
getKey->K
End
If K=11 or 12:Goto 9
If K=13:Goto 2
End
Lbl 1
CrlHome
2->X:2->Y:2->T
1->A:1->B:2->C
0->H:0->S
Repeat K=21
getKey->K
For(0,0,20
End
Output(T,1,"]
Output(Y,X,"*
If Y=1 or Y=7
-B->B
If X=1 or X=16
-A->A
If S>5:Goto GO
If H>5:Goto G1
If Y(not equal to)C and X=16
S+1->S
If Y(not equal to)T and X=1
H+1->H
C+1(Ans=34 and C<7)-1(Ans=25 and C>1->C
Output(Y,X,"one space
Output(T,1,"one space
Output(C,16,"[
Output(8,2,S
Output(8,15,H
Y+B->Y
X+A->X
Y->T
randInt(1,5)->U
If U(less than or equal to)2:T-1->T
If T<1:T+2->T
If K=73:Pause
End
Lbl GO
ClrHome
Output(4,5,"GAME OVER!
Output(5,7,"You lose!
For(0,0,350
Output(1,16,"one space
End
Goto 9
Lbl G1
Output(4,5,GAME OVER!
Output(5,7,"You WIN!
For(0,0,350
Output(1,16,"one space
End
Goto 9
Lbl 2
ClrHome
DelVar A
DelVar B
DelVar C
DelVar D
DelVar E
DelVar H
DelVar K
DelVar S
DelVar T
DelVar U
DelVar X
DelVar Y
DelVar Z
DelVar 0
Output(1,2,"A1 Programming


Last edited by Guest on 27 May 2004 09:24:57 pm; edited 1 time in total
Back to top
DarkerLine
ceci n'est pas une |


Super Elite (Last Title)


Joined: 04 Nov 2003
Posts: 8328

Posted: 28 May 2004 03:56:33 pm    Post subject:

"I don't this could be even more optimised.."
then he puts a Lbl at the very first line.


Code:
...
Repeat Ans=14 or Ans=15
getKey
If Ans=11 or Ans=12:Goto 1
If Ans=13:Goto 2
End
Lbl 3
DelVar KClrDraw
...
Repeat 0
getKey
If Ans=11 or Ans=12:Goto 9
If Ans=13:Goto 2
End
Lbl 1
CrlHome
DelVar HDelVar S2->X:2->Y:2->T
1->A:1->B:2->C
Repeat K=21
getKey->K
For(theta,0,20
End
...
S+(Y(not equal to)C and X=16->S
H+(Y(not equal to)T and X=1->H
C+(Ans=34 and C<7)-(Ans=25 and C>1->C
...
If randInt(1,5)(less than or equal to)2:T-1->T
...

No time to optimize it more, sorry. And I didn't even get to the labels yet, but that actually involves an ounce of creativity I don't have at the moment.
Back to top
Awesome1


Advanced Member


Joined: 28 Jan 2004
Posts: 269

Posted: 30 May 2004 09:08:36 pm    Post subject:

Thank you very much for the optimised code and taking the time to do it. i have not been on often. Been chillen' with my friends and working on the yard so i have been too busy to check up on the forum.
Back to top
DarkerLine
ceci n'est pas une |


Super Elite (Last Title)


Joined: 04 Nov 2003
Posts: 8328

Posted: 31 May 2004 02:43:33 pm    Post subject:

Actually, Goto a label near the beginning of the program might be better than prgmPONG. Reasons:
1. It takes less space.
2. Since the label is at the very beginning, the Goto's take little time to find it, making no difference in speed. That label isn't used where speed counts anyway.
3. You can change the name of the program easily with Goto Lbl.
Some more optimizations:

Code:
If randInt(1,5)(less than or equal to)2
can be replaced with

Code:
If rand>.4


Code:
A-1->A
A+2(A<1->A
can be replaced with

Code:
DS<(A,1
A+2->A

In

Code:
Repeat K=21 or (B=5 or D=5
, the ( is superfluous since or is associative.

Code:
Pxl-On(17,58
Pxl-On(17,59
Pxl-On(18,60
Pxl-On(18,61
Pxl-On(18,62
Pxl-On(19,63
Pxl-On(20,64
Pxl-On(21,65
Pxl-On(21,66
Pxl-On(22,67

could probably be replaced with 1 or 2 line statements, I'm not sure though how effective that would be.

Code:
DelVar ADelVar BDelVar CDelVar DDelVar KDelVar SDelVar TDelVar XDelVar YOutput(1,2,"A1 Programming
is just plain silly, how long do you think the calc lasts with those vars anyway? And the Output could be replaced with " A1 Programming.

Almost forgot, the Horizontal Xmin and Vertical Ymin statements should be technically switched to Horizontal Ymin and Vertical Xmin, though it doesn't matter either way, they're the same thing. Same with Xmax and Ymax.

Finally, try varying the arguments of Vertical, Horizontal, and Line( statements a bit to your taste, getting the arguments to be integers. That will save some additional space.
Back to top
Display posts from previous:   
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
    »
» View previous topic :: View next topic  
Page 1 of 1 » All times are UTC - 5 Hours

 

Advertisement