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 - 191Brian

Pages: [1] 2 3 ... 7
1
QB64 Discussion / Re: Dynamic Random Access Field creation
« on: May 25, 2021, 03:12:14 am »
If you only need to access the data from QB64 then using arrays is probably best as it is quite simple to read and write whole arrays to and from a binary file plus they're much faster than file i/o. To save an arrays to file I write a single line comma delimited file with the array sizes then use PUT to write the arrays to binary files.

2
QB64 Discussion / Re: Dynamic Random Access Field creation
« on: May 24, 2021, 02:25:35 pm »
Hi @JohnUKresults

In this situation I would use 2 files 1 file to hold the race details (header) 1 to hold the laps or drivers (details) it makes the programming a bit more complicated but ultimately much more efficient.

3
QB64 Discussion / Re: Using INKEY$ and on screen movement
« on: May 19, 2021, 03:16:12 am »
Hi the delay is the Os wait time before auto repeat starts best way to avoid it is to use _keydown instead.

4
QB64 Discussion / Re: Mouse Controls
« on: May 17, 2021, 06:33:33 am »
Interesting I have found mouse control works quite well, the only issue I have seen like OldMoses is the need to add a short delay after actioning a click even to avoid duplicating the action.
What particular issues have you had?

5
QB64 Discussion / Re: reading remote text file
« on: May 15, 2021, 03:36:28 pm »
Pretty sure the answer is no, open only works on files local to you either on your PC or network share.

6
Hi

When I did my version of a tile map editor in QB64 https://191brian.itch.io/qb64-tile-map-editor which is for image tiles rather than coloured blocks it uses the image file names in the map files rather than having to cross reference codes to files/image names. It outputs the maps as files instead of data statements.

7
QB64 Discussion / Re: simultaneous loops?
« on: May 09, 2021, 04:02:14 am »
Hi Jaze

Good luck hope you get it working. I think you would find that's how game loops are programmed for example in my invaders game the game loop updates the players ship, the players bullets, the aliens, the random alien ship and explosion effects that's 5 different elements moving at various speeds.

8
QB64 Discussion / Re: random write to a .csv file
« on: May 08, 2021, 03:43:52 am »
Hi

Need a bit more info on what the application is. Do you want to add a new record or change one of the existing 4 records? If changing an existing record while sharing the file with other users could be messy, really need a db with record locking. I haven't tested it but I assume while one user has the file open on one else can open it.

9
QB64 Discussion / Re: simultaneous loops?
« on: May 06, 2021, 02:47:37 am »
You can make them move different speeds by adding a different offset i.e
Char1X = Char1X + 1
Char2X = Char2X + 2

Will make character 2 move twice as fast as character 1 horizontally

10
QB64 Discussion / Re: Output EXE to Source Folder
« on: April 28, 2021, 03:35:40 am »
Re com might help if you could share a snippet of your code. If you print to com it adds LF CR characters.

11
Programs / Re: Tile Based Game - You are the best
« on: April 28, 2021, 02:28:15 am »
Lol thanks for giving it a  try have you tried the next game [url]https://191brian.itch.io/campsite-manager/url]

12
QB64 Discussion / Re: help with arrays and DATA to make game maps
« on: April 23, 2021, 02:30:45 pm »
Hi

It is reading the data into the variable BLOCK% and if it is less than 9 it writes the value into the map array, the 9 in the data indicates the start position of the player which is set in the else part 
ELSE
      You(0) = col%
      You(1) = row%

IF Map(You(0), You(1) - 1) = 0 is testing if the cell the player is trying to move to is an empty (0) i.e not a wall (1) note this if statement changes depending on which direction the player is trying to move.

13
QB64 Discussion / Re: My small walking robot project ...
« on: April 21, 2021, 04:57:26 pm »
Hi Marco

Look forward to seeing the project develop would be happy to help where I can.

14
QB64 Discussion / Re: My small walking robot project ...
« on: April 21, 2021, 02:40:42 pm »
Hi

Found an Arduino in my shed, put a primitive sketch on it that listens for commands "fast", "med" and "slow" on the serial port then flashes its on board LED accordingly, then wrote a little QB64 program to send commands via serial port.
As proof of concept it works.



Arduino sketch.
String inputString ="";
int fspeed = 500;
char code = "x";

void setup() {
  pinMode(LED_BUILTIN, OUTPUT);
  Serial.begin(9600);

}

void loop() {
  // put your main code here, to run repeatedly:
  //Serial.println(code);
  digitalWrite(LED_BUILTIN, HIGH);
  delay(fspeed);
  digitalWrite(LED_BUILTIN,LOW);
  delay(fspeed);
}

void serialEvent()
{
  while(Serial.available())
  {
    char ch = (char)Serial.read();
    Serial.write(ch);
    inputString += ch;
    if(ch == '\n')
    {
      if(inputString == "fast\r\n"){
        fspeed = 50;
        code = "s";
      }
      if(inputString == "slow\r\n"){
        fspeed = 1000;
        code ="f";
      }
      if(inputString == "med\r\n"){
        fspeed = 500;
        code ="f";
      }
      inputString ="";
     
    }
  }
}

