try at al rubix's

Game development specific discussions.
bluatigro
Posts: 597
Joined: Apr 25, 2012 10:35
Location: netherlands

try at al rubix's

Postby bluatigro » Jun 08, 2018 9:28

try at rubix 6 2

error :
my cube is not drawn good
the code does not stop at "q"

Code: Select all

'' bluatigro 8 jun 2018
'' rubix 6 2
#include "color.bas"
#include "_text.bas"
dim shared as ulong kl( 6 * 4 )
sub rot4( a as integer _
  , b as integer , c as integer , d as integer )
  dim as ulong help = kl( a )
  kl( a ) = kl( b )
  kl( b ) = kl( c )
  kl( c ) = kl( d )
  kl( d ) = help
end sub
function qq( face as integer , poly as integer ) as integer
  return face * 4 + poly
end function
''02
''13
'' 4
''0123
'' 5
sub rotj
  rot4 qq( 4 , 0 ) , qq( 2 , 2 ) , qq( 5 , 3 ) , qq( 0 , 1 )
  rot4 qq( 4 , 2 ) , qq( 2 , 3 ) , qq( 5 , 1 ) , qq( 0 , 0 )
  rot4 qq( 3 , 0 ) , qq( 3 , 2 ) , qq( 3 , 3 ) , qq( 3 , 1 )
end sub
sub rotk
  rot4 qq( 0 , 1 ) , qq( 1 , 1 ) , qq( 2 , 1 ) , qq( 3 , 1 )
  rot4 qq( 0 , 3 ) , qq( 1 , 3 ) , qq( 2 , 3 ) , qq( 3 , 3 )
  rot4 qq( 5 , 0 ) , qq( 5 , 2 ) , qq( 5 , 3 ) , qq( 5 , 1 )
end sub
sub rotl
  rot4 qq( 4 , 2 ) , qq( 1 , 2 ) , qq( 5 , 2 ) , qq( 3 , 1 )
  rot4 qq( 4 , 3 ) , qq( 1 , 3 ) , qq( 5 , 3 ) , qq( 3 , 0 )
  rot4 qq( 2 , 0 ) , qq( 2 , 2 ) , qq( 2 , 3 ) , qq( 2 , 1 )
end sub
sub shufle
  dim as string in
  dim as integer level , i
  cls
  locate 20 , 20
  input "how many shufles ? " ; in
  level = val( in )
  for i = 1 to level
    select case int( rnd * 3 )
      case 0
        rotj
      case 1
        rotk
      case 2
        rotl
      case else
    end select
  next i
end sub
screen 20 , 32
sub resetcube
  dim as integer i , j
  dim as ulong help
  restore
  for i = 0 to 5
    read help
    for j = 0 to 3
      kl( qq( i , j ) ) = help
    next j
  next i
end sub
data red,green,cyan,magenta,blue,yellow
dim as integer i
dim as string in
resetcube
do
  cls
  for j = 0 to 1
    for k = 0 to 1
      line ( 100 + j * 50 , k * 50 ) _
      - step( 45 , 45 ) , kl( qq( 4 , j * 2 + k ) ) , bf
    next k
  next j
  for j = 0 to 1
    for k = 0 to 1
      line ( 100 + j * 50 , k * 50 + 200 ) _
      - step( 45 , 45 ) , kl( qq( 5 , j * 2 + k ) ) , bf
    next k
  next j
  for i = 0 to 3
    for j = 0 to 1
      for k = 0 to 1
        line ( i * 100 + j * 50 , k * 50 + 100 ) _
        - step( 45 , 45 ) , kl( qq( i , j * 2 + k ) ) , bf
      next k
    next j
  next i
  text 225 , 25 , "j" , 4 , white
  text 425 , 175 , "k" , 4 , white
  text 175 , 325 , "l" , 4 , white
  text 512 , 550 , "[ s to shuffle ]" , 4 , white
  text 512 , 600 , "[ r to reset ]" , 4 , white
  text 512 , 650 , "[ q to quit ]" , 4 , white
  locate 27 , 20
  input "choise [ j , k , l , q , r , s ] = " ; in
  select case in
    case "j"
      rotj
    case "k"
      rotk
    case "l"
      rotl
    case "r"
      resetcube
    case "s"
      shufle
    case else
  end select
 
loop until in = "q"


sleep


Code: Select all

''bluatigro 13 feb 2015
''color.bas

''some colors consts + functions

#ifndef COLOR_H
#define COLOR_H

#include "math.bas"

''primary colors
const as ulong black      = &hff000000
const as ulong red        = &hffff0000
const as ulong green      = &hff00ff00
const as ulong yellow     = &hffffff00
const as ulong blue       = &hff0000ff
const as ulong magenta    = &hffff00ff
const as ulong cyan       = &hff00ffff
const as ulong white      = &hffffffff
''mix colors
const as ulong orange     = &hffff7f00
const as ulong gray       = &hff7f7f7f
const as ulong pink       = &hffff7f7f
const as ulong purple     = &hff7f007f
const as ulong darkRed    = &hff7f0000
const as ulong darkYellow = &hff7f7f00
const as ulong darkGreen  = &hff007f00
const as ulong darkBlue   = &hff00007f

