Qbasicnews.com
August 21, 2018, 02:35:49 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Back to Qbasicnews.com | QB Online Help | FAQ | Chat | All Basic Code | QB Knowledge Base
 
   Home   Help Search Login Register  
Pages: 1 [2]
  Print  
Author Topic: Rotating a squared matrix  (Read 15792 times)
Ralph
Ancient Guru
****
Posts: 544


« Reply #15 on: January 26, 2008, 02:24:19 AM »

ClayDragon:

First, thanks for the kudos.  These are always welcome.  But...

You said, "I can't wait to see the final results".  What do you mean?  If you want "final results", we expect you to start contributing comments and code.  The reason for these forums is to help people that are interested in programming, or even in just one particular proyect, and learning how to code it.  We help, but don't do the "final result", unless the poster helps, too.  So, post some code and ask away.
Logged

Ralph, using QuickBASIC 4.5 and Windows XP Home Edition and Service Pack 2, with HP LaserJet 4L printer.
Dr_Davenstein
Na_th_an
*****
Posts: 2052


« Reply #16 on: January 26, 2008, 03:24:18 AM »

That's cool. I tried doing my own taxes a cople of times, but I realy hated it, so I just take them to a pro these days. They usually get me more anyway, since they know more about our variable tax laws.

About the programs: Yeah, unfortunately, they wont compile with any version of QB. They use a FB library that me and a few friends programmed.
Logged
Dr_Davenstein
Na_th_an
*****
Posts: 2052


« Reply #17 on: January 26, 2008, 03:24:58 AM »

ClayDragon:

First, thanks for the kudos.  These are always welcome.  But...

You said, "I can't wait to see the final results".  What do you mean?  If you want "final results", we expect you to start contributing comments and code.  The reason for these forums is to help people that are interested in programming, or even in just one particular proyect, and learning how to code it.  We help, but don't do the "final result", unless the poster helps, too.  So, post some code and ask away.

Seconded! Wink
Logged
Clay Dragon
Member
*
Posts: 38


WWW
« Reply #18 on: January 26, 2008, 06:11:10 PM »

ClayDragon:

First, thanks for the kudos.  These are always welcome.  But...

You said, "I can't wait to see the final results".  What do you mean?  If you want "final results", we expect you to start contributing comments and code.  The reason for these forums is to help people that are interested in programming, or even in just one particular proyect, and learning how to code it.  We help, but don't do the "final result", unless the poster helps, too.  So, post some code and ask away.

By "final results", I meant the code snipet I could use to replace the part that is not working properly in my tile editor. I don't have your coding skills. I used to be good at coding but now I'm quite rusted after years of inactivity in the coding department...

So here is the code anyway: (the following is the sub that doesn't work properly. The very part that does work only for a complete grid selection is in the very end of the sub starting from case "R". That's the part that I want to replace with your code snipet)

If you want all the source code, it is here (executable included).

Code:
flip.rotate:
IF x% = xmax% - 3 OR y% = ymax% - 3 THEN GOTO 11
COLOR 10
LOCATE 23, 1
SELECT CASE A$
 CASE "H": PRINT "Define area for horizontal flip..."
 CASE "V": PRINT "Define area for vertical flip..."
 CASE "R": PRINT "Define area for rotation..."
END SELECT
COLOR 15
B$ = "": mx% = x%: my% = y%: x% = x% + 6: y% = y% + 6
DO
 LOCATE 23, 36: PRINT "     ": LOCATE 23, 36
 IF A$ = "H" OR A$ = "V" THEN
  PRINT LTRIM$(STR$((x% - mx%) / 3)) + "x" + LTRIM$(STR$((y% - my%) / 3))
 ELSE
  PRINT LTRIM$(STR$((x% - mx%) / 3)) + CHR$(253)
 END IF
 GET (mx% + (x% - mx%) / 2 - 2, my% + (y% - my%) / 2 - 2)-(mx% + (x% - mx%) / 2 + 2, my% + (y% - my%) / 2 + 2), buffer
 DO WHILE B$ = ""
  FOR i% = 0 TO 1
   LINE (mx%, my%)-(x%, y%), 15 * i%, B
   LINE (mx% + (x% - mx%) / 2, my% + (y% - my%) / 2 - 2)-(mx% + (x% - mx%) / 2, my% + (y% - my%) / 2 + 2), 15 * i%, B
   LINE (mx% + (x% - mx%) / 2 - 2, my% + (y% - my%) / 2)-(mx% + (x% - mx%) / 2 + 2, my% + (y% - my%) / 2), 15 * i%, B
   FOR j% = 1 TO 300
    B$ = INKEY$
    IF B$ <> "" THEN EXIT FOR
   NEXT j%
   IF B$ <> "" THEN EXIT FOR
  NEXT i%
 LOOP
 LINE (mx%, my%)-(x%, y%), 19, B
 PUT (mx% + (x% - mx%) / 2 - 2, my% + (y% - my%) / 2 - 2), buffer, PSET
 B$ = UCASE$(B$)
 SELECT CASE B$
  CASE CHR$(0) + CHR$(72): GOSUB check.up: IF A$ = "R" THEN GOSUB check.left
  CASE CHR$(0) + CHR$(80):
   GOSUB check.down
   IF A$ = "R" THEN
    GOSUB check.right
    IF mx% - my% <> x% - y% THEN x% = mx% + 6: y% = my% + 6
   END IF
  CASE CHR$(0) + CHR$(77):
   GOSUB check.right
   IF A$ = "R" THEN
    GOSUB check.down
    IF mx% - my% <> x% - y% THEN x% = mx% + 6: y% = my% + 6
   END IF
  CASE CHR$(0) + CHR$(75): GOSUB check.left: IF A$ = "R" THEN GOSUB check.up
  CASE CHR$(13): EXIT DO
  CASE CHR$(27): x% = mx%: y% = my%: GOTO 10
 END SELECT
 B$ = ""
