|
Pages: 1 2 3 [4] 5 6 ... 10
31
« Last post by mr why on May 24, 2012, 03:36:28 am »
This gets you the colours you want and you know what you are getting.
It is a "colour picker" and no matter which screen or monitor you use you get the colour you pick. (The next thing you draw is thet colour and none other. No theory; no broken promises!)
The chart below show all the colours that YOUR monitor screen is ABLE to show. Run it in qb64 nd you will see them all:
DIM colour&(32), r(400, 480), B(400, 480), g(400, 480) SCREEN _NEWIMAGE(640, 480, 32)
WINDOW (-440, -240)-(439, 239) _FULLSCREEN kk = 90 kkc = 130 kkd = 100 kky = 105 kkg = 130 kkb = 150 FOR x = -200 TO 200 xx = x + 200 FOR y = -200 TO 200
yy = y + 200 GOSUB quickcalc r(xx, yy) = 320 * EXP(-ABS(x / kkc) - ABS(y - 200) / kkc) B(xx, yy) = 335 * EXP(-ABS(x - 200) / kkb - ABS(y) / kkb) g(xx, yy) = 320 * EXP(-ABS(x / kkg) - ABS(y + 200) / kkg) r(xx, yy) = r(xx, yy) + 310 * EXP(-ABS(x + 200) / kky - ABS(y) / kky) g(xx, yy) = g(xx, yy) + 310 * EXP(-ABS(x + 200) / kky - ABS(y) / kky) 'xx,yy from 0 to 400, r(xx, yy) = r(xx, yy) + (255 - r(xx, yy)) * calc1 g(xx, yy) = g(xx, yy) + (255 - g(xx, yy)) * calc1 B(xx, yy) = B(xx, yy) + (255 - B(xx, yy)) * calc1 r(xx, yy) = r(xx, yy) + (255 - r(xx, yy)) * calc2 g(xx, yy) = g(xx, yy) + (255 - g(xx, yy)) * calc2 B(xx, yy) = B(xx, yy) + (255 - B(xx, yy)) * calc2 r(xx, yy) = r(xx, yy) + (255 - r(xx, yy)) * calc3 g(xx, yy) = g(xx, yy) + (255 - g(xx, yy)) * calc3 B(xx, yy) = B(xx, yy) + (255 - B(xx, yy)) * calc3 r(xx, yy) = r(xx, yy) + (255 - r(xx, yy)) * calc4 g(xx, yy) = g(xx, yy) + (255 - g(xx, yy)) * calc4 B(xx, yy) = B(xx, yy) + (255 - B(xx, yy)) * calc4
r(xx, yy) = r(xx, yy) * calc5 g(xx, yy) = g(xx, yy) * calc5 B(xx, yy) = B(xx, yy) * calc5
PSET (x, y), _RGB32(r(xx, yy), g(xx, yy), B(xx, yy)) NEXT y NEXT x
END quickcalc: calc1 = EXP(-(((ABS(xx) + ABS(yy))) / kk)) calc2 = EXP(-(((ABS(xx - 400) + ABS(yy - 400))) / kk)) calc3 = EXP(-(((ABS(xx - 400) + ABS(yy))) / kk)) calc4 = EXP(-(((ABS(xx) + ABS(yy - 400))) / kk)) calc5 = (1 - EXP(-(((ABS(x) + ABS(y))) / (kkd)))) RETURN
Now in QB64 Wiki is "explained" how you slide your mouse over the chart and pick exactly the colour you want. Now you see WHY it is useful, give it a try!
With so many millions of coulors it is made a bit complicated. Each colour is made by a recipe of 0 to 255 tots of the 3 primary colours, giving "as dark as your screen gets" to bright white via all colours in between.
But this chart gets rid of all that fuss and bother (inventing colours NOT those actually on YOUR screen). And the command that tells you the state-of-screen at the point where you have put the mouse is well worth knowing and useful for other purposes!
Have FUN Mr Why
32
« Last post by mr why on May 22, 2012, 01:33:50 am »
Here is an example and a challenge game for you. Using gravity I have set up 4 equal heavenly bodies to rotate about one another sharing one and the same double figure 8 orbit.
Can you get them to maintain that double-8 orbit?
It should be very easy! - There are only 4 numbers to adjust: xc(1) = .1306 x-position start xc(6) = -.0153 y-position start xc(10) = -6.0005 x-speed start xc(13) = 1.9245 y=speed start
Adjust these EVER-so-slightly and you may find what I am missing!
I always find the computation errors are too big - the orbit falls apart (beginning in ever-growing fashion) To begin with all seems fine - but soon your hopes are dashed!
But the SINGLE figure-8 shared orbit (3 stars or planets sharing one orbit) is DIFFERENT - for the laws of gravity forgive and correct the computation errors! Similarly if you provide a large central "sun" to rotate around, everything works fine.
DEFDBL A-H, K-M, O-Z: DEFINT I-J, N n = 16: OPTION BASE 1 DIM x(n), xc(n), f(n), c1(n), c2(n), c3(n), c4(n) GOSUB graphics m1 = 1#: m2 = 1#: m3 = 1#: m4 = 1 t = 0# ' ** initial positions ** xc(1) = .1306: xc(2) = 0: xc(3) = -xc(1): xc(4) = 0 'x coords xc(5) = 0#: xc(6) = -.0153#: xc(7) = 0: xc(8) = -xc(6) 'y coords ' ** initial speeds ** xc(9) = 0: xc(10) = -6.0005: xc(11) = 0: xc(12) = -xc(10) 'x vel xc(13) = 1.9245: xc(15) = -xc(13): xc(16) = 0 'y vel
h = .0000015#
agn: GOSUB Runge PSET (xc(1), xc(5)), 12 PSET (xc(2), xc(6)), 9 PSET (xc(3), xc(7)), 15 PSET (xc(4), xc(8)), 13
t = t + h 'IF j = 30000 THEN CLS : j = 0: GOSUB energy GOTO agn END
Equations: d21 = x(2) - x(1): d32 = x(3) - x(2): d43 = x(4) - x(3): d14 = x(1) - x(4) d13 = x(3) - x(1): d24 = x(4) - x(2) d65 = x(6) - x(5): d76 = x(7) - x(6): d87 = x(8) - x(7): d58 = x(5) - x(8) d75 = x(7) - x(5): d86 = x(8) - x(6) r12 = (d21 ^ 2# + d65 ^ 2#) ^ .5# r23 = (d32 ^ 2# + d76 ^ 2#) ^ .5# r34 = (d43 ^ 2# + d87 ^ 2#) ^ .5# r41 = (d14 ^ 2# + d58 ^ 2#) ^ .5# r13 = (d13 ^ 2# + d75 ^ 2#) ^ .5# r24 = (d24 ^ 2# + d86 ^ 2#) ^ .5# p12 = r12 ^ 3#: p23 = r23 ^ 3#: p34 = r34 ^ 3: p41 = r41 ^ 3# p31 = r13 ^ 3: p24 = r24 ^ 3 f(1) = x(9): f(2) = x(10): f(3) = x(11): f(4) = x(12) f(5) = x(13): f(6) = x(14): f(7) = x(15): f(8) = x(16) f(9) = m2 * d21 / p12 + m3 * d13 / p31 - m4 * d14 / p41 'x accn of m1 f(10) = m3 * d32 / p23 + m4 * d24 / p24 - m1 * d21 / p12 ' m2 f(11) = m4 * d43 / p34 - m1 * d13 / p31 - m2 * d32 / p23 ' m3 f(12) = m1 * d14 / p41 - m2 * d24 / p24 - m3 * d43 / p34 ' m4 f(13) = m2 * d65 / p12 + m3 * d75 / p31 - m4 * d58 / p41 'y m1 f(14) = m3 * d76 / p23 + m4 * d86 / p24 - m1 * d65 / p12 ' m2 f(15) = m4 * d87 / p34 - m1 * d75 / p31 - m2 * d76 / p23 ' m3 f(16) = m1 * d58 / p41 - m2 * d86 / p24 - m3 * d87 / p34 ' m4 RETURN
Runge: FOR i = 1 TO n: x(i) = xc(i): NEXT GOSUB Equations FOR i = 1 TO n: c1(i) = h * f(i): NEXT FOR i = 1 TO n: x(i) = xc(i) + c1(i) / 2#: NEXT GOSUB Equations FOR i = 1 TO n: c2(i) = h * f(i): NEXT FOR i = 1 TO n: x(i) = xc(i) + c2(i) / 2#: NEXT GOSUB Equations FOR i = 1 TO n: c3(i) = h * f(i): NEXT FOR i = 1 TO n: x(i) = xc(i) + c3(i): NEXT GOSUB Equations FOR i = 1 TO n: c4(i) = h * f(i): NEXT FOR i = 1 TO n xc(i) = xc(i) + (c1(i) + 2# * c2(i) + 2# * c3(i) + c4(i)) / 6# NEXT RETURN
graphics: SCREEN 12 PAINT (1, 1), 9 xm = .15: ym = .15 VIEW (180, 17)-(595, 460), 0, 13 WINDOW (-xm, -ym)-(xm, ym) xg = .134 FOR xi = -xg TO xg + .001 STEP xg / 20 LINE (-xm, xi)-(xm, xi), 8: LINE (xi, -ym)-(xi, ym), 8 NEXT xi LINE (-xm, 0)-(xm, 0), 9: LINE (0, -ym)-(0, ym), 9
RETURN
energy: ' ** Is energy conserved? ** kin1 = .5# * m1 * (xc(7) ^ 2# + xc(10) ^ 2#) kin2 = .5# * m2 * (xc(8) ^ 2# + xc(11) ^ 2#) kin3 = .5# * m3 * (xc(9) ^ 2# + xc(12) ^ 2#) pot = -(m1 * m2 / r12 + m2 * m3 / r23 + m3 * m1 / r13) energy = kin1 + kin2 + kin3 + pot LOCATE 21, 1: PRINT "Energy" LOCATE 22, 1: PRINT energy LOCATE 17, 7: PRINT " " LOCATE 17, 1: PRINT "Time ="; CSNG(t) RETURN
33
« Last post by MR. Y on May 21, 2012, 04:22:02 pm »
Don't worry abt that! Someone will tell 'em sooner or later and their silliness will stop. (Actually qb64 is a threat as it is far better than their junk - for example always works versus "sometimes")
34
« Last post by axlyon on May 21, 2012, 02:58:54 pm »
this looks cool.
wow, the first time i run QB64 code after i update my security pack and microsoft thinks QB64 progs are a threat!
35
« Last post by MR. Y on May 21, 2012, 02:12:06 pm »
Yes, no need for all 3 ideas at once
For finest resolution (and speed) do not show size the way done in the above example (coiled coils are very slow) For smoothness colour-code for depth with GRADUAL and prpportional colour changes Instead of jumping between two views a smooth change of eye-position can be used. Just use the ideas best for YOU in YOUR program
36
« Last post by axlyon on May 21, 2012, 01:23:01 pm »
i get it. like the kind of thing they did with StarFox on the SNES
37
« Last post by mr why on May 21, 2012, 09:41:55 am »
One of the first things most of us want to do is make things look three-dimensional, real and solid, despite only having a flat screen. I will illustrate three ways to help do this, using the programs I did to draw knots and find out when they were actually knotted - not just tangled loops
1. Use colour to indicate depth (like on a contour map) 2. Make distant things smaller 3 SHIFT distant things BEHIND near things as you move your eye-position
By doing 3 (parallelax shift) alternately back and forth birds judge distance very accurtely. Also, for us things that change once-a-second get immediately noticed!
This prog is best run in qb64 (screen resolution and speed)
DEFDBL A-Z
_FULLSCREEN SCREEN _NEWIMAGE(1000, 730, 256) WINDOW (0, 0)-(1000, 730) DIM wx(710), wy(710), wz(710) dt = 710 FOR n = 1 TO dt wx(n) = 1 + SIN(n / 30 - 1.8) wy(n) = 1 + SIN(n / 41 + .7) wz(n) = 1 + SIN(n / 50 - .3) NEXT n
PRINT "Here is a piece of bent wire tied in a knot"
FOR n = 1 TO dt x = 60 + 100 * wx(n) y = 700 - 120 * wy(n) z = 1 + 7 * wz(n) CIRCLE (x, y), z / 3 + 1, z NEXT n LOCATE 9, 1: PRINT "xy view" LOCATE 9, 45: PRINT "xz view"
FOR n = 1 TO dt x = 400 + 120 * wz(n) y = 700 - 120 * wy(n) z = 1 + 7 * wx(n) CIRCLE (x, y), (z + 3) / 3 + 1, z NEXT n
FOR n = 1 TO dt x = 50 + 100 * wx(n) y = 280 - 120 * wz(n) z = 1 + 7 * wy(n) CIRCLE (x, y), (z + 3) / 3 + 1, z NEXT n
LOCATE 40, 1: PRINT "zy view" LOCATE 5, 20: PRINT "A" LOCATE 14, 9: PRINT "B" LOCATE 14, 61: PRINT "B" LOCATE 5, 81: PRINT "A" LOCATE 34, 6: PRINT "B" LOCATE 44, 20: PRINT "A" LOCATE 38, 54: PRINT "B" LOCATE 30, 68: PRINT "A" LOCATE 45, 50: PRINT " View from alternating x-positions";
again: PSET (400, 300), 0 FOR n = 1 TO dt x = 420 + 100 * wx(n) y = 310 - 120 * wy(n) z = 1 + 7 * wz(n) CIRCLE (x, y), z / 3 + 1, z NEXT n GOSUB pause FOR n = 1 TO dt x = 420 + 100 * wx(n) y = 310 - 120 * wy(n) z = 1 + 7 * wz(n) CIRCLE (x, y), z / 3 + 1, 0 NEXT n FOR n = 1 TO dt x = 420 + 100 * wx(n) + 15 / (2.4 - wz(n)) y = 310 - 120 * wy(n) z = 1 + 7 * wz(n) CIRCLE (x, y), z / 3 + 1, z NEXT n GOSUB pause FOR n = 1 TO dt x = 420 + 100 * wx(n) + 15 / (2.4 - wz(n)) y = 310 - 120 * wy(n) z = 1 + 7 * wz(n) CIRCLE (x, y), z / 3 + 1, 0 NEXT n GOTO again:
pause: DO _LIMIT 20 kk = kk + 1 IF kk > 30 THEN kk = 0: RETURN GOTO pause LOOP END
38
« Last post by mr why on May 21, 2012, 02:50:19 am »
I just joined, in relation to qb64, the best resources are at http://www.qb64.net and http://qb64.net/wiki/index.php?title=Main_Page Some tutorials are available at the same wiki, http://qb64.net/wiki/index.php?title=QB64_Tutorials Well anyway good luck with your forum. from a qb64user
QB64user, Welcome, good to have your help! Please tell us more of your ideas on tutorials. I am not sure "Tutorials" is the best word to use - newbies are easily discxouraged if they suffered from "not the best teachig"! We can call them "Getting Started" or "How I wrote my first xxxx program" Put yourself in their shoes - remember how you felt about things when you first began and explain in simple English (keeping away from jargon and technical terms if you can!). Take everything by example and in SIMPLE steps. Yes qb64 is excellent (and a free download). Especially it is excellent (fast and powerful with GREAT music via _SNDRAW) - eventually. That is AFTER you get your program working! But QB64 has no way to warn you AT ONCE of all the errors you make! On the other hand QBASIC lets you ASK wht values all the numbers have reached EVERY TIME it stops working. You just type ? and the name like this for example ? N and it tells you. This makes QBAS far easier to lean on - and your finished program then runs seamlessly and much faster on qb64 So start with QBAS (Quickbasic) and switch to QB64 once you get it working! BIll Gates tried to "torpedo" QBAS in his bodge fix SP2. On many computers he succeeded - but not on mine. So perhaps not on yours. So give QBAS a try and see if it works on your computer.
39
« Last post by MR. Y on May 20, 2012, 02:24:26 am »
In QB64 you can make very realistic sounds. Decide which instruments you want and form an orchestra!
But to start simply here is a xylophone You have decided (see code below) which keys (\,a,z,s.......;,/) play which notes. Yes (but not this demo) you can play chords and change between wind, stringed, percussion and other instruments (timbre, overtones, transients, decay rates)
Just get the hang of it here and come back with your ideas!
Download qb64 and run this program:
CONST Pi = 3.14159265358979 _DELAY 0.5 'time (in seconds) 'a$ = INKEY$: IF a$ = "" THEN GOTO nxt nxt:
DO nx: t = 0 a$ = INKEY$: IF a$ = "" THEN GOTO nx 'INPUT p IF a$ = "\" THEN p = -9 IF a$ = "a" THEN p = -8 'b IF a$ = "z" THEN p = -7 IF a$ = "s" THEN p = -6 'b IF a$ = "x" THEN p = -5 IF a$ = "d" THEN p = -4.5 IF a$ = "c" THEN p = -4 IF a$ = "f" THEN p = -3 'b IF a$ = "v" THEN p = -2 IF a$ = "g" THEN p = -1 'b IF a$ = "b" THEN p = 0 IF a$ = "h" THEN p = 1 'b IF a$ = "n" THEN p = 2 IF a$ = "j" THEN p = 2.5 IF a$ = "m" THEN p = 3 IF a$ = "k" THEN p = 4 'b IF a$ = "," THEN p = 5 IF a$ = "l" THEN p = 6 'b IF a$ = "." THEN p = 7 IF a$ = ";" THEN p = 8 'b IF a$ = "/" THEN p = 9 a$ = ""
DO WHILE _SNDRAWLEN < 1 'this sets the overtones and their decay rates
F = EXP(-t) * COS(t * 2 * Pi * freq(p)) A = (1 / (4.5 * (t))) * COS(t * 2 * Pi * freq(p + 6 * 2.76)) c = (1 / (5 * (t))) * COS(t * 2 * Pi * freq(p + 6 * 5.4)) e = (1 / (6 * (t))) * COS(t * 2 * Pi * freq(p + 6 * 8.9))
value = 0.125 * (F + A + c + e) ' this volume-adds them
'Queue the value to be played _SNDRAW value
t = t + 1 / _SNDRATE LOOP
_LIMIT 10
LOOP 'WHILE t < 1
'Wait for sound buffer to empty DO: LOOP WHILE _SNDRAWLEN GOTO nxt
'Returns the frequency (in Hz) of the desired note 'measured in semitones from A440 (that's A above middle C) 'A above middle C is 0, A# is 1, B is 2, C is 3, etc. 'Middle C is -9 FUNCTION freq# (note AS DOUBLE) freq = (2 ^ (note / 12)) * 440 END FUNCTION
40
« Last post by MR. Y on May 20, 2012, 01:18:31 am »
I wanted to write a game. But soon found that all a computer could DO was write idiot things like "Hello World" on the screen.
So given a computer HOW do we get it to do something that helps ME!
Well for weeks I was disillusioned. But one day, idly, I made it write Hello world so many time it filled the screen and I noticed it then "jumped up one" And it still did that whatever I told it to print So I told it to print I a hundred times, each on a new line (PRINT "I") This gave me a vertical line Big deal!
So I moved the I a bit (Print " I", Print " I", and so on) A wiggly line. Not much use, eh
But TWO wiggly lines? They are the edges of a RACE TRACK which "Moves up" each time a new line is "added"
OK, so we need a car My car was done like this llll llll llll and I started with it between the edges of my racetrack
I found I had WRITTEN a program! Here the car is at the top of the screen and "moves down the track because the track edges move up!
To STEER the car I had to insert spaces before it to move it Right (or after it to move it Left)
HOW you do this really DOES NOT MATTER. In fact I ended up using the keyboard keys L and R. You can use the "arrows" if you look up a bit of jargon (i.e. what "codes" they use).
You can also make a far better car, and the colours you want.
Anyway the car "proceeds down the wiggly track" (use RND to wiggle the track) Soon it collides with the track edge. Count how many times and you have both a score, a winner and a record score ever
By now I hope you are getting the idea and at least SOME of all that jargon code (in whatever language) is starting to make sense.
I suggest using QBAS, because it is "almost English" which means you can get help about it from a friend or parent. They can read your program and almose see what it is doing.
Unfortunately, Bill Gates, in one of his bodge "improvements" (this one called SP2) managed to STOP most people using QBAS. (I managed to defeat him.) If he stops you then use QB64 - a free download that Google Search knows all about. QB64 is very much faster than QBAS. Better. "More powerful" - good luck with finding out what that actually means.
Having now written your first game, write to us here and tell us how it turned out and all your ideas for better games.
Pages: 1 2 3 [4] 5 6 ... 10
|
Excelling in C++: Trust the Professional Code Experts at MyCodingHomework for Expert Homework Assistance
by Dilamon Saravi
June 05, 2023, 08:02:21 am
|
Make money online: 4 Reasons Why Blockchain Gaming is The Future
by Damingw
March 06, 2023, 05:51:43 am
|
Fairy Cat, New Profitable Blockchain Game
by claude william
March 01, 2023, 11:30:54 pm
|
GameFi - A way out for low-skilled workers
by claude william
February 28, 2023, 11:29:57 pm
|
The History of Gaming — From Pay-to-Play to Play-to-Earn
by claude william
February 27, 2023, 11:50:57 pm
|
Best Blockchain Games
by claude william
February 26, 2023, 11:46:46 pm
|
3 Best Blockchain Games to Invest In 2023
by claude william
February 25, 2023, 11:16:23 pm
|
The History of Gaming — From Pay-to-Play to Play-to-Earn
by claude william
February 24, 2023, 11:57:47 pm
|
Best Play-to-Earn Games with NFTs or Crypto
by claude william
February 24, 2023, 12:04:48 am
|
A few lines of fun writing to IT brothers during Covid
by claude william
February 22, 2023, 11:35:56 pm
|
|
|