Qbasicnews.com
July 22, 2019, 07:26:38 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Back to Qbasicnews.com | QB Online Help | FAQ | Chat | All Basic Code | QB Knowledge Base
 
   Home   Help Search Login Register  
Pages: [1] 2 3
  Print  
Author Topic: Obscurely coded pong  (Read 18114 times)
Zack
*/-\*
*****
Posts: 3974



WWW
« on: December 16, 2005, 01:25:38 AM »

This may have been done...I think I recall something like it but I searched and didn't find it.
Anywho, I want you folks to design a Pong game, but code it as annoyingly and obscurely as possible. That means loads of GOTO's and useless obscurification, as confusing as possible.
The rules:
a) Must be FB compatible
b) No non-native libs allowed, only the built-in FB lib.
c) May be for one or two players, but if it's for two players they must both be humans. No AI allowed.
d) Only three seperate statements on each line. That is to say, only 2 colons ":" are allowed. Example: print "hello":print "world":print "dude" is allowed, but nothing more.
Logged

f only life let you press CTRL-Z.
--------------------------------------
Freebasic is like QB, except it doesn't suck.
Zap
Been there, done that
*****
Posts: 1124


« Reply #1 on: December 16, 2005, 08:33:20 AM »

How is pong for one person without an AI opponent? You play against the wall or what?
Logged

url=http://www.copy-pasta.com]CopyPasta[/url] - FilePasta
yetifoot
Ancient Guru
****
Posts: 575



« Reply #2 on: December 16, 2005, 09:59:40 AM »

i didnt write this pong, i took it from ABC, but heres a quick jobbie using define

Code:
#define biff Locate
#define bibble Option Explicit
#define chog Screen 12
#define z Dim Shared
#define y As Integer
#define x As Single
#define w Case
#define v gg = gg +
#define u End Sub
#define t Select
#define s As String
#define r Sub
#define q ee + 20
#define p If
#define o Line
#define n Circle
#define m CHR$(255)
#define l Then
#define k Print
#define j Loop
#define i End
#define h Else
#define g Sleep
#define f ()
#define e INKEY$
#define d Do
#define c Until
#define a To
#define kjh OR
#define kjj - 20
#define cof cc = cc * -1
#define bof dd = dd * -1
bibble
z aa y:z bb y:z cc x:z dd x:z ee y:z ff y:z gg y:z hh s
r ii (aa, jj)
o (615,aa+50)-(630,aa-50),jj,B
u
r pq f
bb=200:cc=bb/100:dd=cc:ee=575:ff=240:aa=ff:gg=0  
u
r xzx f
k "GAME OVER":g:i
u
r bv f
ii(aa,0):aa=aa-15
p aa<0 l aa=0
ii(aa,4)
u
r vb f
ii(aa,0):aa=aa+15
p aa>480 l aa=480
ii(aa,4)
u
r jug f
d c e=" ": j
u
r xzy f
t w ff
w aa-55 a aa+55
cc = cc*-1:v 1:w 0 a aa-44:xzx
w aa+55 a 480
xzx
w h
cc = cc*-1:v 1:i t
u
r lk f
chog
pq
ii(240, 4)
d
ScreenSync
biff 1, 1: k gg
n (ee,ff),20,0:ee=ee+cc:ff=ff+dd
n (ee,ff),20,2
p q > 640 kjh q < 0 l cof
p ee kjj < 0 kjh q < 0 l cof
p ff kjj > 480 kjh ff + 20 > 480 l bof
p ff kjj < 0 kjh ff + 20 < 0 l bof
p q >= 614 l xzy
hh$ = e
t w hh$
w m + "H"
bv
w m + "P"
vb
w "q"
i
w "p"
jug
i t
j
u
lk
Logged

EVEN MEN OF STEEL RUST.
Anonymous
Guest
« Reply #3 on: December 16, 2005, 11:24:08 AM »

Lol
Logged
Zack
*/-\*
*****
Posts: 3974



WWW
« Reply #4 on: December 16, 2005, 03:53:26 PM »

Quote from: "Zap"
How is pong for one person without an AI opponent? You play against the wall or what?
Precisely.

Yetifoot: heheh, that's a start. Now ruin it more with gotos.
Logged

f only life let you press CTRL-Z.
--------------------------------------
Freebasic is like QB, except it doesn't suck.
yetifoot
Ancient Guru
****
Posts: 575



« Reply #5 on: December 16, 2005, 04:30:56 PM »

im kicking myself really cause the original program was all gotos, real spaghetti stuff, and for some dumb reason i sat there and subbed it all!!
Logged

EVEN MEN OF STEEL RUST.
thegrogen
Ancient QBer
****
Posts: 444



