Welcome, Guest
You have to register before you can post on our site.

Username/Email:
  

Password
  





Search Forums

(Advanced Search)

Forum Statistics
» Members: 324
» Latest member: Martinstobe
» Forum threads: 1,747
» Forum posts: 17,908

Full Statistics

Latest Threads
The Crucial Role of Getti...
Forum: Utilities
Last Post: Martinstobe
06-06-2025, 04:41 PM
» Replies: 0
» Views: 18
The Essential Role of See...
Forum: Utilities
Last Post: Martinstobe
06-06-2025, 12:32 PM
» Replies: 0
» Views: 19
astuce pour survivre fina...
Forum: Utilities
Last Post: coletteleger
05-14-2025, 04:47 AM
» Replies: 0
» Views: 56
trouver permis de conduir...
Forum: Utilities
Last Post: nicolasrene
05-05-2025, 05:24 AM
» Replies: 0
» Views: 58
LIGHTBAR Menu
Forum: Programs
Last Post: nicolasrene
05-05-2025, 05:08 AM
» Replies: 15
» Views: 1,070
Learning Pallet Rack Safe...
Forum: Utilities
Last Post: Sandrapew
04-03-2025, 09:36 AM
» Replies: 0
» Views: 62
Choosing New Versus or Pr...
Forum: Utilities
Last Post: Sandrapew
03-18-2025, 01:11 AM
» Replies: 0
» Views: 65
The QB64 IDE shell
Forum: Utilities
Last Post: JasonPag
09-16-2024, 05:37 PM
» Replies: 9
» Views: 1,162
Importance regarding Ches...
Forum: Utilities
Last Post: JasonPag
09-01-2024, 06:34 PM
» Replies: 0
» Views: 92
Chess and Analysis and En...
Forum: Utilities
Last Post: JasonPag
08-28-2024, 02:37 PM
» Replies: 0
» Views: 94

 
  This program causes QB64 to crash - SOLVED
Posted by: Petr - 03-26-2023, 11:58 AM - Forum: General Discussion - Replies (3)

The small screen resolution when using the font causes an error for me - the program has stopped working and will be terminated. I am attaching the font used to test if it will behave the same on your systems. I understand that the screen height is set small, but if you are debugging a large program, this type of error will definitely be very annoying to deal with.

Code: (Select All)
$NoPrefix
Screen _NewImage(800, 64, 32)
F& = LoadFont("BKANT.ttf", 72, "Bold")
Font F&
Print "QB64 Phoenix Edition"

Bug occur in QB64PE 32bit 3.5.0 and also in QB64PE 64bit 3.6.0

font is not attached more, because problem solved using PrintString. Thanks to Mnrvovfrc (in next reply.)

Print this item

  Tiny Mastermind
Posted by: johannhowitzer - 03-25-2023, 11:45 PM - Forum: Programs - Replies (5)

NOTE: Later down there's an updated version that is more optimized and does away with colons.

I present to you the game Mastermind, in 25 lines of code.  Technically a little more because of
colons, but all the colons here are fine I think.  For tiny little one-statement DO and FOR loops,
I find it's more readable like this; likewise for concatenating a handful of simple results of an
IF statement, to avoid a block IF...END IF.  For much larger programs, it makes understanding
program flow much less convoluted, since my eyes have less nesting hierarchy to navigate.
Also, this code works in QBasic!

Code: (Select All)
do: input "How many possible letters (2-26)? ", code_colors%: loop while code_colors% < 2 or code_colors% > 26
do: input "How many letters long? ", code_length%: loop while code_length% < 1
dim match%(code_length%)
randomize timer
for n = 1 to code_length%: solution$ = solution$ + chr$(int(rnd * code_colors%) + asc("a")): next n
do
  do: input "> ", attempt$: loop until len(attempt$) = code_length%
  black_pegs% = 0: white_pegs% = 0
  for n = 1 to code_length%
      if mid$(attempt$, n, 1) <> mid$(solution$, n, 1) then match%(n) = 0 else match%(n) = n: black_pegs% = black_pegs% + 1
  next n
  for n = 1 to code_length%
      if match%(n) = 0 then
        for n1 = 1 to code_length%
            if n1 <> n and mid$(attempt$, n, 1) = mid$(solution$, n1, 1) then
              for n2 = 1 to code_length%
                  if match%(n2) <> n1 then m = 0 else m = -1: exit for ' Check for pre-existing white peg
              next n2
              if m = 0 then match%(n) = n1: white_pegs% = white_pegs% + 1: exit for
            end if
        next n1
      end if
  next n
  print black_pegs%; "black,"; white_pegs%; "white"
loop while black_pegs% < code_length%


This operates exactly like Mastermind as you know it, except with lowercase letters instead of
colored pegs.  You specify how many letters are possible, and how long the solution is.  So, if
you say 12 possible letters and 4 letters long, the game will use the letters a through l, and
produce solutions such as "glhf" and "dljk."  If you say 2 possible letters and 15 letters long,
it will produce things like "baabbbabaababba."

Guesses must be of the specified length, and must be in all lowercase.  The game will signal
a correct letter in correct position with a "black peg," just like a typical Mastermind set,
and will signal a correct letter that is in the wrong position with a "white peg."  For example,
if the solution is "hall," and you guess "hola," you will get two black pegs for the first h and
the third l, and one white peg for the a, which is not in the second position.  If the solution
is "other," and you guess "trout," you will get three white pegs, not four, since the solution
only has one t.

Print this item

  OpenGL examples
Posted by: Petr - 03-25-2023, 04:01 PM - Forum: Petr - Replies (52)

I'll say straight away that I literally only passed very light OpenGL. Still, I have a few absolutely basic things to post here.

The first program is completely primitive. Draws a triangle and a square in 2D, without texture.

Code: (Select All)
$Resize:On
Screen _NewImage(800, 600, 32)
Do While InKey$ <> Chr$(27)
    _Limit 20
Loop

Sub _GL
    _glViewport 0, 0, 800, 600
    _glMatrixMode _GL_PROJECTION '//                        set projection matrix
    _glLoadIdentity '             //                        Reset matrix
    _gluPerspective 45.0F, 800 / 600, 0.1F, 100.0F '        claculate perspective
    _glMatrixMode _GL_MODELVIEW '                           set matrix _GL_MODELVIEW
    _glLoadIdentity
    _glShadeModel _GL_SMOOTH '                              allow smooth shading
    _glClearColor 0.0F, 0.0F, 0.0F, 0.5F
    _glClearDepth 1.0F '                                    set depth buffer
    _glEnable _GL_DEPTH_TEST '                              allow depth testing
    _glDepthFunc _GL_LEQUAL '                               depth testing type
    _glHint _GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST '    set the best projection correction
    _glClear _GL_COLOR_BUFFER_BIT: _glClear _GL_DEPTH_BUFFER_BIT 'clear screen and depth buffer
    _glLoadIdentity '                                            matrix reset
    ' Sem kresli primitivy
    _glTranslatef -1.5F, 0.0F, -6.0F 'Shift to the left and to the depth - be careful, every other shift on the screen moves from the place where we moved before!
    _glBegin _GL_TRIANGLES '          Begin draw triangle
    _glVertex3f 0.0F, 1.0F, 0.0F '    upper point
    _glVertex3f -1.0F, -1.0F, 0.0F '  left bottom point
    _glVertex3f 1.0F, -1.0F, 0.0F '   right bottom point
    _glEnd '                          End draw triangle
    _glTranslatef 3.0F, 0.0F, 0.0F '  we will move in the x-axis by 1.5 to the center and 1.5 to the right, where we will paint a square
    _glBegin _GL_QUADS '              Square draw begin
    _glVertex3f -1.0F, 1.0F, 0.0F '   left upper point
    _glVertex3f 1.0F, 1.0F, 0.0F '    right upper point
    _glVertex3f 1.0F, -1.0F, 0.0F '   right bottom point
    _glVertex3f -1.0F, -1.0F, 0.0F '  left bottom point
    _glEnd '                          end draw square
End Sub


[Image: OGL1.png]


[size=1]182 / 5 000

[/size]



This source code shows how to draw a pyramid in color with blending colors on the walls, as well as how to draw a cube with walls of one color and how to rotate these objects.


Code: (Select All)
$Resize:On
Screen _NewImage(800, 600, 32) '
Dim Shared rquad As _Float: rquad = 7
Dim Shared rtri As _Float: rtri = 7

Do While InKey$ <> Chr$(27)
    _Limit 20
Loop

Sub _GL
    _glViewport 0, 0, _Width, _Height
    _glMatrixMode _GL_PROJECTION '                          Set projection matrix
    _glLoadIdentity '                                       Matrix reset
    _gluPerspective 45.0F, _Width / _Height, 0.1F, 100.0F ' Perspective calculation
    _glMatrixMode _GL_MODELVIEW '                           set modelview matrix
    _glLoadIdentity
    _glShadeModel _GL_SMOOTH '                              allow smooth shading
    _glClearColor 0.0F, 0.0F, 0.0F, 0.5F
    _glClearDepth 1.0F '                                    set depth buffer
    _glEnable _GL_DEPTH_TEST '                              allow depth testing
    _glDepthFunc _GL_LEQUAL '                               set depth testing method
    _glHint _GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST '    set nicest projection matrix
    _glClear _GL_COLOR_BUFFER_BIT: _glClear _GL_DEPTH_BUFFER_BIT 'clear screen and depth buffer
    _glLoadIdentity '                                             matrix reset
    ' draw primitives here

    _glTranslatef -1.5F, 0.0F, -6.0F '       Shift to the left and to the depth - be careful, every other shift on the screen moves from the place where we moved before!


    _glRotatef rtri, 0.0F, 1.0F, 0.0F ' Rotate the triangle around the y-axis

    _glBegin _GL_TRIANGLES '            The beginning of drawing the PYRAMID

    _glColor3f 1.0F, 0.0F, 0.0F '       Red color (it is as _glColor3f Red, Green, Blue and values can be calculated as 1 / 255)
    _glVertex3f 0.0F, 1.0F, 0.0F '      Upper point
    _glColor3f 0.0F, 1.0F, 0.0F '       Green color
    _glVertex3f -1.0F, -1.0F, 1.0F '    left bottom point
    _glColor3f 0.0F, 0.0F, 1.0F '       blue color
    _glVertex3f 1.0F, -1.0F, 1.0F '     right bottom point

    _glColor3f 1.0F, 0.0F, 0.0F '  red color
    _glVertex3f 0.0F, 1.0F, 0.0F ' upper point (right wall)
    _glColor3f 0.0F, 0.0F, 1.0F '  blue color
    _glVertex3f 1.0F, -1.0F, 1.0F 'left point (right wall)
    _glColor3f 0.0F, 1.0F, 0.0F '  green
    _glVertex3f 1.0F, -1.0F, -1.0F ' right point (right wall)                 '

    _glColor3f 1.0F, 0.0F, 0.0F '    red
    _glVertex3f 0.0F, 1.0F, 0.0F '   upper point (rear wall)
    _glColor3f 0.0F, 1.0F, 0.0F '    green
    _glVertex3f 1.0F, -1.0F, -1.0F ' left point (rear wall)
    _glColor3f 0.0F, 0.0F, 1.0F '    blue
    _glVertex3f -1.0F, -1.0F, -1.0F 'right point (rear wall)

    _glColor3f 1.0F, 0.0F, 0.0F '    red
    _glVertex3f 0.0F, 1.0F, 0.0F '   upper point (back wall)
    _glColor3f 0.0F, 0.0F, 1.0F '    blue
    _glVertex3f -1.0F, -1.0F, -1.0F 'left point (left wall)
    _glColor3f 0.0F, 1.0F, 0.0F '    green
    _glVertex3f -1.0F, -1.0F, 1.0F ' right point (left wall)

    _glEnd 'triangle draw end

    _glTranslatef 3.0F, 0.0F, 0.0F 'we will move in the x-axis by 1.5 to the center and 1.5 to the right, where we will paint a quad
    'FOR THE ENTIRE OBJECT IN ONE COLOR:

    _glLoadIdentity '                  we call it to align the X Y Z axes to the original direction, without it it would default to the previous rotated state
    _glTranslatef 1.5F, 0.0F, -7.0F '  The displacement of the origin is higher than in a quad

    _glRotatef rquad, 1.0F, 1.0F, 1.0F 'Rotate the quad around the x-axis

    _glBegin _GL_QUADS '               begin draw quad
    _glColor3f 0.0F, 1.0F, 0.0F '      green color
    _glVertex3f 1.0F, 1.0F, -1.0F '    left upper point
    _glVertex3f -1.0F, 1.0F, -1.0F '   right upper point
    _glVertex3f -1.0F, 1.0F, 1.0F '    right bottom point
    _glVertex3f 1.0F, 1.0F, 1.0F '     left bottom point

    _glColor3f 1.0F, 0.5F, 0.0F '      orange color
    _glVertex3f 1.0F, -1.0F, 1.0F '    right upper point (bottom wall)
    _glVertex3f -1.0F, -1.0F, 1.0F '   left upper point  (bottom wall)
    _glVertex3f -1.0F, -1.0F, -1.0F '  left bottom point (bottom wall)
    _glVertex3f 1.0F, -1.0F, -1.0F '   right bottm point (bottom wall)

    _glColor3f 1.0F, 0.0F, 0.0F '       red
    _glVertex3f 1.0F, 1.0F, 1.0F '     right upper point (front wall)
    _glVertex3f -1.0F, 1.0F, 1.0F '    Left upper point (front wall)
    _glVertex3f -1.0F, -1.0F, 1.0F '   left bottom point (front wall)
    _glVertex3f 1.0F, -1.0F, 1.0F '    right bottom point (front wall)

    _glColor3f 1.0F, 1.0F, 0.0F '       yellow
    _glVertex3f 1.0F, -1.0F, -1.0F '   right upper point (rear wall)
    _glVertex3f -1.0F, -1.0F, -1.0F '  left upper point (rear wall)
    _glVertex3f -1.0F, 1.0F, -1.0F '   left bottom point (rear wall)
    _glVertex3f 1.0F, 1.0F, -1.0F '    right bottom point (rear wall)

    _glColor3f 0.0F, 0.0F, 1.0F '      blue
    _glVertex3f -1.0F, 1.0F, 1.0F '   right upper point (left wall)
    _glVertex3f -1.0F, 1.0F, -1.0F '  left upper point (left wall)
    _glVertex3f -1.0F, -1.0F, -1.0F ' left bottom point (left wall)
    _glVertex3f -1.0F, -1.0F, 1.0F '  right bottom point (left wall)


    _glColor3f 1.0F, 0.0F, 1.0F ' purple
    _glVertex3f 1.0F, 1.0F, -1.0F ' right upper point (right wall)
    _glVertex3f 1.0F, 1.0F, 1.0F ' left upper point (right wall)
    _glVertex3f 1.0F, -1.0F, 1.0F 'Left bottom point (right wall)
    _glVertex3f 1.0F, -1.0F, -1.0F 'Right bottom point (right wall)

    _glEnd 'quad draw end
    rtri = rtri + 0.52F 'Incrementing the angle of rotation of the triangle
    rquad = rquad - 0.515F 'Incrementing the angle of rotation of the quad

    'it is important to RESET THE AXES so that they are rotated to the basic setting (otherwise the X axis can move to the Y axis) using _glLoadIdentity,
    'and it is EXTREMELY IMPORTANT to always move in the scene to the beginning of the scene using _glTranslateF
    'moving the object in openGL is not done by recalculating _glVertex, but by moving the start of rendering using _glTranslatef
End Sub

[Image: OGL2.png]


More examples will follow.

Print this item

  Children's Clock
Posted by: Petr - 03-25-2023, 02:21 PM - Forum: Petr - No Replies

This is what happens when you have small children at home, they draw something and you show them that the drawing can be used in some way.

Program need H00H.gif file

Code: (Select All)
$NoPrefix
Title "Kids clock"
Dim Shared nrs(14) As Long
'DataCreate "hrsml.txt", "h00h.gif" - not used, is here for you - you can test it, it is way how find numbers to DATA lines in this program
LoadSubImages
Screen NewImage(1024, 768, 32)
CX = 500: CY = 350: A = -_Pi / 2 + _Pi(2) / 12
Circle (535, 419), 340, _RGB32(200)
Paint (535, 419), _RGB32(250), _RGB32(200)
For t = 0 To 11
    Xv = CX + Cos(A) * 250
    Yv = CY + Sin(A) * 250
    A = A + _Pi(2) / 12
    PutImage (Xv, Yv), nrs(t)
Next

PCopy Display, 1
Do Until k&
    k& = KeyDown(27)
    PCopy 1, Display
    Mode = 1
    Select Case Mode '                                   mode: 0 for standard STEPs mode, 1 for smooth steps.
        Case 0
            Hrs = Int(Timer / 3600)
            If Hrs > 12 Then Hrs = Hrs - 12
            Min = Int((Timer / 3600 - Hrs) * 60)
            Secs = Int(Timer - (Hrs * 3600 + Min * 60))
        Case 1
            Hrs = Timer / 3600
            Min = (Hrs - (Int(Timer / 3600))) * 60
            Secs = Timer - (Int(Hrs) * 3600 + Int(Min) * 60)
    End Select

    For HrsSel = 1 To 3
        Select Case HrsSel
            Case 1 'hours
                Asecs = _Pi(2) / 12 * Hrs - _Pi / 2
                iW = 45: iH = 144: Handle = 13: L1 = 170

            Case 2 'minutes
                Asecs = _Pi(2) / 60 * Min - _Pi / 2
                iW = 54: iH = 145: Handle = 14: L1 = 222

            Case 3 'seconds
                Asecs = _Pi(2) / 60 * Secs - _Pi / 2
                iW = 61: iH = 143: Handle = 12: L1 = 200
        End Select

        X1 = 535 + Cos(Asecs - .09) * L1
        X2 = 535 + Cos(Asecs + .09) * L1
        Y1 = 419 + Sin(Asecs - .09) * L1
        Y2 = 419 + Sin(Asecs + .09) * L1

        X3 = 535 + Cos(Asecs - .6) * -20
        X4 = 535 + Cos(Asecs + .6) * -20
        Y3 = 419 + Sin(Asecs - .6) * -20
        Y4 = 419 + Sin(Asecs + .6) * -20

        MapTriangle (0, 0)-(iW, iH)-(0, iH), nrs(Handle) To(X1, Y1)-(X3, Y3)-(X4, Y4)
        MapTriangle (iW, 0)-(0, 0)-(iW, iH), nrs(Handle) To(X2, Y2)-(X1, Y1)-(X3, Y3)
    Next HrsSel
    Display
    Limit 20
Loop

Sub DataCreate (OutputFile As String, InputFile As String) 'this sub is not need for run, but is used between developing this program. This sub create DATA values for us.
    img = LoadImage(InputFile$, 32)
    img2 = CopyImage(img, 32)

    ff = FreeFile
    Open OutputFile$ For Output As #ff
    Screen img
    Do Until k&
        k& = KeyDown(27)
        While _MouseInput: Wend
        MX = MouseX: MY = MouseY
        MB1 = MouseButton(1)
        MB2 = MouseButton(2)
        If MB1 Then
            Do Until MB1 = 0
                PutImage , img2
                Line (MX, MY)-(MouseX, MouseY), &HFF000000, B
                While MouseInput: Wend
                MB1 = MouseButton(1)
                Limit 15
            Loop
            wMX = MX: wMY = MY: wMx2 = _MouseX: wMy2 = _MouseY
        End If
        If MB2 Then
            If wMx2 Then
                r$ = Str$(wMX) + ", " + Str$(wMY) + ", " + Str$(wMx2) + ", " + Str$(wMy2)
                Print #ff, r$
                wMx2 = 0
            End If
        End If
    Loop
End Sub

Sub LoadSubImages
    img = LoadImage("H00H.gif", 32)
    For lsi = 0 To 14
        Read x1, y1, x2, y2, i
        wdth = x2 - x1: hght = y2 - y1
        nrs(i) = _NewImage(wdth, hght, 32)
        PutImage , img, nrs(i), (x1, y1)-(x2, y2)
        SetAlpha 0, _RGB32(255) To _RGB32(200), nrs(i)
    Next
    FreeImage img

    Data 0,4,62,148,12
    Data 69,5,115,150,13
    Data 118,7,172,153,14
    Data 182,9,226,140,8
    Data 226,10,310,134,9
    Data 320,10,430,144,10
    Data 435,11,522,132,11
    Data 1,177,59,270,0
    Data 64,171,130,260,1
    Data 143,170,204,267,2
    Data 211,168,280,269,3
    Data 282,168,330,265,4
    Data 332,167,401,272,5
    Data 402,156,469,274,6
    Data 474,157,518,265,7
End Sub



Attached Files Thumbnail(s)
   
Print this item

  QB64 bug when using Inform
Posted by: TDarcos - 03-24-2023, 06:18 PM - Forum: General Discussion - Replies (17)

