Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Real2Two

Pages: [1] 2
1
Programs / Re: Screenshare
« on: July 09, 2020, 12:52:10 pm »
I tried to use JQuery instead of reload but I gave up.

2
Programs / Screenshare
« on: July 09, 2020, 12:49:51 pm »
Thanks to Ashish for helping me fix a bug which made the website not work.

I made a little screenshare program... it isn't perfect but it works:

host.bas
Code: QB64: [Select]
  1. dd = _OPENHOST("TCP/IP:80")
  2. crlf$ = CHR$(13) + CHR$(10)
  3.     c = _OPENCONNECTION(dd)
  4.     IF c <> 0 THEN
  5.         addr$ = _CONNECTIONADDRESS(c)
  6.         COLOR 15: PRINT "Client connected: ";: COLOR 12: PRINT addr$
  7.  
  8.         GET #c, , x$
  9.  
  10.         a = INSTR(x$, "GET ")
  11.         b = INSTR(a + 5, x$, " ")
  12.         request$ = RIGHT$(LEFT$(x$, b - 1), b - a - 4)
  13.         COLOR 14, 8
  14.         PRINT "request = ";
  15.         COLOR 0, 7: PRINT request$
  16.         IF LEN(request$) = 0 THEN PRINT x$
  17.         COLOR 7, 0
  18.  
  19.         SELECT CASE request$
  20.             CASE "/"
  21.                 ff = FREEFILE
  22.                 OPEN "index.html" FOR BINARY AS #ff
  23.                 a$ = SPACE$(LOF(ff))
  24.                 GET #ff, 1, a$
  25.                 CLOSE ff
  26.                 reply$ = "HTTP/1.0 200 OK" + crlf$ + crlf$
  27.                 reply$ = reply$ + a$
  28.             CASE "/screen"
  29.                 SaveImage _SCREENIMAGE, "screen"
  30.                 ff = FREEFILE
  31.                 OPEN "screen.bmp" FOR BINARY AS #ff
  32.                 a$ = SPACE$(LOF(ff))
  33.                 GET #ff, 1, a$
  34.                 CLOSE ff
  35.                 reply$ = "HTTP/1.0 200 OK" + crlf$
  36.                 reply$ = reply$ + "Content-Length:" + STR$(LEN(a$)) + crlf$
  37.                 reply$ = reply$ + "Content-Type: image/bmp" + crlf$ + crlf$
  38.                 reply$ = reply$ + a$
  39.             CASE ELSE
  40.                 FourOhFour:
  41.                 reply$ = "HTTP/1.0 404 Not found" + crlf$
  42.                 reply$ = reply$ + "Content-Length: 103" + crlf$
  43.                 reply$ = reply$ + "Content-Type: text/html" + crlf$ + crlf$
  44.                 reply$ = reply$ + "<html><head><title>404 Not Found</title></head><body><p>This page does not exist.</p></body></html>" + crlf$ + crlf$
  45.         END SELECT
  46.         PUT #c, , reply$
  47.         CLOSE c
  48.         c = 0
  49.         x$ = ""
  50.         request$ = ""
  51.         reply$ = ""
  52.     END IF
  53.     _LIMIT 30
  54.  
  55. SUB SaveImage (image AS LONG, filename AS STRING)
  56.     bytesperpixel& = _PIXELSIZE(image&)
  57.     IF bytesperpixel& = 0 THEN PRINT "Text modes unsupported!": END
  58.     IF bytesperpixel& = 1 THEN bpp& = 8 ELSE bpp& = 24
  59.     x& = _WIDTH(image&)
  60.     y& = _HEIGHT(image&)
  61.     b$ = "BM????QB64????" + MKL$(40) + MKL$(x&) + MKL$(y&) + MKI$(1) + MKI$(bpp&) + MKL$(0) + "????" + STRING$(16, 0) 'partial BMP header info(???? to be filled later)
  62.     IF bytesperpixel& = 1 THEN
  63.         FOR c& = 0 TO 255 ' read BGR color settings from JPG image + 1 byte spacer(CHR$(0))
  64.             cv& = _PALETTECOLOR(c&, image&) ' color attribute to read.
  65.             b$ = b$ + CHR$(_BLUE32(cv&)) + CHR$(_GREEN32(cv&)) + CHR$(_RED32(cv&)) + CHR$(0) 'spacer byte
  66.         NEXT
  67.     END IF
  68.     MID$(b$, 11, 4) = MKL$(LEN(b$)) ' image pixel data offset(BMP header)
  69.     lastsource& = _SOURCE
  70.     _SOURCE image&
  71.     IF ((x& * 3) MOD 4) THEN padder$ = STRING$(4 - ((x& * 3) MOD 4), 0)
  72.     FOR py& = y& - 1 TO 0 STEP -1 ' read JPG image pixel color data
  73.         r$ = ""
  74.         FOR px& = 0 TO x& - 1
  75.             c& = POINT(px&, py&) 'POINT 32 bit values are large LONG values
  76.             IF bytesperpixel& = 1 THEN r$ = r$ + CHR$(c&) ELSE r$ = r$ + LEFT$(MKL$(c&), 3)
  77.         NEXT px&
  78.         d$ = d$ + r$ + padder$
  79.     NEXT py&
  80.     _SOURCE lastsource&
  81.     MID$(b$, 35, 4) = MKL$(LEN(d$)) ' image size(BMP header)
  82.     b$ = b$ + d$ ' total file data bytes to create file
  83.     MID$(b$, 3, 4) = MKL$(LEN(b$)) ' size of data file(BMP header)
  84.     IF LCASE$(RIGHT$(filename$, 4)) <> ".bmp" THEN ext$ = ".bmp"
  85.     f& = FREEFILE
  86.     OPEN filename$ + ext$ FOR OUTPUT AS #f&: CLOSE #f& ' erases an existing file
  87.     OPEN filename$ + ext$ FOR BINARY AS #f&
  88.     PUT #f&, , b$
  89.     CLOSE #f&
  90.  

