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

Username/Email:
  

Password
  





Search Forums

(Advanced Search)

Forum Statistics
» Members: 492
» Latest member: Feederumn
» Forum threads: 2,834
» Forum posts: 26,556

Full Statistics

Latest Threads
Sound Effects Generator (...
Forum: Petr
Last Post: Petr
8 minutes ago
» Replies: 0
» Views: 4
Problems with QBJS
Forum: Help Me!
Last Post: bplus
28 minutes ago
» Replies: 4
» Views: 80
which day of the week
Forum: Programs
Last Post: bplus
39 minutes ago
» Replies: 31
» Views: 679
another variation of "10 ...
Forum: Programs
Last Post: bplus
45 minutes ago
» Replies: 3
» Views: 101
sleep command in compiler...
Forum: General Discussion
Last Post: SMcNeill
4 hours ago
» Replies: 3
» Views: 74
Another Dir/File compare ...
Forum: Utilities
Last Post: eoredson
Today, 03:48 AM
» Replies: 0
» Views: 39
Aloha from Maui guys.
Forum: General Discussion
Last Post: madscijr
Yesterday, 04:33 PM
» Replies: 8
» Views: 153
Playing sound files in QB...
Forum: Programs
Last Post: ahenry3068
Yesterday, 05:37 AM
» Replies: 9
» Views: 1,192
Rock Jockey 2.0 is ready ...
Forum: Games
Last Post: NakedApe
01-09-2025, 09:02 PM
» Replies: 20
» Views: 635
Button rack or hotkey fun...
Forum: Utilities
Last Post: Jack002
01-09-2025, 08:20 PM
» Replies: 6
» Views: 409

 
Question compile speed/options?
Posted by: BlameTroi - 06-04-2023, 09:48 PM - Forum: General Discussion - Replies (5)

I got the itch to do some Basic again and found out about the split and decided to follow along with QB64PE. I'm on Windows 11 and on both a rather old laptop (Thinkpad T480 but 8th gen i5) and a very new AMD system the compiler seems slower than I remember on my old desktop.

I suspect it's the compiler start up time since I don't notice a difference between very small programs and larger samples I've downloaded, so there may be nothing I can do but felt I should ask. Searching didn't turn up anything.

Thanks.

Troy.

Print this item

  Simple SpriteSheet Editor step by step in QB64pe
Posted by: TempodiBasic - 06-04-2023, 05:04 PM - Forum: Works in Progress - Replies (5)

Hi
this is a first version of a SpriteSheet editor: a program that loads a SpriteSheet and let you modify it painting with simple tools or/and lets to select an area as a single sprite into the sheet. After selected the sprites, you can save their cohordinates into a DATA file to use into your code with the original  SpriteSheet and you can see the selected sprite shown on the screen.

[Image: Selected-sprites-Sprite-Sheet-Editor.png]



[Image: Save-to-DATA-file-Sprite-Sheet-Editor.png]


It is a project step by step:
this first step brings a program with a main window that will be adapted to the spritesheet loaded and on this the user can define the 2 points to select an area of the picture to do a single sprite. You can accept/store or cancel each point selected before, after stored point 1 and 2 you get the sprite that is highlighted by a red square. 
You can stop the selecting function pressing spacebar into the main loop or mousebutton2 while you are selecting the point 2.

the selected sprites will be displayed at the end of the procedure of selection.


[Image: Selected-sprites-showed-on-the-screen-Sp...Editor.png]


This program uses a second area /canvas to give output to the user as messages or warnings or instructions.
I have posted some screenshots.

It is really incomplete but it can grow up if I use Option _explicit avoiding to waste so much time with bugs going out from my typo errors!

Code: (Select All)
Option _Explicit

Rem SPRITE SHEET EDITOR
Rem this software has the purpouse to load an image of a sprite sheet
Rem and in SELECT MODE it allows to the user to select an area,
Rem or in EDIT MODE to paint changing the images into the sprite sheet

_Title "SpriteSheet Editor"
Const W = 1200, H = 800

'global varables
Dim Shared Main&, Sprite&, NameFile$, SSheet&, HelpS&
ReDim Sprites&(1 To 1)
Dim Shared As Integer Xm(1 To 2), Ym(1 To 2), SprC(1 To 4, 1 To 100)
' main variables
Dim Mg As Integer, a As Integer, Mb1 As Integer, Mb2 As Integer, kb As Integer, spr As Integer

Main& = _NewImage(W, H, 32)
HelpS& = _NewImage(W, H / 4, 32)

Screen Main&
_PrintString ((W / 2) - (10 * 8), H / 2), "SPRITES SHEET EDITOR" ' the title is 20 characters
_Delay 3
_SetAlpha 125, HelpS& ' area of output is half transparent
LoadI
Mg = 13: a = 0 'Mg pixel between 2 lines of the reticulus, a is a counter

While kb <> 32 ' while user does not press spacebar, he can define area on the screen delimiting sprites to capture into single area/canvas
    Helping " Press spacebar to end", 1
    If MouseData(Mb1, Mb2) = -1 Then 'it evaluates mouseinput
        If Mb1 Then 'did mouse button 1 trigger?
            ' it starts the procedure for storing X an Y of points 1 (topleft) and 2 (bottomright)
            If StoreMouseData(1) = -1 Then ' it stores mouse data  for topleft point of sprite
                While 1
                    Helping " Press spacebar to end", 1
                    Helping Str$(_MouseX) + Str$(_MouseY) + Space$(8), 0
                    '_Dest HelpS&: Locate 4, 26: Print kb; Space$(10);
                    'Locate 5, 1: Print _MouseX, _MouseY; Space$(8);: _Dest 0
                    '_PutImage (0, 2 * (_Height(0))), HelpS&,

                    If MouseData(Mb1, Mb2) = -1 Then ' it evaluates mouse input
                        Helping " Press spacebar to end", 1
                        Helping Str$(_MouseX) + Str$(_MouseY) + Space$(8), 0
                        ' it adjourns the keyboard and mouse information
                        '_Dest HelpS&: Locate 4, 26: Print kb; Space$(10);
                        'Locate 5, 1: Print _MouseX, _MouseY; Space$(8);: _Dest 0
                        '_PutImage (0, 2 * (_Height(0))), HelpS&,

                        If Mb1 Then 'did  mousebutton 1 trigger?
                            If StoreMouseData(2) = -1 Then ' yes, it stores  mouse data bottomright
                                ' after confirming the two points of the sprite it memorizes their cohordinates into SprC array
                                spr = spr + 1 ' sprite counter
                                SprC(1, spr) = Xm(1): Xm(1) = 0 'X1
                                SprC(2, spr) = Ym(1): Ym(1) = 0 'Y1
                                SprC(3, spr) = Xm(2): Xm(2) = 0 'X2
                                SprC(4, spr) = Ym(2): Ym(2) = 0 'Y2
                                Line (SprC(1, spr), SprC(2, spr))-(SprC(3, spr), SprC(4, spr)), _RGB32(233, 0, 6), B
                                Helping Str$(spr) + "/" + Str$(SprC(1, spr)) + "+" + Str$(SprC(2, spr)) + "--" + Str$(SprC(3, spr)) + "+" + Str$(SprC(4, spr)), 0
                                _Delay 1
                                Exit While ' after storing point 2 of sprite it returns to external loop
                            Else
                                Helping "To exit press mouse button 2", 0
                                _Delay 2
                            End If
                        End If
                        If Mb2 = -1 Then Exit While
                    End If
                Wend
            End If
            ' if no data stored for point 1 topleft it runs again the loop
        End If
    End If

    kb = _KeyHit
    ' escaping way
    If kb = 13 Then Grid
    Helping Str$(kb), 0
    Helping Str$(_MouseX) + Str$(_MouseY), 0
    While _MouseInput: Wend ' it voids the mouse buffer
    _Limit 10
Wend
Screen Main&
Helping "Save data of sprites into a DATA code file (Y/N)?", 1
kb = 0
While kb = 0
    kb = _KeyHit
    If kb = 89 Or kb = 121 Then SaveDATAtoFile: Exit While 'Y or y
    If kb = 78 Or kb = 110 Then Exit While ' N or n
    kb = 0
Wend
' getting single sprites with newimage
ReDim Sprites&(1 To spr), x As Integer, y As Integer
For a = 1 To spr
    Sprites&(a) = _NewImage(Abs(SprC(1, a) - SprC(3, a)), Abs(SprC(2, a) - SprC(4, a)), 32)
    _PutImage , Sprite&, Sprites&(a), (SprC(1, a), SprC(2, a))-(SprC(3, a), SprC(4, a)) 'it copies area of spritesheet to single area/canvas
    x = x + _Width(Sprites&(a)) ' it adjourns the cohordinates X for showing sprites in sequence
    y = _Height(Sprites&(a))
    _PutImage (x, y), Sprites&(a), 0 ' showing sprites from 1 to top
Next a

End

Sub SaveDATAtoFile
    Rem Saveto DATA file
    Rem save to file in DATA format the array SprC
    Dim n As Integer
    Open "Datafile.txt" For Output As #1
    Helping "Saving data...", 0
    Print #1, "Data";
    For n = 1 To 100 Step 1
        If SprC(1, n) = 0 Then _Continue ' if it finds a wrong value it exits from FOR loop
        If (n Mod 9) = 0 Then Print #1,: Print #1, "Data"; Else If n > 1 Then Print #1, ",";
        Print #1, SprC(1, n), ",", SprC(2, n), ",", SprC(3, n), ",", SprC(4, n);
    Next
    Close #1
    Helping "Saved data!", 1
End Sub

Function MouseData (Mb1 As Integer, Mb2 As Integer)
    MouseData = 0
    While _MouseInput: Wend ' it waits that mouse input ends
    Mb1 = _MouseButton(1)
    Mb2 = _MouseButton(2)
    If Mb1 <> 0 Or Mb2 <> 0 Then MouseData = -1 ' if no mousebutton then function returns failure
End Function

Function StoreMouseData (Index As Integer)
    Dim kb As Integer, OldC As Long
    StoreMouseData = 0
    If _MouseX > 0 Then Xm(Index) = _MouseX Else Xm(Index) = 1 ' it corrects wrong 0 values
    If _MouseY > 0 Then Ym(Index) = _MouseY Else Ym(Index) = 1


    If Xm(Index) > 0 And Ym(Index) > 0 Then
        ' both cohordinates are good?
        Helping "Storing point " + Str$(Index) + Str$(Xm(Index)) + "-" + Str$(Ym(Index)) + " Cancel/Store?", 0
        OldC = Point(Xm(Index), Ym(Index))
        PSet (Xm(Index), Ym(Index)), _RGB32(211, 255, 6)

        While 1 'kb <> 83 Or kb <> 115
            ' here the loop to take cancel/store data
            kb = _KeyHit

            If kb = 67 Or kb = 99 Then
                PSet (Xm(Index), Ym(Index)), OldC
                Exit Function ' if key is c or C then exit function returning the  failure
            End If
            If kb = 83 Or kb = 115 Then Exit While
        Wend
        Helping "Stored", 0
        _Delay 1
        StoreMouseData = -1
    Else
        Exit Function
    End If
End Function

Sub Grid
    Shared Mg As Integer, a As Integer
    For a = 1 To W Step Mg
        Line (a, 1)-(a, W), Mg
    Next
    For a = 1 To H Step Mg
        Line (1, a)-(H, a), Mg
    Next
End Sub

Sub LoadI
    NameFile$ = ".\defendersprites.jpg" '<----- coming soon Open option to type name of file and better an Opendialog box
    If _FileExists(NameFile$) Then
        Helping "File founded", 1
        Sprite& = _LoadImage(NameFile$)
    Else
        Helping "Error: image not loaded", 1
        Sprite& = -1000 ' sprite& brings the failure flag
        _Delay 2
        Exit Sub
    End If
    _Delay 1
    SSheet& = _NewImage(_Width(Sprite&), _Height(Sprite&), 32)
    Screen SSheet&
    _PutImage , Sprite&, 0
End Sub

Sub PaletteS
    Dim n As Integer
    For n = 1 To 256
        'pset (n,1),n
        Line (n, 1)-(n, 256), n, BF
    Next n
    Sleep 2
End Sub

Sub Helping (Msg As String, M As Integer)
    _Dest HelpS&
    If M = 1 Then Cls
    Print Msg
    _Dest 0
    _PutImage (0, 2 * (_Height(0) / 3)), HelpS&,
End Sub

Welcome feedbacks and propositive criticisms.

I'm thinking to add a third way to select the area with a dragging of mouse like in the graphic editor in which you draw a square/rectangle.
Moreover I need an OpenDialog box to choose the file of the Spritesheet to modify. I think that the created/selected sprites must be managed like in a list box with a single/multiple selection for doing specific actions (Save, Cancel, Edit...).
I have never used a SpriteSheet Editor but I'm doing it from zero with poor plan... this will cause so much modifications! Sob. Better measures twice and cut ones.

this is the spritesheet that I have used as file, but use whatever do you want


[Image: defendersprites.jpg]

Print this item

  Option _Explicit Keyword(s) of day XXX:
Posted by: bplus - 06-04-2023, 04:29 PM - Forum: Keyword of the Day! - Replies (27)

This thread started so people can talk about Option _Explicit without hijacking other threads.

Use Option _Explicit in your code to save yourself from typos, probably the number one cause of grief to any coder on any level.

Yes it forces you to declare every variable you use. Yes Dimster that includes For ... Next index variables.

If declared variable is a Const, you don't have to DIM it, same goes for Static, same goes for ReDim (or should).

But there is an interesting by-pass, if I recall, stay tuned... Nope! the example I had in mind didn't work as I remembered.

Print this item

  QB64PE Programs being flagged as having trojans
Posted by: hanness - 06-04-2023, 02:30 AM - Forum: General Discussion - Replies (7)

I have multiple programs that I have written in QB64PE that get flagged by Windows Defender on Windows 11 as having trojan malware.

For now I've been setting exceptions in the antivirus software, but I'm wondering if there is any other kind of strategy to avoiding this in the future.

Print this item

  Nothing to see here
Posted by: SMcNeill - 06-03-2023, 07:11 PM - Forum: General Discussion - Replies (4)

Just testing some junk with Discord.

Print this item

  Welcome grymmjack as Forum Guru!
Posted by: SMcNeill - 06-03-2023, 06:53 PM - Forum: General Discussion - Replies (12)

Everyone give a big hand of applause and many thanks to grymm for volunteering to step up and help with our server and forum maintenance and usability.  Pete was helping me with these things, but he's wandered off into the sunset after all the flooding his area of the world got since last December, and nobody's heard from him since.  (Let's all pray he's good and just dealing with insurance issues and such and simply hasn't felt like being indoors or programming for a while, and that nothing bad happened to him.)

Grymm's taken over handling our back-end server maintenance, and it's all thanks to him and @dbox that we can now embed QBJS in posts here and run those programs and examples.  He's currently at work on integrating our forum notifications so they appear in Discord for us, and who knows what improvements, optimizations, and fixes he'll bring in the future!  (After all, he's only been on the job for all of 2 days now, I think, and he's already finished the QBJS iFrame stuff!)

Any suggestions, issues, fixes, kindly @grymmjack with your concerns, and be certain to thank him for all his hard work and efforts.  Like everyone else who contributes to this project, grymm is doing so of his own free will and in his own free time, with no pay or reimbursement for his work.  Let him know if there's something he might can look into and help with, but as always -- be respectful and don't expect things to change instantly just cause someone reported something or requested something.  He's got a life, and he's got a right to live it first and foremost -- like any other dev here -- and even moreso, he now has admin rights and can ban those who are too pestersome for him....  

Wink

Print this item

Lightbulb qbjs evolving program #1
Posted by: grymmjack - 06-03-2023, 05:27 PM - Forum: QBJS, BAM, and Other BASICs - Replies (28)

On IRC back in the day, we used to play "neverending story".

How it worked:

The first person would provide a sentence or paragraph.

The next person picks up where that last person left off and continues.

e.g.:

First person: Once upon a time there was a pig that
Second person: had smelly breath and could talk like a human.

Story then is concatenated from that point:

"Once upon a time there was a pig that had smelly breath and could talk like a human."

... repeat ...

Let's try the same thing with qbjs!

The only change would be that you have to copy and paste the code from what you make into a new one in the qbjs.org site to get your version to persist for everyone. The other thing would be we should try to preserve what already is there, but extend on it. That is, don't do asshole things like in a SCREEN 0 text start thing, CLS the damned screen (be kind and have fun)?

Let's see what happens and where it goes.

@dbox you go first!

Print this item

  BAM thingies in the works
Posted by: CharlieJV - 06-03-2023, 03:36 AM - Forum: QBJS, BAM, and Other BASICs - Replies (19)

Currently in the works (click here for details; click here to try the test version of BASIC Anywhere Machine)

  • Documentation: setup the architectural components for syntax diagrams, and start using/testing syntax diagrams with the statements/functions/operators below
  • Enhanced debugging: added generic code issue notification and viewing mechanism, and specific catching missing definitions for SUB and FUNCTION declarations
  • Added UrlQueryString$ function
  • Added UrlKey$ function
  • Added IFF function
  • Added MIN and MAX functions
  • Added BIN$ keyword (alternative name for already existing _BIN$ function)
  • Added DAY$ function
  • Added DIV keyword (alternative for the already existing "\", i.e. integer division, operator)
  • Added FRAC function
  • Added BETWEEN function
  • Added CHOOSE function
  • Enhanced compatibility of DEFtype statements
  • Enhanced compatibility of _BIN$, HEX$, OCT$ functions
  • Enhanced compatibility of SLEEP statement
  • Enhanced compatibility of INSTR function 
  • Enhanced compatibility of RANDOMIZE function 
  • Enhanced compatibility of INTEGER data type
  • Fixed the WIDTH statement: fixed a little glitch and documented behaviour
  • Added the HEIGHT statement (WIDTH specifying the number of text columns, why not be able to specify the number of rows?)
  • Added PUTSTRING statement
  • Added SCROLL statement

Print this item

  niXman gcc-13.1.0
Posted by: Jack - 06-02-2023, 10:14 AM - Forum: General Discussion - Replies (8)

niXman has updated gcc version from 12.2.0 to 13.1.0, I tried it and so far no problems

Print this item

  On Exit question
Posted by: NasaCow - 06-02-2023, 03:50 AM - Forum: Help Me! - Replies (52)

I am trying to control exiting to prevent work from getting loss and adding some basic code related to EXIT is having my program crash out with Error 10 - Duplicate definition (The error points to the label ShutDown). I tried to step through it to see how the program flows exactly but with no success. Is running the timer all the time to check a bad idea for complex programs? Getting it to work with a simple loop seems to be no problem, inserting into Grade Keeper seems to be breaking something...


Quote:'Disabling the default exit routinue
ExitFlag = EXIT
ON TIMER(1) GOSUB ShutDown
TIMER ON
...
ShutDown:
ExitFlag = EXIT
IF ExitFlag THEN SYSTEM
RETURN

Print this item