Navigation

    Fuze Arena Logo
    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Popular
    • Users
    • Groups
    • Help
    • Discord

    Get Pixel colour

    Coding
    4
    17
    641
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Retrocade_media
      Retrocade_media F last edited by

      I wonder if the getbit commands would be of any use?

      F 1 Reply Last reply Reply Quote 0
      • F
        faz808 F @Retrocade_media last edited by

        @Retrocade_media Do you mean bitGet? I can't find getbit...

        Retrocade_media 1 Reply Last reply Reply Quote 1
        • Retrocade_media
          Retrocade_media F @faz808 last edited by

          @faz808 yea probably? I don't know how all that works but it might be useful

          F 1 Reply Last reply Reply Quote 0
          • F
            faz808 F @Retrocade_media last edited by

            @Retrocade_media I'll try that. Thanks.

            1 Reply Last reply Reply Quote 0
            • Martin
              Martin Fuze Team last edited by

              bitGet isn’t going to help you I’m afraid. There’s no way to do getPixel at the moment

              F 1 Reply Last reply Reply Quote 0
              • F
                faz808 F @Martin last edited by

                @Martin I suspected that. Maybe in the future?

                1 Reply Last reply Reply Quote 0
                • Martin
                  Martin Fuze Team last edited by

                  If you explain what you need it for then we might be able to help you find an alternative

                  F 1 Reply Last reply Reply Quote 0
                  • F
                    faz808 F @Martin last edited by Martin

                    @Martin I have 255 stars - circle(galaxy_x[I],galaxy_y[I], 2, 32 ,col,false) - randomly displayed. Using a cursor, move around the screen checking the present for a "star" and converting the x,y cords to a random star name.
                    I think I've managed it with:-

                    namepart = ["EN", "LA", "CAN" etc 64 letter combinations..
                    "WE", "DE"
                    ]
                     
                    pointx = 623
                    pointy = 351
                    circle (pointx, pointy, 8, 32, col, true) // my cursor
                    if joy.x then 
                      drawText(422, 33, 26, white, "searching...")
                      for i = 1 to 255 loop
                         for dx = -8 to 8 loop
                          if (point+dx) == galaxy_x[i] then
                            for dy = -8 to 8 loop
                              if (pointy+dy) == galaxy_y[i] then
                                clear()
                                starname = namepart[i/11] + namepart[i/5] + namepart[i/7] //generate starname from array parts
                                drawText(822, 33, 26, white, i)
                                drawText(900, 33, 26, white, starname)
                                pointy = galaxy_y[i] // lock circle to star position
                                pointx = galaxy_x[i]
                             endif
                           repeat
                         endif
                       repeat
                     repeat
                    endif
                    

                    My aim is to write a simple Elite clone. I don't think I need a getPixel command as such. Another problem is the lack of str lower case to upper. This would have been useful. An earlier suggestion solved the random number problem - lack of a seed. It would be nice to be able to save more than one file This would give me more than one repeatable galaxy.

                    F 1 Reply Last reply Reply Quote 0
                    • F
                      faz808 F @faz808 last edited by

                      @faz808 Sorry, I did indent it correctly but it seems to have gone wonky.

                      F 1 Reply Last reply Reply Quote 0
                      • F
                        faz808 F @faz808 last edited by Martin

                        @faz808 Forget to add:-

                        if joy,right then
                          clear()
                          pointx += 1
                        endif
                        etc etc …
                        

                        Cheers

                        1 Reply Last reply Reply Quote 0
                        • xevdev
                          xevdev F last edited by

                          If you have all the stars x and y positions use distance() to find which is the closest to your circle.
                          If the Distance( star_xy, circle_xy ) is less than circle radii it's within your circle

                          F 1 Reply Last reply Reply Quote 2
                          • F
                            faz808 F @xevdev last edited by

                            @xevdev Thanks. That's shortened the code. I must learn to read the documentation !

                            1 Reply Last reply Reply Quote 1
                            • Martin
                              Martin Fuze Team last edited by Martin

                              You need to add code tags to the start and end, which is 3 'backticks' (obviously I can't type them) - i've done it for you.

                              SO, also, another way (admittedly, a rather wasteful way) would be to use sprites for the stars. Yes, it's wastefull if they are just a single pixel but it does make other operations such as scaling simpler should you need them and Fuze should easily cope with 255 of them. Then you can use collision detection against whatever your pointer might be. If you experiement with this then don't forget to removeSprite() when you are done with them because you are dealing with quite a lot of sprites.

                              Yeah, maybe not the best of ideas but it should work.

                              For strLower and strUpper, just write one. I'm sure there are already examples on the forum but I'm not sure how good the search is. Very, very quickly knocked up, without Fuze in front of me, something along the lines of...

                              function toLower(str)
                                  string new
                                  int n = 0
                                  int v = 0
                                  for n = 0 to len(str) loop
                                      v = chrVal(str[n])
                                      if v > 64 and v < 91 then new[n] = char(v + 32) endif
                                  repeat
                              return
                              

                              Should be somewhere in the ballpark of what you need?

                              PS: Yeah, the language should really have some kind of upper and lower functionality really

                              F 2 Replies Last reply Reply Quote 0
                              • F
                                faz808 F @Martin last edited by

                                @Martin Thanks. It's all coming together nicely now.

                                1 Reply Last reply Reply Quote 0
                                • F
                                  faz808 F @Martin last edited by

                                  @Martin Upper to Lower works fine. To keep the first character as caps I changed one line to:-
                                  new[n] = chr(v + (( n > 0) * 32 ))
                                  Many thanks.

                                  1 Reply Last reply Reply Quote 1
                                  • Martin
                                    Martin Fuze Team last edited by

                                    Oh, that's neat, i like that

                                    1 Reply Last reply Reply Quote 0
                                    • First post
                                      Last post