index.html
Code: Text: [Select]
  1. <html>
  2.     <head>
  3.         <title>Screenshare</title>
  4.         <style>
  5.             body {
  6.                 margin: 0;
  7.             }
  8.         </style>
  9.         <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
  10.     </head>
  11.     <body>
  12.         <div id="screen">
  13.         </div>
  14.         <script>
  15.             imageLoop()
  16.             function imageLoop() {
  17.                 document.getElementById("screen").innerHTML = `<img id="imgvar" src="/screen">`;
  18.                 setTimeout(function(){
  19.                     location.reload();
  20.                 }, 8000);
  21.             }
  22.         </script>
  23.     </body>
  24. </html>

3
QB64 Discussion / An Orginial Game Idea - Take the idea if you want.
« on: June 01, 2020, 12:20:17 pm »
When I was outside, I decided to try to avoid all the shadows with my shadow. Then, that got me thinking of a game idea.

Maybe, what if there was a RPG type game but there are shadows you aren't allowed to touch with the characters shadow.

The shadow should always stay in 1 direction no matter where the chracter is facing and if the shadow touches another shadow, you lose. Example: https://imgur.com/2W4tv5k

Also, the shadow should be 2 blocks when the chracter is looking all directions but east. When the character is looking in the east direction, the shadow should be 1 block.

It would be cool if someone takes this idea to make a game.

If you question me about more ideas or what I mean about this game idea, I can explain more about it.

If you wonder why I wouldn't make this, I just don't feel like making a game, even though it is a cool orginial idea that I've never seen any game have.

4
Programs / Re: COVID-19 in QB64
« on: June 01, 2020, 09:36:09 am »
Nice work, ashishh. I made yours a little more efficient:

