Author Topic: how to - x axis?  (Read 7418 times)

0 Members and 1 Guest are viewing this topic.

Offline codevsb12

  • Newbie
  • Posts: 23
    • View Profile
Re: how to - x axis?
« Reply #30 on: February 21, 2020, 06:30:17 pm »
alright, first, _vince, im a newbie, that's what it says under my name.

and second, the balls not appearing and my player is not moving.

lemme try some things to fix it because i've asked a lot for help this week...

hmm...

i don't see any problem in the code

maybe i don't have the eye of a programmer

gotta try another method, then...
...
nothing?

w? s? d? a? Q????? NO?

oh, i forgot the randomize timer in the beginning...
injustice...

one last try...

yay! now it works!

important note: no defint a-z from now on...
« Last Edit: February 21, 2020, 06:36:10 pm by codevsb12 »

Offline _vince

  • Seasoned Forum Regular
  • Posts: 422
    • View Profile
Re: how to - x axis?
« Reply #31 on: February 21, 2020, 07:11:36 pm »
Holy Tilapia _vince!

try this, bplus

Code: QB64: [Select]
  1. a = 50/400
  2. b = 20/400
  3.  

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: how to - x axis?
« Reply #32 on: February 21, 2020, 07:26:09 pm »
try this, bplus

Code: QB64: [Select]
  1. a = 50/400
  2. b = 20/400
  3.  

Yep! 100% purple. You did a marvelous job of duplicating my newest avatar. I love the really long IF block with AND OR AND.
First thing I did to check it out was this:
Code: QB64: [Select]
  1. DEFLNG A-Z
  2. CONST sw = 640
  3. CONST sh = 480
  4. SCREEN _NEWIMAGE(sw, sh, 32)
  5.  
  6. w = 400
  7. h = 400
  8. a = 0.08
  9. b = 0.03
  10.  
  11. LINE (0, 0)-(sw, sh), _RGB(237, 221, 255), BF ' blue off by only 1 tick too low in red = &heeddff
  12. FOR y = 0 TO h
  13.     FOR x = 0 TO w
  14.         IF (SQR((x + a * w) ^ 2 + (y - h / 2) ^ 2) > (w / 2 + b * w)) THEN
  15.             IF (SQR((x - w - a * w) ^ 2 + (y - h / 2) ^ 2) > (w / 2 + b * w)) THEN
  16.                 PSET (sw / 2 - w / 2 + x, sh / 2 + h / 2 - y), _RGB(187, 0, 0) 'nailed red!
  17.             END IF
  18.         END IF
  19.         IF (SQR((y + a * h) ^ 2 + (x - w / 2) ^ 2) > (h / 2 + b * h)) THEN
  20.             IF (SQR((y - h - a * h) ^ 2 + (x - w / 2) ^ 2) > (h / 2 + b * h)) THEN
  21.                 PSET (sw / 2 - w / 2 + x, sh / 2 + h / 2 - y), _RGB(187, 0, 0) 'nailed  red!
  22.             END IF
  23.         END IF
  24.     NEXT
  25.  
  26.  
  27.  

Apologies again to codevsb12 for getting off track but again, I didn't start it ;-))

BTW codevsb12 some code to go with your commentary (reply #30) would be nice. ;-)
« Last Edit: February 21, 2020, 07:33:35 pm by bplus »

Offline _vince

  • Seasoned Forum Regular
  • Posts: 422
    • View Profile
Re: how to - x axis?
« Reply #33 on: February 21, 2020, 07:56:50 pm »
As a note, bplus, the above expansion would execute much faster because it will not evaluate the other conditions if the first fails.  Other languages have 'short circuiting' or 'logic' operators that would evaluate equivalently to the above expansion, ie && and || as opposed to & and | in C. Freebasic also supports them:

https://www.freebasic.net/forum/viewtopic.php?t=25782

I personally believe they don't have a place in QB64, or any 'pure' BASIC, it would just add confusion for no real gain. I would never use ANDALSO or ORELSE in freebasic code, what an abomination
« Last Edit: February 21, 2020, 10:22:37 pm by _vince »