Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Screen _newimage(_desktopwidth, _desktopheight, 32)
- Color _rgb32(0,0,0)
- Color , _rgb32(255,255,255)
- Resx = _desktopwidth
- Resy = _desktopheight
- _fullscreen
- Main:
- Do
- While _mouseinput
- If mouseclick(Resx/2-100,Resy/2-100,Resx/2+100,Resy/2+100) then
- Goto game
- Elseif mouseclick(Resx/2-100,Resy/2-200,Resx/2+100,Resy/2+200) then
- Goto addcard
- End if
- Wend
- Line (Resx/2-100,Resy/2-100)-(Resx/2+100,Resy/2+100),_rgb32(100,200,255),B
- _printstring(Resx/2-100,Resy/2-50),"Play"
- Line (Resx/2-100,Resy/2-200)-(Resx/2+100,Resy/2+200),_rgb32(100,200,255),B
- _printstring(Resx/2-100,Resy/2-150),"Add a Card to your collection!"
- _display
- Cls
- Loop
- Addcard:
- Cls
- If download("","cards.txt",20) then
- Print "Success in Downloading FIle!"
- Open "cards.txt" for input as #1
- Input "Enter the code no. For your card....";code$
- Do while not eof(1)
- Input #1, line$
- If code$ = line$ then
- Input #1, card$
- Input #1, loc$
- Print "You have chosen the ";card$;" card!!!"
- Print "Please wait till we find out where it's data is lying around..."
- Open "mycard.txt" for append as #2
- Print #2, card$
- Print #2, loc$
- Close #2
- End if
- Loop
- Close #1
- Else
- Print "Failed in Downloading The File...."
- Print "Please try again later...."
- Sleep
- Goto main
- Endif
- System
- Game:
- Function mouseclick(x1,y1,x2,y2)
- Mx = _mousex
- My = _mousey
- Mb = _mousebutton(1)
- If mx >= x1 and mx <= x2 and my >= y1 and my <= y2 and mb then
- Mouseclick = -1
- End if
- End function
- FUNCTION Download (url$, file$, timelimit) ' returns -1 if successful, 0 if not
- url2$ = url$
- x = INSTR(url2$, "/")
- IF x THEN url2$ = LEFT$(url$, x - 1)
- client = _OPENCLIENT("TCP/IP:80:" + url2$)
- IF client = 0 THEN EXIT FUNCTION
- e$ = CHR$(13) + CHR$(10) ' end of line characters
- url3$ = RIGHT$(url$, LEN(url$) - x + 1)
- x$ = "GET " + url3$ + " HTTP/1.1" + e$
- x$ = x$ + "Host: " + url2$ + e$ + e$
- PUT #client, , x$
- t! = TIMER ' start time
- DO
- _DELAY 0.05 ' 50ms delay (20 checks per second)
- GET #client, , a2$
- a$ = a$ + a2$
- i = INSTR(a$, "Content-Length:")
- IF i THEN
- i2 = INSTR(i, a$, e$)
- IF i2 THEN
- l = VAL(MID$(a$, i + 15, i2 - i -14))
- i3 = INSTR(i2, a$, e$ + e$)
- IF i3 THEN
- i3 = i3 + 4 'move i3 to start of data
- IF (LEN(a$) - i3 + 1) = l THEN
- CLOSE client ' CLOSE CLIENT
- d$ = MID$(a$, i3, l)
- fh = FREEFILE
- OPEN file$ FOR OUTPUT AS #fh: CLOSE #fh 'Warning! Clears data from existing file
- OPEN file$ FOR BINARY AS #fh
- PUT #fh, , d$
- CLOSE #fh
- Download = -1 'indicates download was successfull
- EXIT FUNCTION
- END IF ' availabledata = l
- END IF ' i3
- END IF ' i2
- END IF ' i
- LOOP UNTIL TIMER > t! + timelimit ' (in seconds)
- CLOSE client
- END FUNCTION
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement