Welcome, Guest |
You have to register before you can post on our site.
|
Latest Threads |
The QB64 IDE shell
Forum: Utilities
Last Post: JasonPag
09-16-2024, 05:37 PM
» Replies: 9
» Views: 762
|
Importance regarding Ches...
Forum: Utilities
Last Post: JasonPag
09-01-2024, 06:34 PM
» Replies: 0
» Views: 31
|
Chess and Analysis and En...
Forum: Utilities
Last Post: JasonPag
08-28-2024, 02:37 PM
» Replies: 0
» Views: 32
|
DAY 009:_PutImage
Forum: Keyword of the Day!
Last Post: grymmjack
09-02-2023, 02:57 PM
» Replies: 54
» Views: 2,034
|
Fall Banner Contest?
Forum: Site Suggestions
Last Post: grymmjack
08-31-2023, 11:50 PM
» Replies: 36
» Views: 1,261
|
ColorPicker - Function th...
Forum: Dav
Last Post: Dav
08-31-2023, 11:04 PM
» Replies: 3
» Views: 315
|
Goals(1) = New Tile()
Forum: Works in Progress
Last Post: RhoSigma
08-31-2023, 09:45 PM
» Replies: 3
» Views: 127
|
micro(A)v11
Forum: QBJS, BAM, and Other BASICs
Last Post: bplus
08-31-2023, 09:14 PM
» Replies: 90
» Views: 3,589
|
Updating The Single Most ...
Forum: QBJS, BAM, and Other BASICs
Last Post: bplus
08-31-2023, 09:13 PM
» Replies: 7
» Views: 254
|
QBJS Image Question
Forum: QBJS, BAM, and Other BASICs
Last Post: bplus
08-31-2023, 05:49 PM
» Replies: 5
» Views: 155
|
|
|
Embed Text |
Posted by: SMcNeill - 02-17-2023, 02:43 AM - Forum: SMcNeill
- Replies (2)
|
|
An old routine which I found on my drive, which showcases how to embed text into an image and hide it from most folks prying eyes.
EmbedText.7z (Size: 1.1 MB / Downloads: 33)
<-- Grab the archive here, extract, and run with "OUTPUT EXE TO SOURCE FOLDER" enabled in the run menu.
What this does, breaks down to these steps:
1) It loads an image for us.
2) It then embeds text into the image, without disturbing the image in any way noticeable to you. It'll display it on the screen for you to stare at in awe at the sheer lack of text upon it.
3) It then decrypts that text back off from that image and puts it onto a blank canvas, to display for you to stare at in awe, just so you can see that the process here actually works.
Hidden text in images!
I use this all the time for photos and such, to embed names, dates, places, occasions, and whatnot into the image itself, so I can just draw that info out anytime I ever want in the future -- and it still won't be visible for the general public to ever notice.
|
|
|
Are These Dots Spinning? |
Posted by: bplus - 02-15-2023, 08:38 PM - Forum: Programs
- Replies (6)
|
|
Code: (Select All) _Title "Do the dots in disk look like they are spinning?" ' B+ 2019-01-12
'try an optical illusion saw on Internet
Const xmax = 600
Const ymax = 600
Screen _NewImage(xmax, ymax, 32)
_ScreenMove 300, 60
x0 = xmax / 2: y0 = ymax / 2: a24 = _Pi(2 / 24): r = 240
While _KeyHit <> 27
If loopcnt < 2 Then stopit = 11
If loopcnt = 2 Then stopit = 0
If loopcnt > 2 Then
If stopit < 11 Then stopit = stopit + 1
End If
For a = 0 To _Pi(2) Step _Pi / 180
Color _RGB32(128, 0, 0): fcirc x0, y0, 251
For i = 0 To stopit
If loopcnt > 1 Then
xs = x0 + r * Cos(a24 * i)
ys = y0 + r * Sin(a24 * i)
xe = x0 + r * Cos(a24 * i + _Pi)
ye = y0 + r * Sin(a24 * i + _Pi)
Line (xs, ys)-(xe, ye), _RGB32(255, 255, 255)
End If
x = x0 + Cos(a + _Pi(i / 12)) * r * Cos(a24 * i)
y = y0 + Cos(a + _Pi(i / 12)) * r * Sin(a24 * i)
Color _RGB32(255, 255, 255)
fcirc x, y, 10
Next
_Display
_Limit 90
Next
loopcnt = loopcnt + 1
Wend
'Steve McNeil's copied from his forum note: Radius is too common a name
Sub fcirc (CX As Long, CY As Long, R As Long)
Dim subRadius As Long, RadiusError As Long
Dim X As Long, Y As Long
subRadius = Abs(R)
RadiusError = -subRadius
X = subRadius
Y = 0
If subRadius = 0 Then PSet (CX, CY): Exit Sub
' Draw the middle span here so we don't draw it twice in the main loop,
' which would be a problem with blending turned on.
Line (CX - X, CY)-(CX + X, CY), , BF
While X > Y
RadiusError = RadiusError + Y * 2 + 1
If RadiusError >= 0 Then
If X <> Y + 1 Then
Line (CX - Y, CY - X)-(CX + Y, CY - X), , BF
Line (CX - Y, CY + X)-(CX + Y, CY + X), , BF
End If
X = X - 1
RadiusError = RadiusError - X * 2
End If
Y = Y + 1
Line (CX - X, CY - Y)-(CX + X, CY - Y), , BF
Line (CX - X, CY + Y)-(CX + X, CY + Y), , BF
Wend
End Sub
No...
|
|
|
Snapshots in QB64? |
Posted by: 40wattstudio - 02-15-2023, 03:03 AM - Forum: Help Me!
- Replies (11)
|
|
Recently I've been learning about saving data in games. It seems like most games only save the variables that have changed during the course of gameplay. But with this method you have to specify which variables get saved and that can be an extremely long list to keep track of.
So my question is: I've heard about some games using snapshots (hoping that's the right term), where instead of saving just a handful of variables, it saves the entire state of the entire game at that moment so it can be loaded later. Is there a way to do that in QB64? Though I've never used them before, I'm aware of all the _MEM commands and I imagine it can be done using those, but I have no clue how to do so and haven't seen any practical tutorials.
|
|
|
Array in an array |
Posted by: NasaCow - 02-15-2023, 12:44 AM - Forum: Help Me!
- Replies (79)
|
|
Happy Year of the Rabbit. Back to work and also back to programming. The holiday break was nice....
So I am trying to rack my head how to store this. Let me show what I have and then maybe someone can call me an idiot and point out an eaiser way of making everything work
The gradebook:
As we can see I am going for something a little more complicated than just enter numbers and call it a day. I want it to be flexiable. Able to add and drop students. Being pulled from the report side of the program
The student data:
Code: (Select All) TYPE NameListType 'Used for the student name database
PinYinName AS STRING * 20
FirstName AS STRING * 20
MiddleName AS STRING * 20
LastName AS STRING * 20
Year AS INTEGER
Month AS INTEGER
Day AS INTEGER
HouseColor AS STRING * 8
MomName AS STRING * 30
MomPhone AS STRING * 20 'Saved as string to support symbols and international prefixes
MomEmail AS STRING * 38
DadName AS STRING * 30
DadPhone AS STRING * 20
DadEmail AS STRING * 38
UID AS INTEGER
END TYPE
The key I believe is to have a unique id number for each student (UID), positive values will be current students and deleted students will have the value made negative. So we can keep grades with names by having the grade database match this one.
Ok so far....
This is where I run into trouble, one assignment, has details and many students with multiple details. How to combine?
Assignment file (Master):
Code: (Select All) TYPE MasterAssignmentType 'Each entry needs to be defined before use with slave
ARName AS STRING * 20 'Assignment report name
ADName AS STRING * 10 'Assignment display name (short name)
AType AS UNSIGNED BYTE 'Assignment Type (Completeion, formative, summative, etc.)
ACat AS STRING * 20 'Assignment Category (subject, unit, etc)
AColor AS UNSIGNED BYTE 'Color coding assignment headers and for grouping for reports
ACode AS UNSIGNED BYTE 'Reserved
APts AS UNSIGNED INTEGER 'Total points allowed
END TYPE
Slave file (for student details):
Code: (Select All) TYPE SlaveAssignmentType 'Each student would require one with use with master
UID AS INTEGER 'UID will match the stuedent name list to match results, negative UID means deleted and we will ignore it on display and reports
MPts AS UNSIGNED INTEGER 'Points earned for each particular students
Flags AS UNSIGNED BYTE 'See below for codes
Flags2 AS UNSIGNED BYTE ' Reserved
Notes AS STRING * 512 'Comments for a student's work
END TYPE
'====================Flag codes====================
'1 - Late (Turned in late) |
'2 - Absent on due date (ignore due date) |
'4 - Incomplete (turned in but not done) |
'8 - Missing (Not turned in) |
'16 - Excused/Exempt |
'32 - Ignore score internally for avg, etc. |
'64 - Remove from reports (ignore externally) |
'128 - Reserved |
'==================================================
Now this is where I am in trouble.
Now I could make a file for each student with the slave but that seems.... excesive. I tried to combine both with an array but, as far as I know, it doesn't work. I want to do something like SlaveFile (UIDs(40), 500) with 40 being for UIDs and 500 for the UDT SlaveFile (something like an array in an array or jagged array). I just don't know the context for this or the workaround to get what I want....
Tried it out in a smiple way and it doesn't work the way I thought it would
Code: (Select All) OPTION _EXPLICIT
TYPE Test
X AS INTEGER
y AS INTEGER
z AS STRING
END TYPE
TYPE UID
ID AS INTEGER
END TYPE
DIM AS INTEGER abc(1 TO 4)
DIM AS Test xyz(1 TO 10, abc())
abc(3) = 2
xyz(1, abc(1)).X = 5
xyz(1, abc(2)).y = 3
PRINT xyz(1, abc(1)).X
PRINT xyz(1, abc(2)).y
PRINT abc(3)
PRINT xyz(1, abc(4)).X
Like I said, there is likely a much easier way (I can be a stubborn Polock after all and make things more complicated than I need to!)
You guys are amazing and I look forward to your wisdom and advide!
|
|
|
IDE for Windows like the official one? |
Posted by: Ikerkaz - 02-14-2023, 02:36 PM - Forum: General Discussion
- Replies (25)
|
|
Hello to everyone.
It's just an idea. Would it be possible to build an IDE with auto tabbing and syntax checking, just like the official IDE but for Windows?
I'm not quite convinced by the current text-mode IDE, and Notepad++ doesn't have error checking and auto tabbing. Thanks and sorry for the question, I understand that the current IDE already has a lot of work done. I would not want to belittle the work of the creators.
|
|
|
Recursion: 4 ways to get it working |
Posted by: TempodiBasic - 02-14-2023, 01:27 PM - Forum: Help Me!
- Replies (16)
|
|
Hi
I think that this demo is clear enough to be used as example about recursion in QB64pe.
I must remark that the STATIC way has is goal in preserving the previouse values of variable of the SUB/FUNCTION.
So if we need to preserve few variables we can use STATIC into the SUB to declare the variable to preserve,
instead if we need to preserve all variable or the more part of local variables we use STATIC in SUB/FUNCTION declaration.
Code: (Select All) Rem Demonstration of variables into recursive calling
Screen 0
Dim counter As Single
Dim Shared counter2 As Single
Dim Choice As String
Choice = " "
Do
If Choice <> "" Then
Cls
Print "we are testing recursive calling"
Print String$(60, "#")
Print "please make your choice: "
Print " press 1 for recursion without parameter or shared variable"
Print " press 2 for recursion with parameter and no shared variable"
Print " press 3 for recursion with shared variable and no parameter"
Print " press 4 for STATIC recursion without parameter or shared variable"
Print " press 0 to exit from demonstration"
Print String$(60, "#")
End If
Choice = InKey$
If Choice = "0" GoTo Ending
If Choice = "1" Then GoSub NoParameters
If Choice = "2" Then GoSub YesParameters
If Choice = "3" Then GoSub SharedVariable
If Choice = "4" Then GoSub StaticNoParameters
Loop
End
NoParameters:
counter = 0
Print " No parameter and no shared variable demo"
Print "-----------------------------------------"
Print counter; " value of flag in the main"
RecursiveNoParameters
Return
YesParameters:
counter = 0
Print " Yes parameter and no shared variable demo"
Print "------------------------------------------"
Print counter; " value of flag in the main"
RecursiveYesParameters counter
Return
SharedVariable:
counter2 = 0
Print " No parameter and Yes shared variable demo"
Print "------------------------------------------"
Print counter2; " value of flag in the main"
SharedVariables
Return
StaticNoParameters:
counter = 0
Print " STATIC and no parameter and no shared variable demo"
Print "-----------------------------------------"
Print counter; " value of flag in the main"
StaticNoParameter
Return
Ending:
Rem here the flow of code ends
End
Sub RecursiveNoParameters
counter = counter + 1
DoJob counter
If InKey$ <> "" Then Exit Sub ' emergency exit
If counter < 10 Then RecursiveNoParameters
End Sub
Sub RecursiveYesParameters (c As Single)
c = c + 1
DoJob c
If InKey$ <> "" Then Exit Sub ' emergency exit
If c < 10 Then RecursiveYesParameters c
End Sub
Sub SharedVariables
counter2 = counter2 + 1
DoJob counter2
If InKey$ <> "" Then Exit Sub ' emergency exit
If counter2 < 10 Then SharedVariables
End Sub
Sub StaticNoParameter
Static counter ' you need to have STATIC only the flag of recursion, at least
counter = counter + 1
DoJob counter
If InKey$ <> "" Then Exit Sub ' emergency exit
If counter < 10 Then StaticNoParameter
End Sub
Sub DoJob (c As Single)
Print c; " press a key to stop the recursive loop"
Sleep 1 ' we need this to avoid the crash of application
End Sub
more explanation and tips coming soon.
|
|
|
Square brackets and curly brackets in expressions? |
Posted by: CharlieJV - 02-13-2023, 05:49 PM - Forum: QBJS, BAM, and Other BASICs
- Replies (12)
|
|
I'm thinking of adding the ability to use curly brackets and square brackets in expressions, along with parentheses, to make complex expressions easier to read.
But not if square brackets (i.e. [ and ] ) and curly brackets (i.e. { and } ) are used in any way as special characters in QB64pe.
Are square brackets and/or curly brackets used for any purpose in QB64pe? (I haven't noticed any.)
|
|
|
Smarter than a fb Worm |
Posted by: bplus - 02-13-2023, 05:44 PM - Forum: Programs
- Replies (4)
|
|
This snake never goes hungry:
Code: (Select All) _Title "Snake AI-1.1" 'b+ 2020-03-16
'2020-03-14 Snake AI-1 first post
'2020-03-16 Snake AI-1.1 there must be overlap of the snake somewhere!
Const sq = 20, sqs = 20, xmax = 400, ymax = 400
Screen _NewImage(xmax, ymax, 32)
_Delay .25
_ScreenMove _Middle
Randomize Timer
Dim X(xmax + 100), Y(ymax + 100), overlap(19, 19) As Integer
hx = 10: hy = 10: ax = 15: ay = 15: top = 0: X(top) = hx: Y(top) = hy 'initialize
Do
_Title Str$(top + 1)
Line (0, 0)-(xmax, ymax), &HFF006600, BF 'clear garden
'>>>>>>>>>>> SNAKE BRAIN <<<<<<<<<<<<<<<
If hx = 0 And hy = 19 Then
hy = hy - 1
ElseIf hx Mod 2 = 0 And hy <> 0 And hy <> 19 Then
hy = hy - 1
ElseIf hx Mod 2 = 0 And hy = 0 And hy <> 19 Then
hx = hx + 1
ElseIf hx Mod 2 = 1 And hx <> 19 And hy < 18 Then
hy = hy + 1
ElseIf hx Mod 2 = 1 And hx <> 19 And hy = 18 Then
hx = hx + 1
ElseIf hx = 19 And hy = 19 Then
hx = hx - 1
ElseIf hy = 19 And hx <> 0 Then
hx = hx - 1
ElseIf hx Mod 2 = 1 And hy = 0 And hy <> 19 Then
hy = hy + 1
ElseIf hx = 19 And hy < 19 Then
hy = hy + 1
End If
For i = 0 To top - 1
X(i) = X(i + 1): Y(i) = Y(i + 1)
Next
X(top) = hx: Y(top) = hy
'apple
If (ax = hx And ay = hy) Then 'snake eats apple, get new apple watch it's not where snake is
top = top + 1
X(top) = hx: Y(top) = hy
Do 'check new apple
ax = Int(Rnd * sqs): ay = Int(Rnd * sqs): good = -1
For i = 0 To top - 1
If ax = X(i) And ay = Y(i) Then good = 0: Exit For
Next
Loop Until good
End If
Line (ax * sq, ay * sq)-Step(sq - 2, sq - 2), _RGB32(255, 100, 255), BF
'snake
Erase overlap
For i = 0 To top
If i = top Then
c~& = &HFF000000
Else
Select Case (top - i) Mod 4
Case 0: c~& = &HFF000088
Case 1: c~& = &HFF880000
Case 2: c~& = &HFFBB8800
Case 3: c~& = &HFF008888
End Select
End If
overlap(X(i), Y(i)) = overlap(X(i), Y(i)) + 1
Line (X(i) * sq, Y(i) * sq)-Step(sq - 2, sq - 2), c~&, BF
If overlap(X(i), Y(i)) > 1 Then Line (X(i) * sq + .25 * sq, Y(i) * sq + .25 * sq)-Step(.5 * sq - 2, .5 * sq - 2), &HFFFFFFFF, BF
Next
_Display
If top < 10 Then
_Limit 10 + top
ElseIf top < 300 Then
_Limit 100
Else
_Limit 10
End If
Loop
And it's the dumbest snake I have!
|
|
|
|