function mix( kla as ulong , f as single , klb as ulong ) as ulong
  dim as ulong ra , ga , ba , rb , gb , bb , r , g , b
  ra = ( kla shr 16 ) and 255
  ga = ( kla shr 8 ) and 255
  ba = kla and 255
  rb = ( klb shr 16 ) and 255
  gb = ( klb shr 8 ) and 255
  bb = klb and 255
  r = ra + ( rb - ra ) * f
  g = ga + ( gb - ga ) * f
  b = ba + ( bb - ba ) * f
  return rgb( r and 255 , g and 255 , b and 255 )
end function

function rainbow( x as single ) as ulong
  dim as ulong r , g , b
  r = sin( rad( x ) ) * 127 + 128
  g = sin( rad( x - 120 ) ) * 127 + 128
  b = sin( rad( x + 120 ) ) * 127 + 128
  return rgb( r and 255 , g and 255 , b and 255 )
end function

function rndcolor() as ulong
  return rgb( rnd * 255 , rnd * 255 , rnd * 255 )
end function

#endif

Code: Select all

''text
dim shared as integer letterpart( 40 , 7 )
dim as integer j , k
const as string letters = "abcdefghijklmnopqrstuvwxyz0123456789[]="
dim as string q
for i as byte = 1 to len( letters )
  for j = 0 to 7
    read q
    for k = 0 to 7
      if mid( q , k + 1 , 1 ) = "1" then
        letterpart( i , j ) = letterpart( i , j ) or 2 ^ k
      end if
    next k
  next j
next i

''a
data "...1...."
data "..111..."
data ".1...1.."
data "1.....1."
data "1111111."
data "1.....1."
data "1.....1."
data "1.....1."
''b
data "1111...."
data "1...1..."
data "1....1.."
data "1....1.."
data "111111.."
data "1.....1."
data "1.....1."
data "111111.."
''c
data "..111..."
data ".1...1.."
data "1.....1."
data "1......."
data "1......."
data "1.....1."
data ".1...1.."
data "..111..."
''d
data "11111..."
data "1....1.."
data "1.....1."
data "1.....1."
data "1.....1."
data "1.....1."
data "1....1.."
data "11111..."
''e
data "1111111."
data "1.....1."
data "1......."
data "1......."
data "111111.."
data "1......."
data "1.....1."
data "1111111."
''f
data "1111111."
data "1.....1."
data "1......."
data "1......."
data "111111.."
data "1......."
data "1......."
data "1......."
''g
data "..111..."
data ".1...1.."
data "1.....1."
data "1......."
data "1...111."
data "1.....1."
data ".1...1.."
data "..111..."
''h
data "1.....1."
data "1.....1."
data "1.....1."
data "1.....1."
data "1111111."
data "1.....1."
data "1.....1."
data "1.....1."
''i
data "..111..."
data "...1...."
data "...1...."
data "...1...."
data "...1...."
data "...1...."
data "...1...."
data "..111..."
''j
data "..111..."
data "...1...."
data "...1...."
data "...1...."
data "...1...."
data "1..1...."
data "1..1...."
data ".11...."
''k
data "1......."
data "1.....1."
data "1....1.."
data "1...1..."
data "1111...."
data "1...1..."
data "1....1.."
data "1.....1."
''l
data "1......."
data "1......."
data "1......."
data "1......."
data "1......."
data "1......."
data "1......."
data "1111111."
''m
data "1.....1."
data "11...11."
data "1.1.1.1."
data "1..1..1."
data "1..1..1."
data "1.....1."
data "1.....1."
data "1.....1."
''n
data "1.....1."
data "11....1."
data "1.1...1."
data "1..1..1."
data "1..1..1."
data "1...1.1."
data "1....11."
data "1.....1."
''o
data "..111..."
data ".1...1.."
data "1.....1."
data "1.....1."
data "1.....1."
data "1.....1."
data ".1...1.."
data "..111..."
''p
data "11111..."
data "1....1.."
data "1.....1."
data "1....1.."
data "11111..."
data "1.....,."
data "1......."
data "1......."
''q
data "..111..."
data ".1...1.."
data "1.....1."
data "1.....1."
data "1..1..1."
data "1...1.1."
data ".1...1.."
data "..111.1."
''r
data "11111..."
data "1....1.."
data "1.....1."
data "1....1.."
data "111111.."
data "1...1..."
data "1....1.."
data "1.....1."
''s
data "..111..."
data ".1...1.."
data "1.....1."
data "1......."
data ".11111.."
data "......1."
data "1.....1."
data ".11111.."
''t
data "1111111."
data "1..1..1."
data "...1...."
data "...1...."
data "...1...."
data "...1...."
data "...1...."
data "..111..."
''u
data "1.....1."
data "1.....1."
data "1.....1."
data "1.....1."
data "1.....1."
data "1.....1."
data "1.....1."
data ".11111.."
''v
data "1.....1."
data "1.....1."
data "1.....1."
data "1.....1."
data "1.....1."
data ".1...1.."
data "..1.1..."
data "...1...."
''w
data "1.....1."
data "1.....1."
data "1.....1."
data "1.....1."
data "1..1..1."
data "1.1.1.1."
data "11...11."
data "1.....1."
''x
data "1.....1."
data ".1...1.."
data "..1.1.."
data "...1...."
data "...1...."
data "..1.1..."
data ".1...1.."
data "1.....1."
''y
data "1.....1."
data ".1...1.."
data "..1.1.."
data "...1...."
data "...1...."
data "..1....."
data ".1......"
data "1......."
''z
data "1111111."
data ".....1.."
data "....1..."
data "...1...."
data "...1...."
data "..1....."
data ".1......"
data "1111111."
''0
data ".11111.."
data "1.....1."
data "1.....1."
data "1.....1."
data "........"
data "1.....1."
data "1.....1."
data ".11111.."
''1
data "........"
data "......1."
data "......1."
data "......1."
data "........"
data "......1."
data "......1."
data "........"
''2
data ".11111.."
data "......1."
data "......1."
data "......1."
data ".11111.."
data "1......."
data "1......."
data ".11111.."
''3
data ".11111.."
data "......1."
data "......1."
data "......1."
data ".11111.."
data "......1."
data "......1."
data ".11111.."
''4
data "........"
data "1.....1."
data "1.....1."
data "1.....1."
data ".11111.."
data "......1."
data "......1."
data "........"
''5
data ".11111.."
data "1......."
data "1......."
data "1......."
data ".11111.."
data "......1."
data "......1."
data ".11111.."
''6
data ".11111.."
data "1......."
data "1......."
data "1......."
data ".11111.."
data "1.....1."
data "1.....1."
data ".11111.."
''7
data ".11111.."
data "......1."
data "......1."
data "......1."
data "........"
data "......1."
data "......1."
data "........"
''8
data ".11111.."
data "1.....1."
data "1.....1."
data "1.....1."
data ".11111.."
data "1.....1."
data "1.....1."
data ".11111.."
''9
data ".11111.."
data "1.....1."
data "1.....1."
data "1.....1."
data ".11111.."
data "......1."
data "......1."
data ".11111.."
''[
data "..1111.."
data "..1....."
data "..1....."
data "..1....."
data "..1....."
data "..1....."
data "..1....."
data "..1111.."
'']
data "..1111..."
data ".....1.."
data ".....1.."
data ".....1.."
data ".....1.."
data ".....1.."
data ".....1.."
data "..1111.."
''=
data "........"
data "........"
data "..1111.."
data "........"
data "........"
data "..1111.."
data "........"
data "........"


sub digit( x as integer , y as integer , b as integer , d as double , kl as ulong )
  dim as integer i , j
  for i = 0 to 7
    for j = 0 to 7
      if ( letterpart( b , i ) and 2 ^ j ) <> 0 then
        circle ( x + j * d - 3 * d , y + i * d - 3 * d ) , d / 2 , kl ,,,, f
      end if
    next j
  next i
end sub
const as ulong transparent = &h1000000
sub text( x as integer , y as integer _
  , t as string , d as double _
  , kl as ulong , bkl as ulong = transparent )
  dim as integer i , l = len( t )
  if bkl < transparent then
    line ( x - l * 4 * d + d * 4 , y - 4 * d ) _
    - step ( l * 8 * d - d * 4 , 9 * d ) , bkl , bf
  end if
  for i = 1 to l
    digit x + i * 8 * d - l * 4 * d - 4 * d , y _
    , instr( letters , lcase( mid( t , i , 1 ) ) ) , d , kl
  next i
end sub
counting_pine
Site Admin
Posts: 6172
Joined: Jul 05, 2005 17:32
Location: Manchester, Lancs

Re: try at al rubix's

Postby counting_pine » Jun 08, 2018 14:06

I had to add this line in place of math.bas:

Code: Select all

#define rad(x) ((x)*atn(1)/45)

I like the large font.
It quits for me ok if I press 'q', Enter, and then press a key.
It's not easy for me to work out how the drawing code works. Maybe try to isolate it and try it in a more simple scenario?
lizard
Posts: 440
Joined: Oct 17, 2017 11:35
Location: Germany

Re: try at al rubix's

Postby lizard » Jun 08, 2018 23:03

counting_pine wrote:I like the large font.

Agree. But in graphics it is sometimes not good to have a even number of lines, because there is no middle line and it is hard to get symmetry. So i deleted a data line in each glyph and now there is line 4 as middle line.

Code: Select all

' bigtext.bas

dim shared as integer letterpart( 40 , 7 )
dim as integer j , k
const as string letters = "abcdefghijklmnopqrstuvwxyz0123456789[]="
dim as string q
for i as byte = 1 to len( letters )
  for j = 0 to 6
    read q
    for k = 0 to 7
      if mid( q , k + 1 , 1 ) = "1" then
        letterpart( i , j ) = letterpart( i , j ) or 2 ^ k
      end if
    next k
  next j
next i

''a
data "..111..."
data ".1...1.."
data "1.....1."
data "1111111."
data "1.....1."
data "1.....1."
data "1.....1."
''b
data "111111.."
data "1.....1."
data "1.....1."
data "111111.."
data "1.....1."
data "1.....1."
data "111111.."
''c
data "..111..."
data ".1...1.."
data "1......."
data "1......."
data "1......."
data ".1...1.."
data "..111..."
''d
data "11111..."
data "1....1.."
data "1.....1."
data "1.....1."
data "1.....1."
data "1....1.."
data "11111..."
''e
data "1111111."
data "1.....1."
data "1......."
data "111111.."
data "1......."
data "1.....1."
data "1111111."
''f
data "1111111."
data "1.....1."
data "1......."
data "111111.."
data "1......."
data "1......."
data "1......."
''g
data "..111..."
data ".1...1.."
data "1......."
data "1...111."
data "1.....1."
data ".1...1.."
data "..111..."
''h
data "1.....1."
data "1.....1."
data "1.....1."
data "1111111."
data "1.....1."
data "1.....1."
data "1.....1."
''i
data "..111..."
data "...1...."
data "...1...."
data "...1...."
data "...1...."
data "...1...."
data "..111..."
''j
data "..111..."
data "...1...."
data "...1...."
data "...1...."
data "1..1...."
data "1..1...."
data ".11...."
''k
data "1.....1."
data "1....1.."
data "1...1..."
data "1111...."
data "1...1..."
data "1....1.."
data "1.....1."
''l
data "1......."
data "1......."
data "1......."
data "1......."
data "1......."
data "1......."
data "1111111."
''m
data "1.....1."
data "11...11."
data "1.1.1.1."
data "1..1..1."
data "1..1..1."
data "1.....1."
data "1.....1."
''n
data "1.....1."
data "11....1."
data "1.1...1."
data "1..1..1."
data "1...1.1."
data "1....11."
data "1.....1."
''o
data "..111..."
data ".1...1.."
data "1.....1."
data "1.....1."
data "1.....1."
data ".1...1.."
data "..111..."
''p
data "11111..."
data "1....1.."
data "1....1.."
data "11111..."
data "1.....,."
data "1......."
data "1......."
''q
data "..111..."
data ".1...1.."
data "1.....1."
data "1.....1."
data "1...1.1."
data ".1...1.."
data "..111.1."
''r
data "11111..."
data "1....1.."
data "1....1.."
data "111111.."
data "1...1..."
data "1....1.."
data "1.....1."
''s
data "..1111.."
data ".1....1."
data ".1......"
data "..1111.."
data "......1."
data ".1....1."
data "..1111.."
''t
data "1111111."
data "1..1..1."
data "...1...."
data "...1...."
data "...1...."
data "...1...."
data "..111..."
''u
data "1.....1."
data "1.....1."
data "1.....1."
data "1.....1."
data "1.....1."
data ".1...1.."
data "..111..."
''v

data "1.....1."
data "1.....1."
data ".1...1.."
data ".1...1.."
data "..1.1..."
data "..1.1..."
data "...1...."
''w
data "1.....1."
data "1.....1."
data "1.....1."
data "1..1..1."
data "1.1.1.1."
data "11...11."
data "1.....1."
''x
data "1.....1."
data ".1...1.."
data "..1.1.."
data "...1...."
data "..1.1..."
data ".1...1.."
data "1.....1."
''y
data "1.....1."
data ".1...1.."
data "..1.1.."
data "...1...."
data "..1....."
data ".1......"
data "1......."
''z
data "1111111."
data ".....1.."
data "....1..."
data "...1...."
data "..1....."
data ".1......"
data "1111111."
''0
data ".11111.."
data "1.....1."
data "1.....1."
data "1.....1."
data "1.....1."
data "1.....1."
data ".11111.."
''1
data "......1."
data ".....11."
data "....1.1."
data "......1."
data "......1."
data "......1."
data "......1."
''2
data ".11111.."
data "......1."
data "......1."
data ".11111.."
data "1......."
data "1......."
data ".11111.."
''3
data ".11111.."
data "......1."
data "......1."
data "....11.."
data "......1."
data "......1."
data ".11111.."
''4
data "1.....1."
data "1.....1."
data "1.....1."
data ".111111."
data "......1."
data "......1."
data "......1."
''5
data ".11111.."
data "1......."
data "1......."
data ".11111.."
data "......1."
data "......1."
data ".11111.."
''6
data ".11111.."
data "1......."
data "1......."
data ".11111.."
data "1.....1."
data "1.....1."
data ".11111.."
''7
data "1111111."
data ".....1.."
data "....1..."
data "...1...."
data "..1....."
data ".1......"
data "1......."
''8
data ".11111.."
data "1.....1."
data "1.....1."
data ".11111.."
data "1.....1."
data "1.....1."
data ".11111.."
''9
data ".11111.."
data "1.....1."
data "1.....1."
data ".111111."
data "......1."
data "......1."
data ".11111.."
''[
data "..1111.."
data "..1....."
data "..1....."
data "..1....."
data "..1....."
data "..1....."
data "..1111.."
'']
data "..1111..."
data ".....1.."
data ".....1.."
data ".....1.."
data ".....1.."
data ".....1.."
data "..1111.."
''=
data "........"
data "........"
data "..1111.."
data "........"
data "........"
data "..1111.."
data "........"


sub digit( x as integer , y as integer , b as integer , d as double , kl as ulong )
  dim as integer i , j
  for i = 0 to 7
    for j = 0 to 7
      if ( letterpart( b , i ) and 2 ^ j ) <> 0 then
        circle ( x + j * d - 3 * d , y + i * d - 3 * d ) , d / 2 , kl ,,,, f
      end if
    next j
  next i
end sub

const as ulong transparent = &h1000000

sub text( x as integer , y as integer _
  , t as string , d as double _
  , kl as ulong , bkl as ulong = transparent )
  dim as integer i , l = len( t )
  if bkl < transparent then
    line ( x - l * 4 * d + d * 4 , y - 4 * d ) _
    - step ( l * 8 * d - d * 4 , 9 * d ) , bkl , bf
  end if
  for i = 1 to l
    digit x + i * 8 * d - l * 4 * d - 4 * d , y _
    , instr( letters , lcase( mid( t , i , 1 ) ) ) , d , kl
  next i
end sub

screen 20 , 32
const as ulong white      = &hffffffff

text 512 , 50 , "ABCDEFGHIJKLMNOPQRSTUVWXYZ" , 4 , white
text 512 , 100 , "[ 1234567890 ]" , 4 , white
text 512 , 150 , "ABCDEFGHIJKLMNOPQRSTUVWXYZ" , 4 , white

text 512 , 550 , "[ s to shuffle ]" , 4 , white
text 512 , 600 , "[ r to reset ]" , 4 , white
text 512 , 650 , "[ q to quit ]" , 4 , white
 
sleep
bluatigro
Posts: 597
Joined: Apr 25, 2012 10:35
Location: netherlands

Re: try at al rubix's

Postby bluatigro » Jun 09, 2018 4:34

pardon :
i forgot _math.bas
here it is

Code: Select all

''bluatigro 6-nov-2013
''game lib : math helper functions + connstands

#ifndef MATH_H
#define MATH_H

const as double pi = atn( 1 ) * 4
const as double golden_ratio = ( sqr( 5 ) - 1 ) / 2

function rad( x as double ) as double
''help function degrees to radians
  return x * pi / 180
end function

function range( l as double , h as double ) as double
  return rnd * ( h - l ) + l
end function

sub rotate( byref k as double , byref l as double , deg as double )
  dim as double s , c , hk , hl
  s = sin( rad( deg ) )
  c = cos( rad( deg ) )
  hk = k * c - l * s
  hl = k * s + l * c
  k = hk
  l = hl
end sub


#endif

bluatigro
Posts: 597
Joined: Apr 25, 2012 10:35
Location: netherlands

Re: try at al rubix's

Postby bluatigro » Jun 09, 2018 5:15

feel free to ad char's to bigtext

i tryed to atomate this whit point(x,y)
but that did not work

if you spot the error : help me

Code: Select all

'' bluatigro 9 jun 2018
'' automatic big text

dim shared as integer letterpart( 255 , 20 ) , char , x , y

screen 18 , 32

for char = 30 to 255
  cls
  print chr( char )
  for x = 0 to 16
    for y = 0 to 20
      if point( x , y ) then
        letterpart( char , y ) or= 2 ^ ( 16 - x )
      end if
    next y
  next x
next char

sub digit( a as integer , b as integer _
  , q as integer , d as integer  , kl as ulong )
  for x = 0 to 16
    for y = 0 to 20
      if letterpart( q , y ) and 2 ^ x then
        circle( a + x * d , b + y * d ) , d / 2 , kl ,,,, f
      end if
    next y
  next x
end sub

digit 0 , 0 , asc( "a" ) , 10 , rgb( 255 , 255 , 255 )

sleep
bluatigro
Posts: 597
Joined: Apr 25, 2012 10:35
Location: netherlands

Re: try at al rubix's

Postby bluatigro » Jun 09, 2018 5:45

now whit bigtext sub

Code: Select all

'' bluatigro 9 jun 2018
'' automatic big text

dim shared as integer letterpart( 255 , 20 )
dim as integer char , ix , iy

screen 18 , 32

for char = 30 to 255
  cls
  print chr( char )
  for ix = 0 to 16
    for iy = 0 to 20
      if point( ix , iy ) then
        letterpart( char , iy ) or= 2 ^ ( 16 - ix )
      end if
    next iy
  next ix
next char

sub digit( a as integer , b as integer _
  , q as integer , d as integer  , kl as ulong )
  dim as integer x , y
  for x = 0 to 16
    for y = 0 to 20
      if letterpart( q , y ) and 2 ^ x then
        circle( a + ( x - 8 ) * d , b + ( y - 10 ) * d ) _
        , d / 3 , kl ,,,, f
      end if
    next y
  next x
end sub

sub bigtext( a as integer , b as integer , txt as string _
  , d as integer , kl as ulong )
  dim as integer l = len( txt ) , x
  for x = 1 to l
    digit a + ( x - l / 2 - 1.5 ) * d * 20 , b _
    , asc( mid( txt , x , 1 ) ) , d , kl
  next x
end sub

bigtext 400 , 300 , "test" , 5 , rgb( 255 , 255 , 255 )

sleep
bluatigro
Posts: 597
Joined: Apr 25, 2012 10:35
Location: netherlands

Re: try at al rubix's

Postby bluatigro » Jun 09, 2018 5:58

FOUNT !!!

BIG TEXT IS WORKING NOW !!

Code: Select all

'' bluatigro 9 jun 2018
'' automatic big text

dim shared as integer letterpart( 255 , 20 )
dim as integer char , ix , iy

screen 18 , 32


for char = 30 to 255
  cls
  print chr( char )
  for ix = 0 to 16
    for iy = 0 to 20
      if point( ix , iy ) <> -16777216 then
        letterpart( char , iy ) += 2 ^ ix
      end if
    next iy
  next ix
next char

sub digit( a as integer , b as integer _
  , q as integer , d as integer  , kl as ulong )
  dim as integer x , y
  for x = 0 to 16
    for y = 0 to 20
      if letterpart( q , y ) and 2 ^ x then
        circle( a + ( x - 8 ) * d , b + ( y - 10 ) * d ) _
        , d / 3 , kl ,,,, f
      end if
    next y
  next x
end sub

sub bigtext( a as integer , b as integer , txt as string _
  , d as integer , kl as ulong )
  dim as integer l = len( txt ) , x
  for x = 1 to l
    digit a + ( x - l / 2 - 1.5 ) * d * 20 , b _
    , asc( mid( txt , x , 1 ) ) , d , kl
  next x
end sub
cls

bigtext 400 , 300 , "GAME OVER !" , 2 , rgb( 255 , 255 , 255 )

sleep
bluatigro
Posts: 597
Joined: Apr 25, 2012 10:35
Location: netherlands

Re: try at al rubix's

Postby bluatigro » Jun 09, 2018 9:04

update :
last error's removed i think

you have to sometimes push q more then 1x to quit

Code: Select all

'' bluatigro 9 jun 2018
'' rubix 6 2
#include "color.bas"
#include "_big_chars.bas"
dim shared as ulong kl( 6 * 4 )
sub rot4( a as integer _
  , b as integer , c as integer , d as integer )
  dim as ulong help = kl( a )
  kl( a ) = kl( b )
  kl( b ) = kl( c )
  kl( c ) = kl( d )
  kl( d ) = help
end sub
function qq( face as integer , poly as integer ) as integer
  return face * 4 + poly
end function
''02
''13
'' 4
''0123
'' 5
sub rotj
  rot4 qq( 4 , 0 ) , qq( 2 , 2 ) , qq( 5 , 3 ) , qq( 0 , 1 )
  rot4 qq( 4 , 2 ) , qq( 2 , 3 ) , qq( 5 , 1 ) , qq( 0 , 0 )
  rot4 qq( 3 , 0 ) , qq( 3 , 2 ) , qq( 3 , 3 ) , qq( 3 , 1 )
end sub
sub rotk
  rot4 qq( 0 , 1 ) , qq( 1 , 1 ) , qq( 2 , 1 ) , qq( 3 , 1 )
  rot4 qq( 0 , 3 ) , qq( 1 , 3 ) , qq( 2 , 3 ) , qq( 3 , 3 )
  rot4 qq( 5 , 0 ) , qq( 5 , 2 ) , qq( 5 , 3 ) , qq( 5 , 1 )
end sub
sub rotl
  rot4 qq( 4 , 2 ) , qq( 1 , 2 ) , qq( 5 , 2 ) , qq( 3 , 1 )
  rot4 qq( 4 , 3 ) , qq( 1 , 3 ) , qq( 5 , 3 ) , qq( 3 , 0 )
  rot4 qq( 2 , 0 ) , qq( 2 , 2 ) , qq( 2 , 3 ) , qq( 2 , 1 )
end sub
sub shufle
  dim as string in
  dim as integer level , i
  cls
  locate 20 , 20
  input "how many shufles ? " ; in
  level = val( in )
  for i = 1 to level
    select case int( rnd * 3 )
      case 0
        rotj
      case 1
        rotk
      case 2
        rotl
      case else
    end select
  next i
end sub
sub resetcube
  dim as integer i , j
  dim as ulong help
  restore
  for i = 0 to 5
    read help
    for j = 0 to 3
      kl( qq( i , j ) ) = help
    next j
  next i
end sub
data red,green,cyan,magenta,blue,yellow
dim as integer i , j , k
dim as string in
resetcube
do
  cls
''02
''13
'' 4
''0123
'' 5
  for j = 0 to 1
    for k = 0 to 1
      line ( 100 + j * 50 , k * 50 ) _
      - step( 45 , 45 ) , kl( qq( 4 , j * 2 + k ) ) , bf
    next k
  next j
  for j = 0 to 1
    for k = 0 to 1
      line ( 100 + j * 50 , k * 50 + 200 ) _
      - step( 45 , 45 ) , kl( qq( 5 , j * 2 + k ) ) , bf
    next k
  next j
  for i = 0 to 3
    for j = 0 to 1
      for k = 0 to 1
        line ( i * 100 + j * 50 , k * 50 + 100 ) _
        - step( 45 , 45 ) , kl( qq( i , j * 2 + k ) ) , bf
      next k
    next j
  next i
  text 225 , 25 , "j" , 4 , white
  text 425 , 175 , "k" , 4 , white
  text 175 , 325 , "l" , 4 , white
  text 512 , 550 , "s to shuffle" , 4 , white
  text 512 , 600 , "r to reset" , 4 , white
  text 512 , 650 , "q to quit" , 4 , white
  locate 27 , 20
  in = ""
  while in = ""
    in = inkey
  wend
  select case in
    case "j"
      rotj
    case "k"
      rotk
    case "l"
      rotl
    case "r"
      resetcube
    case "s"
      shufle
    case else
  end select
 
loop until in = "q"


sleep


_big_chars.bas

Code: Select all

'' bluatigro 9 jun 2018
'' automatic big text

dim shared as integer letterpart( 255 , 20 )
dim as integer char , ix , iy

#include "fbgfx.bi"
#if __FB_LANG__ = "fb"
  Using FB '' Scan code constants are stored in the FB namespace in lang FB
#endif

DIM shared AS INTEGER winx, winy, bitdepth , nu
SCREENINFO winx , winy , bitdepth
SCREENRES winx , winy , 32 , 2 , FB.GFX_FULLSCREEN

for char = 30 to 255
  cls
  print chr( char )
  for ix = 0 to 16
    for iy = 0 to 20
      if point( ix , iy ) <> -16777216 then
        letterpart( char , iy ) += 2 ^ ix
      end if
    next iy
  next ix
next char

sub digit( a as double , b as double _
  , q as double , d as double  , kl as ulong )
  dim as double x , y
  for x = 0 to 16
    for y = 0 to 20
      if letterpart( q , y ) and 2 ^ x then
        circle( a + ( x - 4 ) * d , b + ( y - 4 ) * d ) _
        , d / 3 , kl ,,,, f
      end if
    next y
  next x
end sub

sub text( a as double , b as double , txt as string _
  , d as double , kl as ulong )
  dim as double l = len( txt ) , x
  for x = 1 to l
    digit a + ( x - l / 4 - 1 ) * d * 8 , b _
    , asc( mid( txt , x , 1 ) ) , d , kl
  next x
end sub

lizard
Posts: 440
Joined: Oct 17, 2017 11:35
Location: Germany

Re: try at al rubix's

Postby lizard » Jun 09, 2018 12:39

My next version in 8 x 7, +, -, *, / and \ added:

Code: Select all

' bigtext2.bas

#include "fbgfx.bi"

DIM shared AS INTEGER winx, winy, bitdepth , nu
SCREENINFO winx , winy , bitdepth
SCREENRES winx , winy , 32 , 2 , FB.GFX_FULLSCREEN

dim shared as integer letterpart( 255 , 7 )
dim as integer j , k
const as string letters = "abcdefghijklmnopqrstuvwxyz0123456789[]=+-*/\"
dim as string q
for i as byte = 1 to len( letters )
  for j = 0 to 6
    read q
    for k = 0 to 7
      if mid( q , k + 1 , 1 ) = "1" then
        letterpart( i , j ) = letterpart( i , j ) or 2 ^ k
      end if
    next k
  next j
next i

''a
data "..111..."
data ".1...1.."
data "1.....1."
data "1111111."
data "1.....1."
data "1.....1."
data "1.....1."
''b
data "111111.."
data "1.....1."
data "1.....1."
data "111111.."
data "1.....1."
data "1.....1."
data "111111.."
''c
data "..111..."
data ".1...1.."
data "1......."
data "1......."
data "1......."
data ".1...1.."
data "..111..."
''d
data "11111..."
data "1....1.."
data "1.....1."
data "1.....1."
data "1.....1."
data "1....1.."
data "11111..."
''e
data "1111111."
data "1.....1."
data "1......."
data "111111.."
data "1......."
data "1.....1."
data "1111111."
''f
data "1111111."
data "1.....1."
data "1......."
data "111111.."
data "1......."
data "1......."
data "1......."
''g
data "..111..."
data ".1...1.."
data "1......."
data "1...111."
data "1.....1."
data ".1...1.."
data "..111..."
''h
data "1.....1."
data "1.....1."
data "1.....1."
data "1111111."
data "1.....1."
data "1.....1."
data "1.....1."
''i
data "..111..."
data "...1...."
data "...1...."
data "...1...."
data "...1...."
data "...1...."
data "..111..."
''j
data "..111..."
data "...1...."
data "...1...."
data "...1...."
data "1..1...."
data "1..1...."
data ".11...."
''k
data "1.....1."
data "1....1.."
data "1...1..."
data "1111...."
data "1...1..."
data "1....1.."
data "1.....1."
''l
data "1......."
data "1......."
data "1......."
data "1......."
data "1......."
data "1......."
data "1111111."
''m
data "1.....1."
data "11...11."
data "1.1.1.1."
data "1..1..1."
data "1..1..1."
data "1.....1."
data "1.....1."
''n
data "1.....1."
data "11....1."
data "1.1...1."
data "1..1..1."
data "1...1.1."
data "1....11."
data "1.....1."
''o
data "..111..."
data ".1...1.."
data "1.....1."
data "1.....1."
data "1.....1."
data ".1...1.."
data "..111..."
''p
data "11111..."
data "1....1.."
data "1....1.."
data "11111..."
data "1.....,."
data "1......."
data "1......."
''q
data "..111..."
data ".1...1.."
data "1.....1."
data "1.....1."
data "1...1.1."
data ".1...1.."
data "..111.1."
''r
data "11111..."
data "1....1.."
data "1....1.."
data "111111.."
data "1...1..."
data "1....1.."
data "1.....1."
''s
data "..1111.."
data ".1....1."
data ".1......"
data "..1111.."
data "......1."
data ".1....1."
data "..1111.."
''t
data "1111111."
data "1..1..1."
data "...1...."
data "...1...."
data "...1...."
data "...1...."
data "..111..."
''u
data "1.....1."
data "1.....1."
data "1.....1."
data "1.....1."
data "1.....1."
data ".1...1.."
data "..111..."
''v

data "1.....1."
data "1.....1."
data ".1...1.."
data ".1...1.."
data "..1.1..."
data "..1.1..."
data "...1...."
''w
data "1.....1."
data "1.....1."
data "1.....1."
data "1..1..1."
data "1.1.1.1."
data "11...11."
data "1.....1."
''x
data "1.....1."
data ".1...1.."
data "..1.1.."
data "...1...."
data "..1.1..."
data ".1...1.."
data "1.....1."
''y
data "1.....1."
data ".1...1.."
data "..1.1.."
data "...1...."
data "..1....."
data ".1......"
data "1......."
''z
data "1111111."
data ".....1.."
data "....1..."
data "...1...."
data "..1....."
data ".1......"
data "1111111."
''0
data ".11111.."
data "1.....1."
data "1.....1."
data "1.....1."
data "1.....1."
data "1.....1."
data ".11111.."
''1
data "......1."
data ".....11."
data "....1.1."
data "......1."
data "......1."
data "......1."
data "......1."
''2
data ".11111.."
data "......1."
data "......1."
data ".11111.."
data "1......."
data "1......."
data ".11111.."
''3
data ".11111.."
data "......1."
data "......1."
data "....11.."
data "......1."
data "......1."
data ".11111.."
''4
data "1.....1."
data "1.....1."
data "1.....1."
data ".111111."
data "......1."
data "......1."
data "......1."
''5
data ".11111.."
data "1......."
data "1......."
data ".11111.."
data "......1."
data "......1."
data ".11111.."
''6
data ".11111.."
data "1......."
data "1......."
data ".11111.."
data "1.....1."
data "1.....1."
data ".11111.."
''7
data "1111111."
data ".....1.."
data "....1..."
data "...1...."
data "..1....."
data ".1......"
data "1......."
''8
data ".11111.."
data "1.....1."
data "1.....1."
data ".11111.."
data "1.....1."
data "1.....1."
data ".11111.."
''9
data ".11111.."
data "1.....1."
data "1.....1."
data ".111111."
data "......1."
data "......1."
data ".11111.."
''[
data "..1111.."
data "..1....."
data "..1....."
data "..1....."
data "..1....."
data "..1....."
data "..1111.."
'']
data "..1111..."
data ".....1.."
data ".....1.."
data ".....1.."
data ".....1.."
data ".....1.."
data "..1111.."
''=
data "........"
data "........"
data "..1111.."
data "........"
data "..1111.."
data "........"
data "........"
''+
data "........"
data "...1...."
data "...1...."
data ".11111.."
data "...1...."
data "...1...."
data "........"
''-
data "........"
data "........"
data "........"
data "..1111.."
data "........"
data "........"
data "........"
''*
data "........"
data "........"
data "..1.1..."
data "...1...."
data "..1.1..."
data "........"
data "........"
''/
data "........"
data "......1."
data ".....1.."
data "....1..."
data "...1...."
data "..1....."
data "........"
''\
data "........"
data ".1......"
data "..1....."
data "...1...."
data "....1..."
data ".....1.."
data "........"

const as ulong transparent = &h1000000
''primary colors
const as ulong black      = &hff000000
const as ulong red        = &hffff0000
const as ulong green      = &hff00ff00
const as ulong yellow     = &hffffff00
const as ulong blue       = &hff0000ff
const as ulong magenta    = &hffff00ff
const as ulong cyan       = &hff00ffff
const as ulong white      = &hffffffff
''mix colors
const as ulong orange     = &hffff7f00
const as ulong gray       = &hff7f7f7f
const as ulong pink       = &hffff7f7f
const as ulong purple     = &hff7f007f
const as ulong darkRed    = &hff7f0000
const as ulong darkYellow = &hff7f7f00
const as ulong darkGreen  = &hff007f00
const as ulong darkBlue   = &hff00007f


sub digit( x as integer , y as integer , b as integer , d as double , kl as ulong )
  dim as integer i , j
  for i = 0 to 6
    for j = 0 to 7
      if ( letterpart( b , i ) and 2 ^ j ) <> 0 then
        circle ( x + j * d - 3 * d , y + i * d - 3 * d ) , d / 2 , kl ,,,, f
      end if
    next j
  next i
end sub

sub text( x as integer , y as integer _
  , t as string , d as double _
  , kl as ulong , bkl as ulong = transparent )
  dim as integer i , l = len( t )
  if bkl < transparent then
    line ( x - l * 4 * d + d * 4 , y - 4 * d ) _
    - step ( l * 8 * d - d * 4 , 9 * d ) , bkl , bf
  end if
  for i = 1 to l
    digit x + i * 8 * d - l * 4 * d - 4 * d , y _
    , instr( letters , lcase( mid( t , i , 1 ) ) ) , d , kl
  next i
end sub

text 600 , 050,  "ABCDEFGHIJKLMNOPQRSTUVWXYZ" , 1 , magenta
text 600 , 100 , "[ 123 - 7890=+-*/\ ]" , 2 , white
text 600 , 150 , "ABCDE 777\64 Z" , 3 , orange
text 600 , 200 , "2 + 2 / 57 = 1437" , 4 , darkRed
text 600 , 250 , "X[2] * 7 / -7 = [7]E12" , 5 , darkYellow
text 600 , 300 , "A5 0 +6 + 5 ++VZ" , 6 , red
text 600 , 400 , "ABCDEFGHIJKLMNOPQ" , 7, pink
text 600 , 450 , "[ 1234567890=+-*/]" , 8, darkGreen
text 600 , 500 , "ABCDEF * JKOPQ \ UVWXYZ" , 1, darkBlue
text 600 , 550 , "2 + 2 / 57 = 1437" , 2, darkRed
text 600 , 600 , "X[2] * 7 /57 = [7]E12" , 3, darkYellow
text 600 , 650 , "A5 0 +6 + 5 ++VZ" , 4, blue
text 600 , 700 , "ABCD -- IJKL ++ QRS" , 5, yellow
text 600 , 750 , "[ 1234567890=+-*/ \ ]" , 6 , cyan
text 600 , 800 , "ABCDEF ***  PQRSTUVW" , 7, purple
text 600 , 850 , "2 + 2 / 570 = 1437" , 8, black

sleep

Return to “Game Dev”

Who is online

Users browsing this forum: No registered users and 18 guests