I tried using Inform 1.3 with QB64pe as I thought it should work. Well, sometimes it says include files are missing even though the editor says to click on it to open tht file! I change one of the include files to paste it.  Well, that fixed that one. Then it points to a DECLARE LIIBRARY 'falcon' so I copy tie file falcon.h over. Still does not see it. So I comment out the DECLARE statement. That causes the complaint that a later declaratiion is illegal without a correspondind DELARE LIBRARY statement.

Sometimes I think this proram should be named Catch-22 instead.

Print this item

  TiddlyWiki as a context-sensitive help engine
Posted by: CharlieJV - 03-24-2023, 03:55 AM - Forum: Utilities - No Replies

As part of some work I'm doing for a client, I'm setting up the client's applications with context-sensitive help using TiddlyWiki as the context-sensitive help engine.

A small wiki for creating and maintaining documentation is pretty fantastic in and of itself, but the bonus of having that single file doing a stellar job as context-sensitive help engine?  It rocks something silly.

The one TiddlyWiki I've setup is to provide help for five applications, each application having a different set of users.  Depending on the application that brings up the TiddlyWiki instance in a web browser, parameters are included in the URL to alter the appearance of the wiki so that it looks as if it is dedicated to the application that brought it up.

So if you ever want some context-sensitive help for your QB64pe, I highly recommend TiddlyWiki.

Just as an example, here's one TiddlyWiki instance that I've just setup with the ability to generate a link to a specific subject and topic for copying and pasting for sharing:  https://basicanywheremachine.neocities.o...chine#Home

That link is much more complicated than normal when sharing a link to a specific wiki page, but that's because I've completely overridden the TiddlyWiki interface with a custom interface.  So that it doesn't look like a wiki anymore.

Print this item

  parsing code files to identify dependencies?
Posted by: madscijr - 03-23-2023, 09:02 PM - Forum: General Discussion - Replies (2)

From time to time I run into this issue where 

  • I have a program with multiple modules (in QB64, VBA, VBScript, etc.) containing some functions or routines I want to reuse in another program
  • Various routines call other routines, and there is a dependency chain.
  • So I end up having to copy one function at a time, try to compile, see what functions or variable definitions the IDE complains is missing, copy that over, test again, and so on. 
  • For bigger projects, this can take up some time and gets pretty tedious.

If anyone has found any tools or written a script that can parse multiple files of QB-like code, making a map of what functions are contained in each, and parse them all to see what functions they call, so that for function X to work somewhere else, will produce a list of all the routines you'll need to move over (including their dependencies, and so on), I would be interested in hearing about it!

Print this item

  _FullScreen woes
Posted by: madscijr - 03-23-2023, 04:02 PM - Forum: Help Me! - Replies (5)

Hey all, 

I'm trying to display full screen, using example #1 from the wiki (code below), but for some reason the full screen doesn't work.

It's been a while since I used _FullScreen, but I don't recall ever having any problems with it. 

The only thing that changed since then is I changed my monitor from an older 4k Polaroid TV (at 1920x1080) to a Vizio TV (at 1360x768).

This is with QB64PE 3.6.0, but I also get the same behavior with QB64 2.0.2. 

Does anyone know why this might be happening? 

Code: (Select All)
'Screen 12
Screen _NewImage(800, 600, 32): _ScreenMove 0, 0
_FullScreen
If _FullScreen = 0 Then _FullScreen _Off 'check that a full screen mode initialized
Line (100, 100)-(500, 400), 13, BF
Sleep
System

Here is what I am seeing most of the time (black with white outline where the program window was before it went fullscreen):

[Image: Full-Screen-woes-1.png]

Here is another test which seems to result in different output every time I run it (but the _FullScreen never works):
Code: (Select All)
' Running in any of the _FullScreen modes doesn't work...?
' Enabling any of the _FullScreen lines causes one of:
' * displays black with white outline of window & nothing inside, and frozen mouse pointer
' * no screen updating, IDE window is displayed with no screen updating
' * immediately reverts to _FullScreen _Off
' which changes depending on whether program is saved, run 1st or 2nd time, etc.

Screen _NewImage(800, 600, 32): _ScreenMove 0, 0

'_FullScreen
'_FullScreen _SquarePixels
'_FullScreen _Stretch

If _FullScreen = 0 Then _FullScreen _Off 'check that a full screen mode initialized