LOOP
LINE (mx%, my%)-(x%, y%), 15, B
IF A$ = "H" OR A$ = "V" THEN
 COLOR 10
 LOCATE 23, 1
 PRINT "Mirror effect (Y/N)?                    "
 B$ = ""
 DO WHILE B$ = ""
  B$ = UCASE$(INKEY$)
  IF B$ <> "" THEN IF B$ <> "Y" AND B$ <> "N" THEN B$ = ""
 LOOP
 LOCATE 23, 22: PRINT B$
 mirror% = ASC(B$) \ 89
END IF
IF A$ = "R" THEN
 COLOR 10
 LOCATE 23, 1
 PRINT "Rotate which way: (R)ight or (L)eft?    "
 B$ = ""
 DO WHILE B$ = ""
  B$ = UCASE$(INKEY$)
  IF B$ <> "" THEN IF B$ <> "R" AND B$ <> "L" THEN B$ = ""
 LOOP
 LOCATE 23, 38: PRINT B$
END IF
COLOR 15
LINE (mx% + (x% - mx%) / 2, my% + (y% - my%) / 2 - 2)-(mx% + (x% - mx%) / 2, my% + (y% - my%) / 2 + 2), 19, B
LINE (mx% + (x% - mx%) / 2 - 2, my% + (y% - my%) / 2)-(mx% + (x% - mx%) / 2 + 2, my% + (y% - my%) / 2), 19, B
LINE (mx%, my%)-(x%, y%), 19, B
FOR j% = mx% / 3 TO x% / 3 - 1
 FOR i% = my% / 3 TO y% / 3 - 1
  buffer(j%, i%) = POINT(171 + j%, 1 + i%)
 NEXT i%
NEXT j%
FOR j% = mx% / 3 TO x% / 3 - 1
 FOR i% = my% / 3 TO y% / 3 - 1
  SELECT CASE A$
   CASE "H":
    IF i% < (my% / 3 + y% / 3) / (mirror% + 1) THEN
     LINE (1 + j% * 3, 1 + ((my% / 3 + y% / 3) - i% - 1) * 3)-(2 + j% * 3, 2 + ((my% / 3 + y% / 3) - i% - 1) * 3), buffer(j%, i%), BF
     PSET (171 + j%, 1 + (my% / 3 + y% / 3) - i% - 1), buffer(j%, i%)
    END IF
   CASE "V":
    IF j% < (mx% / 3 + x% / 3) / (mirror% + 1) THEN
     LINE (1 + ((mx% / 3 + x% / 3) - j% - 1) * 3, 1 + i% * 3)-(2 + ((mx% / 3 + x% / 3) - j% - 1) * 3, 2 + i% * 3), buffer(j%, i%), BF
     PSET (171 + (mx% / 3 + x% / 3 - j% - 1), 1 + i%), buffer(j%, i%)
    END IF
   CASE "R":
    IF B$ = "R" THEN
     LINE (1 + (i% * 3), 1 + (j% * 3))-(2 + (i% * 3), 2 + (j% * 3)), buffer(j%, y% / 3 - i% - 1), BF
     PSET (171 + i%, 1 + j%), buffer(j%, y% / 3 - i% - 1)
    ELSE
     LINE (1 + (i% * 3), 1 + (j% * 3))-(2 + (i% * 3), 2 + (j% * 3)), buffer(x% / 3 - j% - 1, i%), BF
     PSET (171 + i%, 1 + j%), buffer(x% / 3 - j% - 1, i%)
    END IF
  END SELECT
 NEXT i%
NEXT j%
x% = mx%: y% = my%
GOTO 10
« Last Edit: January 26, 2008, 08:32:18 PM by Clay Dragon » Logged
Ralph
Ancient Guru
****
Posts: 544


« Reply #19 on: January 28, 2008, 06:26:58 PM »

Claydragon, you wrote:
Quote
By "final results", I meant the code snipet I could use to replace the part that is not working properly in my tile editor. I don't have your coding skills. I used to be good at coding but now I'm quite rusted after years of inactivity in the coding department...

I understand you.  However, there is too much code for me to try to understand just what it is that you need. 

I would suggest that you write pseudocode to explain what you need.  Then, maybe I can help you.  But, perhaps Dr_Davenstein can help you, at this point? 

Logged

Ralph, using QuickBASIC 4.5 and Windows XP Home Edition and Service Pack 2, with HP LaserJet 4L printer.
Clay Dragon
Member
*
Posts: 38


WWW
« Reply #20 on: September 18, 2009, 01:46:41 AM »

I solved my problem! Thanks
Logged
Pages: 1 [2]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!