Code: QB64: [Select]
  1. 'COVID-19 in QB64
  2. 'By Ashish
  3. '1 Jun, 2020
  4. '
  5. 'WARNING:Use mask. Apply santizer after closing the program.
  6.  
  7. _TITLE "I'm Covid-19"
  8. SCREEN _NEWIMAGE(600, 600, 32)
  9.  
  10.     SUB glutSolidSphere (BYVAL radius AS DOUBLE, BYVAL slices AS LONG, BYVAL stack AS LONG)
  11.     SUB gluLookAt (BYVAL eyeX#, BYVAL eyeY#, BYVAL eyeZ#, BYVAL centerX#, BYVAL centerY#, BYVAL centerZ#, BYVAL upX#, BYVAL upY#, BYVAL upZ#)
  12.  
  13.  
  14. DIM SHARED glAllow AS _BYTE
  15. TYPE vec3
  16.     x AS SINGLE
  17.     y AS SINGLE
  18.     z AS SINGLE
  19.  
  20. TYPE COVID19
  21.     POS AS vec3
  22.     r AS SINGLE
  23.  
  24. DIM SHARED virus AS COVID19
  25.  
  26. virus.r = 0.3
  27.  
  28. glAllow = -1
  29.     _LIMIT 1
  30.  
  31. SUB _GL ()
  32.     STATIC init, aspect, rotY
  33.  
  34.     IF glAllow = 0 THEN EXIT SUB
  35.     IF init = 0 THEN
  36.         init = 1
  37.         aspect = _WIDTH / _HEIGHT
  38.         _glViewport 0, 0, _WIDTH, _HEIGHT
  39.     END IF
  40.  
  41.     _glEnable _GL_DEPTH_TEST
  42.     _glEnable _GL_LIGHTING
  43.     _glEnable _GL_LIGHT0
  44.  
  45.     _glLightfv _GL_LIGHT0, _GL_AMBIENT, glVec4(0.0, 0.0, 0.0, 1)
  46.     _glLightfv _GL_LIGHT0, _GL_DIFFUSE, glVec4(0.8, 0.8, 0.8, 1)
  47.     _glLightfv _GL_LIGHT0, _GL_SPECULAR, glVec4(1, 1, 1, 1)
  48.     _glLightfv _GL_LIGHT0, _GL_POSITION, glVec4(0, 0, 10, 1)
  49.  
  50.  
  51.  
  52.     _glMatrixMode _GL_PROJECTION
  53.     _gluPerspective 50, aspect, 0.1, 10
  54.  
  55.     _glMatrixMode _GL_MODELVIEW
  56.     gluLookAt 0, 0, 2, 0, 0, 0, 0, 1, 0
  57.  
  58.  
  59.     _glLineWidth 2.0
  60.     _glPointSize 10.0
  61.  
  62.     _glTranslatef virus.POS.x, virus.POS.y, virus.POS.z
  63.     _glRotatef rotY, 0.5, 1, 0
  64.     rotY = rotY + 1
  65.  
  66.     _glMaterialfv _GL_FRONT_AND_BACK, _GL_DIFFUSE, glVec4(0, 0.9, 0, 1)
  67.  
  68.     glutSolidSphere virus.r, 20, 20
  69.  
  70.     _glDisable _GL_LIGHTING
  71.     _glColor3f 1, 0, 0
  72.     _glBegin _GL_LINES
  73.     'FOR phi = 0.4 TO _PI(2) STEP .5
  74.     'FOR theta = 0.3 TO _PI STEP .5
  75.  
  76.     rr = 0.18
  77.     a = _ASIN(rr / (0.1 + virus.r))
  78.     FOR theta = a TO _PI STEP a
  79.         aa = rr / ((0.1 + virus.r) * SIN(theta))
  80.         FOR phi = aa TO _PI(2) STEP aa
  81.             _glVertex3f virus.r * SIN(theta) * COS(phi), virus.r * SIN(theta) * SIN(phi), virus.r * COS(theta)
  82.             _glVertex3f (0.1 + virus.r) * SIN(theta) * COS(phi), (0.1 + virus.r) * SIN(theta) * SIN(phi), (0.1 + virus.r) * COS(theta)
  83.         NEXT
  84.     NEXT
  85.  
  86.     _glEnd
  87.     _glBegin _GL_POINTS
  88.     FOR theta = a TO _PI STEP a
  89.         aa = rr / ((0.1 + virus.r) * SIN(theta))
  90.         FOR phi = aa TO _PI(2) STEP aa
  91.             _glVertex3f (0.1 + virus.r) * SIN(theta) * COS(phi), (0.1 + virus.r) * SIN(theta) * SIN(phi), (0.1 + virus.r) * COS(theta)
  92.         NEXT
  93.     NEXT
  94.     _glEnd
  95.     _glEnable _GL_LIGHTING
  96.  
  97.  
  98.  
  99.  
  100. FUNCTION glVec4%& (x, y, z, w) 'give the offset of the given vector
  101.     STATIC internal_vec4(3)
  102.     internal_vec4(0) = x
  103.     internal_vec4(1) = y
  104.     internal_vec4(2) = z
  105.     internal_vec4(3) = w
  106.     glVec4%& = _OFFSET(internal_vec4())
  107.  

Why did you evolve the virus?

5
QB64 Discussion / Re: OpenClient trouble
« on: May 29, 2020, 02:16:36 pm »
I'm not too sure but:
1. rpi and computer might not be connecting
2. I feel like this would be spamming OPENCLIENT... I think you should only connect the client once and use GET...

7
QB64 Discussion / Re: Downloading TEXT file from internet
« on: March 20, 2020, 09:00:16 pm »
Try doing some get of GET request of QB64, which I remember seeing code with the GET with QB64, but I forgot about it.

8
QB64 Discussion / Re: Flashing text: how to do it?
« on: February 15, 2020, 06:44:02 am »
Worked? _LIMIT was always confusing to me.

SLEEP, _DELAY, _LIMIT... all so different

9
QB64 Discussion / Re: Flashing text: how to do it?
« on: February 15, 2020, 06:41:21 am »
Try this:

Code: QB64: [Select]
  1. SCREEN _NEWIMAGE(300, 500, 32)
  2.  
  3. colornum = 0
  4.  
  5. IF colornum = 0 THEN
  6. colornum = 1
  7. COLOR &HFFffffff
  8. colornum = 0
  9. COLOR &HFF000000
  10. LOCATE 10, 1: PRINT "test"
  11. SYSTEM ' Not required.

Also try adjusting _LIMIT

10
QB64 Discussion / Re: Flashing text: how to do it?
« on: February 15, 2020, 06:39:35 am »
Is the screen just black?

11
QB64 Discussion / Re: Flashing text: how to do it?
« on: February 15, 2020, 06:30:45 am »
Something like:

Code: QB64: [Select]
  1. SCREEN _NEWIMAGE(300, 500, 32)
  2.  
  3. colornum = 0
  4.  
  5. IF colornum = 0 THEN
  6. colornum = 1
  7. COLOR &HFFffffff
  8. colornum = 0
  9. COLOR &HFF000000
  10. LOCATE 10, 1: PRINT "test"
  11. SYSTEM ' Not required.

12
QB64 Discussion / Re: Flashing text: how to do it?
« on: February 15, 2020, 06:01:33 am »
What do you mean flashing text? Text constantly changing color/black and white?

13
QB64 Discussion / Re: CTRL+v
« on: February 14, 2020, 05:23:38 pm »
Like long time ago. Doesnt say on wiki rip

14
QB64 Discussion / Re: Can someone write a qb64 code for me?
« on: February 12, 2020, 06:51:13 am »
It might be easier to write it in batch but I guess if you use SHELL, you can loop all files (but idk how to do that).

15
QB64 Discussion / Re: Can someone write a qb64 code for me?
« on: February 11, 2020, 02:54:54 pm »
I've never found a way to unzip files with qb64. This might be hard to do.

Pages: [1] 2