Line (100, 100)-(500, 400), _RGB32(255, 0, 0), BF
Line (30, 20)-(200, 200), _RGB32(0, 255, 0), BF
Line (400, 300)-(550, 450), _RGB32(0, 0, 255), BF
Locate 30, 1: Color _RGB32(255, 255, 255)
Print "Press any key to exit"

Sleep
System

Any help appreciated...

Print this item

  Basic Chase and Prize Game
Posted by: bplus - 03-23-2023, 09:23 AM - Forum: Programs - Replies (20)

Did not like key action in Bandit so I tried a Keypad setup and got bonus of arrow keys working too Smile

Code: (Select All)
_Title "Basic Chase and Prize Game" ' b+ 2023-03-24
Randomize Timer
Screen _NewImage(640, 480, 32) '80 cols X 30 rows
_ScreenMove 250, 100
Locate 7, 20: Print "*** Basic Chase and Prize Game ***"
Locate 10, 20: Print "H = Hero"
Locate 12, 20: Print "* = Prize"
Locate 14, 20: Print "X = Doom!"
Locate 18, 20: Print "Object: Use NumberPad to Collect prizes,"
Locate 19, 28: Print "don't let Doom come to Hero!"
Locate 25, 20: Print "press any to start...."
Sleep
DoomMoves = 20
HeroX = 40: HeroY = 15
PrizeX = Int(Rnd * 80) + 1: PrizeY = Int(Rnd * 30) + 1
DoomX = Int(Rnd * 80) + 1: DoomY = Int(Rnd * 30) + 1
Do
    Cls ' screen update
    Locate HeroY, HeroX: Print "H";
    Locate PrizeY, PrizeX: Print "*";
    Locate DoomY, DoomX: Print "X";
    If HeroX = PrizeX And HeroY = PrizeY Then
        score = score + 1
        PrizeX = Int(Rnd * 80) + 1: PrizeY = Int(Rnd * 30) + 1
        DoomX = Int(Rnd * 80) + 1: DoomY = Int(Rnd * 30) + 1
        If DoomMoves > 5 Then DoomMoves = DoomMoves - 1
    ElseIf HeroX = DoomX And HeroY = DoomY Then
        Locate 15, 35: Print "Game Over"
        Beep: _Delay 8: _KeyClear: Sleep: Exit Do
    End If
    _Title "Prizes:" + Str$(score)
    kh& = _KeyHit
    Select Case kh& ' top left to bottom right
        Case 55, 18176 ' up and left
            DX = -1: DY = -1
        Case 56, 18432 ' up
            DX = 0: DY = -1
        Case 57, 18688 ' up and right
            DX = 1: DY = -1
        Case 52, 19200 ' left
            DX = -1: DY = 0
        Case 54, 19712 ' right
            DX = 1: DY = 0
        Case 49, 20224 ' left and down
            DX = -1: DY = 1
        Case 50, 20480 ' down
            DX = 0: DY = 1
        Case 51, 20736 ' down and right
            DX = 1: DY = 1
        Case Else
            DX = 0: DY = 0
    End Select
    testX = HeroX + DX: testY = HeroY + DY
    If testX > 0 And testX < 81 And testY > 0 And testY < 31 Then
        HeroX = testX: HeroY = testY
    Else
        Beep
    End If
    lc = lc + 1
    If lc = DoomMoves Then
        DoomX = DoomX + Sgn(HeroX - DoomX): DoomY = DoomY + Sgn(HeroY - DoomY)
        lc = 0
    End If
    _Limit 30
Loop Until _KeyDown(27)

Print this item

  Testing for extended unicode?
Posted by: tothebin - 03-23-2023, 06:01 AM - Forum: Help Me! - Replies (9)

I've done a lot of searching here and in the wiki and can't seem to figure this out. I am reading subtitle (.srt) files for videos, and trying to determine programmatically which are in English. It's actually much easier to look for foreign characters and determine which files are NOT in English. The files are UTF-8. I understand the foreign characters use extended unicode to display, and I think I understand how to use _MAPUNICODE to map ASCII characters to other unicode characters. What I can't seem to find is how to work this the other direction. If I copy some foreign language characters from a text file to the clipboard, say Greek letters, how do I read them from the clipboard and determine they are Greek and not standard ASCII characters? I noticed that when I read these characters from the clipboard using ASC() a single Greek character shows up with several ASCII codes. But how do I know that isn't several 'standard' characters. Is it just a matter of using the right variable type?

Print this item