« Reply #6 on: December 16, 2005, 06:58:58 PM »

Code:

Screen 18,,,1 : Cls          
points = 0
Goto begin:
start:    
Cls
Line (0,playery)-(10,playery+50), 15,bf
inputsec:
a$ = Inkey$
If a$ = "w" And playery > 0 Then playery-=20  
If a$ = "s" And playery < (479-50) Then playery+=20
If a$ = Chr$(27) Then End
Goto ball
ball:                            
ballx+=ballxvel : bally += ballyvel
Circle (ballx+10, bally+10), 10  
Goto collision
endloop:
Locate 1, 35: Print points
Sleep 16 :  Goto start
begin:
playery=0
ballx= 10 : bally = 10
ballxvel=5 : ballyvel = 5
Goto start
collision:
If ballx <= 0 Then Goto begin
If ballx <= 10 And bally > playery And bally < playery+50 Then
ballxvel = -ballxvel
points+=1
End If
If bally <= 0 Then ballyvel = -ballyvel
If ballx >= 639 Then ballxvel =-ballxvel
If bally >= 479 Then ballyvel = -ballyvel
Goto endloop


Bounce the ball off the wall. Each time you bounce the ball off the paddle, you get a point. Use the lower-case 'w' and 'a' keys to move the paddle up and down. Took me about half an hour to write.
Logged

.14159265358979323846264338327950288419716939937510582709445
Glarplesnarkleflibbertygibbertygarbethparkentalelelangathaffendoinkadonkeydingdonkaspamahedron.
NecrosIhsan
Been there, done that
*****
Posts: 1191



« Reply #7 on: December 16, 2005, 07:42:26 PM »

Quote from: "Zack"
d) Only three seperate statements on each line. That is to say, only 2 colons ":" are allowed. Example: print "hello":print "world":print "dude" is allowed, but nothing more.

Doesn't this sorta defeat a major obfuscation technique? Cheesy
Logged

\__/)
(='.'=) Copy bunny into your signature to
(")_(") help him gain world domination.
yetifoot
Ancient Guru
****
Posts: 575



« Reply #8 on: December 16, 2005, 09:11:30 PM »

i broke that rule
Logged

EVEN MEN OF STEEL RUST.
KiZ
__/--\__
*****
Posts: 2879


WWW
« Reply #9 on: December 17, 2005, 12:04:59 AM »

Wow... my head hurts now.


drawing on yeti's idea (this also breaks the rule, but what the hell)
[syntax="qbasic"]#define x if
#define xx then
#define xxx else
#define xxxx do
#define xxxxx loop
#define xxxxxx until
#define z and
#define zx line
#define zxxx input
#define zxxxx multikey
#define zxxxxx circle
#define xz wait
#define xzx flip
#define xzxx cls
#define xzxxx goto
#define xzxxxx end
#define xxz screenset
#define xxzx dim as single
#define xxzxx screen
#define xxzxxx dim as string

xxzxx 14,,2
xzzxzzx:
xxz 0, 1:xxzx zxxz, zxzx, zxzz:xxzxxx zzxx, zzzx, zzzz, zzzxx
zxz = 160:zxxz = 160:zxzx = 50:zxzz = 1:zzzz = "y":y = 35
yx = 0:yyx = 265:yyyx = 200:yyyyx = 1:yyyyyx = 260:xy = 40
xyx = 0.001:xyxx = 5:xyxxx = 175:xyxxxx = 195:xyxxxxx = 190
xxy = 240:xxyx = 75:xxyxx = 77:xxyxxx = 180:xxxy = 20
xxxyx = 60:xxxyxx = 8:xxxyxxx = &h3da:xxxxy = 3
xxxx: zx(y, yx)-(yyx, yyyx), , b: x zzx = yyyyx xx zxxz = zxxz + zxzz xxx zxxz = zxxz - zxzz
x zxxz < xy xx zzx = yyyyx xxx x zxxz > yyyyyx xx zzx = yx
zxzz = zxzz + xyx:x zzz = yyyyx xx zxzx = zxzx + zxzz xxx zxzx = zxzx - zxzz
x zxzx < xyxx xx zzz = yyyyx xxx x zxzx > xyxxx z zxxz > zxz - xxxy z zxxz < zxz + xxxy xx zzz = yx
x zxzx > xyxxxx xx xxz yyyyx,yyyyx: zxxx "play again"; zzzxx: x zzzxx=zzzz xx xzxxx xzzxzzx xxx xzxxxx
zxxxxx(zxxz, zxzx), xyxx: x zxxxx(xxyx) z zxz > xxxyx xx zxz=zxz-xxxxy
x zxxxx(xxyxx) z zxz < xxy xx zxz = zxz+xxxxy
zx (zxz-xxxy,xxyxxx)-(zxz+xxxy,xyxxxxx),,b:xz xxxyxxx,xxxyxx:xzx:xzxx:xxxxx xxxxxx zxxxx(yyyyx)[/syntax]
Logged
yetifoot
Ancient Guru
****
Posts: 575



« Reply #10 on: December 17, 2005, 08:42:46 AM »

this one doesnt break the rules

Code:
' S I M P L E  P O N G  
'   by Cam <Slyboots> Spowart
' Stripped and stupidified by yetifoot
' Sub -> GOTO
' Select Case -> IF
' 7 -> ((1 shl 3) - 1) etc.
' code -> lots of horrible defines
#define a1111 GOTO
#define b0000 THEN
#define b0001 IF
#define b0010 ELSEIF
#define b0011 LINE
#define b0100 END
#define b0101 CIRCLE
#define b0110 DIM
#define b0111 ((((1 shl 9) OR (1 shl 6) OR (1 shl 5)) + (1 shl 3) - 1),
#define b1000 b0011 b0111 a0101 + ((3 shl (1 shl (1 shl 1))) + (1 shl 1)))-((((1 shl 9) OR (1 shl 6) OR (1 shl 5)) + (1 shl 3) - 1) + 15, a0101 - ((3 shl (1 shl (1 shl 1))) + (1 shl 1))),
#define b1001 (1 shl (1 shl (1 shl 1)) OR 1 shl (1 shl 1)) >
#define b1010 And a0100
#define b1011 (1 shl (1 shl (1 shl 1)) OR 1 shl (1 shl 1)) < 0
#define b1100 b1000 0,
#define b1101 b0010 a0100 >=
#define b1110 a0110[0] =
#define b1111 b1000 (1 shl (1 shl 1)), B:a1111 a1000
#define c0000 Or a0100 +
#define c0001 Or a0011 + b1011 b0000 a0001 = a0001 * -1
#define c0010 b1100 B:a0101 = a0101
#define c0011 a0010 = a0010 * -1
#define c0100 b1010 <=
#define c0101 b0001 a0011
#define c0110 b0010 b1110
#define c0111 a1111 a1110
#define c1000 b0001 a0101
#define c1001 Sleep
#define c1010 b0000 a0101 =
#define c1011 b0001 a0100 -
#define c1100 c0101 + b1001
#define c1101 (a0101 + 55)
#define c1110 a0001 = a0001 * -1
#define c1111 (a0101 -
#define d0000 a1111 a1001
#define d0001 = INKEY$
#define d0010 b0101 (a0011, a0100), (1 shl (1 shl (1 shl 1)) OR 1 shl (1 shl 1)),
#define d0011 Do
#define d0100 Loop
#define d0101 Else
#define d0110 = (((1 shl (1 shl (1 shl 1)))-1) shl (1 shl (1 shl 1)))
#define d0111 (((1 shl (1 shl (1 shl 1)))-1) shl ((1 shl (1 shl 1))+1))
#define d1000 Screen
#define d1001 As Single
#define d1010 As ZString * 2
#define d1011 a0011 =
#define d1100 a0100 >= c1111
#define d1101 =
#define d1110 ((1 shl (1 shl (1 shl 1)))-1)
#define d1111 +
#define e0000 /
#define e0001 50)-(630,
#define e0010 b1101 (0) c0100 c1111 44) b0000
#define e0011 (((1 shl (1 shl (1 shl 1)))-1) shl (1 shl (1 shl 1))) d1111 e0001 (((1 shl (1 shl (1 shl 1)))-1) shl (1 shl (1 shl 1))) - 50), (1 shl (1 shl 1)), B
#define e0100 100:d1011 575:a0100
#define e0101 b1101 c1101 c0100 (d0111) b0000
#define e0110 ((1 shl (1 shl (1 shl 1)))-(1 shl (1 shl 1))):a0000 d1101 200:a0001
#define e0111 ScreenSync
#define __THIS a0111:
#define __IS d1000 e0110 d1101 a0000 e0000 100
#define __GETTING a0010 d1101 a0000 e0000 e0100 d0110
#define __QUITE a0101 d0110:b0011 b0111 e0011
#define __RIDICULOUS d0011
#define __NOW a1000:
#define __BUT e0111:d0010 0:d1011 a0011 d1111 a0001
#define __IN a0100 d1101 a0100 d1111 a0010:d0010 (1 shl 1)
#define __THE c1100 640 c0001
#define __WORDS c0101 - b1011 c0001
#define __OF c1011 b1001 d0111 c0000 b1001 d0111 b0000 c0011
#define __MAGNUS c1011 b1011 c0000 b1011 b0000 c0011
#define __MAGNUSSON c1100= 614 a1111 a1101
#define __I a0110 d0001
#define __HAVE b0001 b1110 97 b0000
#define __STARTED a1111 a1011  
#define __SO c0110 122 b0000
#define __I_ a1111 a1100
#define __SHALL c0110 27 b0000
#define __FINISH a1111 a1010
#define __o_ c0110 112 b0000
#define __PS c1001
#define __THIS_ b0100 b0001
#define __IS_ a1001:
#define __PROBABLY d0100
#define __THE_ a1010:
#define __WORST_ b0100
#define __VERSION a1011:
#define __OF_ c0010 - d1110
#define __PONG c1000 < 0 c1010 0
#define __I__ b1111
#define __HAVE_ a1100:
#define __EVER c0010 d1111 d1110
#define __SEEN c1000 > d0111 c1010 d0111
#define __o__ b1111
#define __THE__ a1101:
#define _KEYS b0001 d1100 55) c0100 c1101 b0000
#define _ARE c1110
#define _A d0000
#define _FOR e0010
#define _UP c0111
#define _AND e0101
#define _Z c0111
#define _FOR_ d0101
#define _DOWN c1110
#define _0_0_ d0000
#define _0_0_0_ b0100 b0001
#define _0_0_0_0_ a1110:
#define _END c1001
#define _OF_ b0100
#define _FILE d0000
Option Explicit
b0110 d1001 a0000, a0001, a0010, a0011, a0100, a0101:b0110 a0110 d1010
__THIS
__IS
__GETTING
__QUITE
__RIDICULOUS
__NOW
__BUT
__IN
__THE
__WORDS
__OF
__MAGNUS
__MAGNUSSON
__I
__HAVE
__STARTED
__SO
__I_
__SHALL
__FINISH
__o_
__PS
__THIS_
__IS_
__PROBABLY
__THE_
__WORST_
__VERSION
__OF_
__PONG
__I__
__HAVE_
__EVER
__SEEN
__o__
__THE__
_KEYS
_ARE
_A
_FOR
_UP
_AND
_Z
_FOR_
_DOWN
_0_0_  
_0_0_0_
_0_0_0_0_
_END
_OF_
_FILE
Logged