Code: QB64: [Select]
  1.  
  2. Type button
  3.     x As Integer
  4.     y As Integer
  5.     w As Integer
  6.     h As Integer
  7.     code As String
  8.     imageH As Long
  9.  
  10. Type vector2
  11.     x As Integer
  12.     y As Integer
  13.  
  14.  
  15. Dim Shared speedBtn(3) As button
  16. Dim Shared mousePos As vector2
  17. Dim Shared currMode As String
  18.  
  19. Dim comP As Long
  20. Dim comPno As String
  21. Dim comPmode As String
  22.  
  23. currMode = ""
  24. comP = FreeFile
  25. comPno = "COM3:"
  26. comPmode = "9600,N,8,1,ASC"
  27.  
  28. CreateButtons
  29.  
  30. Open comPno + comPmode For Output As comP
  31.  
  32. _Delay 0.5
  33.  
  34. Screen _NewImage(320, 140, 32)
  35.  
  36.     Cls
  37.     _Limit 30
  38.     DisplayButtons
  39.     _Display
  40.     mousePos.x = _MouseX
  41.     mousePos.y = _MouseY
  42.     ' If the mouse was clicked check if it was selecting a tile, clicking a button or putting a tile on the map
  43.         currMode = CheckButtons
  44.     End If
  45.     If currMode <> "" Then
  46.         Print #comP, currMode
  47.     End If
  48.  
  49.  
  50.  
  51. Close #comP
  52.  
  53.  
  54. Sub CreateButtons
  55.     Dim si As Integer
  56.     Dim currDest As Long
  57.  
  58.     currDest = _Dest
  59.  
  60.     si = 0
  61.     speedBtn(si).imageH = _NewImage(64, 32, 32)
  62.     _Dest speedBtn(si).imageH
  63.     Line (0, 0)-(63, 31), _RGB32(255), B
  64.     _PrintString (10, 2), "Slow"
  65.     speedBtn(si).x = 10
  66.     speedBtn(si).y = 10
  67.     speedBtn(si).w = 64
  68.     speedBtn(si).h = 32
  69.     speedBtn(si).code = "slow"
  70.  
  71.     si = 1
  72.     speedBtn(si).imageH = _NewImage(64, 32, 32)
  73.     _Dest speedBtn(si).imageH
  74.     Line (0, 0)-(63, 31), _RGB32(255), B
  75.     _PrintString (10, 2), "Medium"
  76.     speedBtn(si).x = 110
  77.     speedBtn(si).y = 10
  78.     speedBtn(si).w = 64
  79.     speedBtn(si).h = 32
  80.     speedBtn(si).code = "med"
  81.  
  82.     si = 2
  83.     speedBtn(si).imageH = _NewImage(64, 32, 32)
  84.     _Dest speedBtn(si).imageH
  85.     _PrintString (10, 2), "Fast"
  86.     Line (0, 0)-(63, 31), _RGB32(255), B
  87.     speedBtn(si).x = 210
  88.     speedBtn(si).y = 10
  89.     speedBtn(si).w = 64
  90.     speedBtn(si).h = 32
  91.     speedBtn(si).code = "fast"
  92.  
  93.     _Dest currDest
  94.  
  95.  
  96.  
  97.  
  98. Sub DisplayButtons
  99.  
  100.     Dim si
  101.  
  102.     For si = 0 To 2
  103.         _PutImage (speedBtn(si).x, speedBtn(si).y), speedBtn(si).imageH
  104.     Next si
  105.     _PrintString (120, 90), "Mode " + currMode
  106.  
  107.  
  108. Function CheckButtons$
  109.     Dim si As Integer
  110.  
  111.     CheckButtons = ""
  112.  
  113.     For si = 0 To UBound(speedbtn)
  114.         If RectCollide(mousePos.x, mousePos.y, 1, 1, speedBtn(si).x, speedBtn(si).y, speedBtn(si).w, speedBtn(si).h) Then
  115.             CheckButtons = speedBtn(si).code
  116.             Exit For
  117.         End If
  118.     Next si
  119.  
  120.  
  121. FUNCTION RectCollide (rect1X as integer,rect1Y as integer,rect1Width as integer,rect1Height as integer,_
  122.                       rect2X as integer,rect2Y as integer,rect2Width as integer,rect2Height as integer)
  123.  
  124.     Dim rect1X2 As Integer
  125.     Dim rect1Y2 As Integer
  126.     Dim rect2X2 As Integer
  127.     Dim rect2Y2 As Integer
  128.  
  129.     rect1X2 = rect1X + rect1Width - 1
  130.     rect1Y2 = rect1Y + rect1Height - 1
  131.     rect2X2 = rect2X + rect2Width - 1
  132.     rect2Y2 = rect2Y + rect2Height - 1
  133.  
  134.     RectCollide = 0
  135.     If rect1X2 >= rect2X Then
  136.         If rect1X <= rect2X2 Then
  137.             If rect1Y2 >= rect2Y Then
  138.                 If rect1Y <= rect2Y2 Then
  139.                     RectCollide = -1
  140.                 End If
  141.             End If
  142.         End If
  143.     End If
  144.  
  145.  
  146.  

15
QB64 Discussion / Re: My small walking robot project ...
« on: April 21, 2021, 07:49:31 am »
Hi

Very interesting project.

Few years ago I worked on communication between ardunio and android basic via Bluetooth. From what I remember the USB connection gets converted to a serial comm port on the pc so the communication is serial and qb64 already has serial communication via print and input. I will see if I still have an ardunio and try hooking it up to qb64.
Pretty sure windows converts touch screen movements and taps to mouse so qb64's mouse command's would work fine.

Pages: [1] 2 3 ... 7