Posts: 3,936
Threads: 175
Joined: Apr 2022
Reputation:
216
10-05-2023, 08:49 PM
Thanks @Dav that is interesting effect I will play with later. Right now tied up with a couple other projects otherwise I'd be more active with several of your posts. But I Like what you've done with your balls LOL!
b = b + ...
Posts: 3,936
Threads: 175
Joined: Apr 2022
Reputation:
216
10-08-2023, 02:13 PM
(This post was last modified: 10-08-2023, 02:51 PM by bplus.)
DRAW Contest Fun Mod
QB64.boards.net is having a contest practicing with DRAW command.
MG posted something that I started playing with and came up with this nice mod:
Code: (Select All) ' Mod MG DRAW by bplus 2023-10-08
'ref https://qb64.boards.net/thread/219/qb64-dev-competition-idea?page=2&scrollTo=1228
Dim i As Integer, ai As Integer, cc As Integer, u As Integer
Dim a$, s$
Randomize Timer
Screen 13
Do
a$ = ""
Do Until Len(a$) > 20
If Random1(2) = 1 Then
If Random1(2) = 1 Then a$ = a$ + "L" Else a$ = a$ + "R"
Else
If Random1(2) = 1 Then a$ = a$ + "D" Else a$ = a$ + "U"
End If
a$ = a$ + Str$(Rand(1, 15))
Loop
s$ = a$
Cls
For i = 1 To 24
stepper = Val(Mid$(" 10 12 15 18 20 30 40 45 60 72 90120180", Int(Rnd * 13) + 1, 3))
For ai = 0 To 360 - stepper Step stepper
cc = Rand(64, 160)
If i > 10 Then u = 10 Else u = i
If i Mod 2 Then cc = 9 Else cc = 15
PSet (160, 100)
'Draw "ta0" ' this needed?
a$ = "S" + Str$(22 - u * 2) + "TA" + Str$(ai) + "C" + Str$(cc) + s$
Draw a$
Next
Next
Print "spacebar for another, esc to quit"
Sleep
Loop Until Asc(InKey$) = 27
Function Rand& (fromval&, toval&)
Dim sg%, f&, t&
If fromval& = toval& Then
Rand& = fromval&
Exit Function
End If
f& = fromval&
t& = toval&
If (f& < 0) And (t& < 0) Then
sg% = -1
f& = f& * -1
t& = t& * -1
Else
sg% = 1
End If
If f& > t& Then Swap f&, t&
Rand& = Int(Rnd * (t& - f& + 1) + f&) * sg%
End Function
Function Random1& (maxvaluu&)
Dim sg%
sg% = Sgn(maxvaluu&)
If sg% = 0 Then
Random1& = 0
Else
If sg% = -1 Then maxvaluu& = maxvaluu& * -1
Random1& = Int(Rnd * maxvaluu& + 1) * sg%
End If
End Function
Wow I like all the variations this thing can make! Maybe we can call these hairy balls.
Update: Wow this works in QBJS without a single change!!!
DRAW contest b+ mod of MG
Dav I am gonna try your thing next ;-)
b = b + ...
Posts: 723
Threads: 118
Joined: Apr 2022
Reputation:
106
10-08-2023, 06:04 PM
(This post was last modified: 10-08-2023, 06:22 PM by Dav.)
That's a neat one. DRAW is such a powerful command. I'll try to come up with something too.
- Dav
Posts: 723
Threads: 118
Joined: Apr 2022
Reputation:
106
10-08-2023, 11:56 PM
(This post was last modified: 10-09-2023, 10:59 PM by Dav.)
Here's a small DRAW screen saver, @bplus. Haven't come up with a good color changing method yet, but it makes nice spinning patterns. Press ENTER to change patterns. ESC to quit. You may mod and/or share this elsewhere if you wish.
- Dav
Code: (Select All)
'DRAWSPIN.BAS
'Spinning patterns using DRAW.
'Press ENTER to change pattern, ESC to quit.
'Coded by Dav, OCT/2023
SCREEN _NEWIMAGE(800, 600, 32)
seed = 123 + (RND * 123): px = 3 + RND * 3
DO
CLS
DO
p = p + px: ang = ang + seed
DRAW "D" + STR$(p) + "TA" + STR$(ang + a)
LOOP UNTIL POINT(0) < 0 AND POINT(1) < 0
p = 0: a = a + .01: IF ang >= (a * seed) THEN ang = 0
seed = seed + .03: IF seed > 245 THEN seed = 123
IF INKEY$ = CHR$(13) THEN seed = 123 + (RND * 123): px = 3 + RND * 3
_LIMIT 30
_DISPLAY
LOOP UNTIL INP(&H60) = 1
Posts: 3,936
Threads: 175
Joined: Apr 2022
Reputation:
216
10-09-2023, 12:22 AM
(This post was last modified: 10-09-2023, 12:30 AM by bplus.)
Wow Dav, a tour de force!
BTW I find escape key works for Inp(&H60) not seen it presented like that before.
b = b + ...
Posts: 723
Threads: 118
Joined: Apr 2022
Reputation:
106
10-09-2023, 12:59 AM
(This post was last modified: 10-09-2023, 01:39 AM by Dav.)
Added some color. The changing color adds another depth to the patterns.
- Dav
Code: (Select All)
'DRAWSPIN.BAS - v2, added some color
'Spinning patterns using DRAW.
'Press ENTER to change pattern, ESC to quit.
'Coded by Dav, OCT/2023
SCREEN _NEWIMAGE(800, 600, 32)
seed = 123 + (RND * 123): px = 3 + RND * 3
DO
CLS
DO
p = p + px: ang = ang + seed
c$ = "C" + STR$(_RGB(seed MOD p / 2, p / 6, p MOD seed * 2))
DRAW "D" + STR$(p) + "TA" + STR$(ang + a) + c$
LOOP UNTIL POINT(0) < 0 AND POINT(1) < 0
p = 0: a = a + .01: IF ang >= (a * seed) THEN ang = 0
seed = seed + .03: IF seed > 245 THEN seed = 123
IF INKEY$ = CHR$(13) THEN seed = 123 + (RND * 123): px = 3 + RND * 3
_LIMIT 30
_DISPLAY
LOOP UNTIL INP(&H60) = 1
Posts: 649
Threads: 95
Joined: Apr 2022
Reputation:
22
I'm mind-boggled that this can be done in so few lines!
Well done, Dav.
Posts: 1,587
Threads: 59
Joined: Jul 2022
Reputation:
52
It's good to know somebody else is using the subprograms I wrote and giving me proper credit.
I didn't think anybody else was going to care a lot about "You're the Bandit!" away from this forum. That program was sort of an example to teach young people how to program a game. Not a good example of an algorithm for the computer-controlled opponents in a single-player-only effort.
Posts: 723
Threads: 118
Joined: Apr 2022
Reputation:
106
Hi mnrvovrfc. Not sure if your post was a response to mine, had to reply to be sure. I make it a habit to give credit when using someone’s routines. That one I came up with on my own, truly. If it’s similar to code elsewhere, then it’s the two minds thinking alike at play.
- Dav
Posts: 3,936
Threads: 175
Joined: Apr 2022
Reputation:
216
(10-09-2023, 12:33 PM)Dav Wrote: Hi mnrvovrfc. Not sure if your post was a response to mine, had to reply to be sure. I make it a habit to give credit when using someone’s routines. That one I came up with on my own, truly. If it’s similar to code elsewhere, then it’s the two minds thinking alike at play.
- Dav
I think mnr... is referring to my post, a mod of MG. MG has mnr's trademark random number functions that I think,.. well not my first choice; I kept them in because too lazy to replace with my own.
I think mnr..., roquedrivel and MG are very tight friends or heck maybe even same person under different name for each forum?
@Dav I am considering posting your code at the other place but I don't want to piss off any forum owner with my sharing others work, so am perplexed, bad enough my own stuff I am guessing. But well I guess I will share my mods if they make significant difference. Playing politics not my thing...
b = b + ...
|