EVEN MEN OF STEEL RUST.
jupiter3888
Member
*
Posts: 63



WWW
« Reply #11 on: December 17, 2005, 10:48:37 AM »

haha very funny yetifoot!  Cheesy=b
Logged

url=http://gm2.ath.cx/~jupiter3888]the home of jupiter3888 -> http://gm2.ath.cx/~jupiter3888[/url]
NecrosIhsan
Been there, done that
*****
Posts: 1191



« Reply #12 on: December 17, 2005, 12:51:03 PM »

That is the biggest abuse of #define I have ever seen. Cheesy
Logged

\__/)
(='.'=) Copy bunny into your signature to
(")_(") help him gain world domination.
thegrogen
Ancient QBer
****
Posts: 444



« Reply #13 on: December 17, 2005, 02:13:37 PM »

Quote from: "NecrosIhsan"
That is the biggest abuse of #define I have ever seen. Cheesy


Not anymore

edit: ported to FB:
Code:

#Define X
#Define XX X
#Define XXXX XX
#Define XXXXXXXXXX XXXX
#Define XXXXXXXXXXXX Sleep
#Define XXXXXXXXXXXXXXXXXXXXXX  Print "Hello, world!"


          XXXXXXXXXX
      XXXX          XXXX
    XX  XXXX      XXXX  XX
  XX  XX    XX  XX    XX  XX
  XX                      XX
XX  XXXXXXXXXXXXXXXXXXXXXX  XX
XX  XX    XX      XX    XX  XX
XX  XX    XX      XX    XX  XX
XX  XX    XX      XX    XX  XX
XX  XX    XX      XX    XX  XX
 XX  XX   XX      XX   XX  XX
  XX    XXXX      XXXX    XX
    XX    XXXXXXXXXX    XX
      XXXX          XXXX
         XXXXXXXXXXXX
Logged

.14159265358979323846264338327950288419716939937510582709445
Glarplesnarkleflibbertygibbertygarbethparkentalelelangathaffendoinkadonkeydingdonkaspamahedron.
axipher
Ancient Guru
****
Posts: 544



« Reply #14 on: December 17, 2005, 03:50:10 PM »

Well although this is abusing #define, now I know what it does, it could shorten programming by diong something like this:

Code:
#define @p PRINT
#define @i IF
#define @t THEN
etc...


It could take a while to define shortcuts for each command, but then typing long programs would be much easier would it not?
Logged
Pages: [1] 2 3
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!