Tricky

Post Reply
DrChip
Posts: 167
Joined: Wed Oct 22, 2014 3:26 pm
My devices: iPhone 4 to 6+,iPad mini to iPad air 2

Tricky

Post by DrChip »

Code: Select all

rem Tricky v3
rem iPhone 6 Plus / iOS 8.3 b4
rem This is from my son Digit. He's 12...
rem adjust bs to device. 64 - iphone, 128 ipad
rem v3 fixed scoller and block size
rem Enjoy...

' Some basic stuff..

  graphics
  sw=screen_width()
  sh=screen_height()
  dim block(10, 8)
  bs=64 ' size of the block larger for ipad
  message$ = "                                Hey, where's my coke? Thanks. Oh, welcome to Tricky, my fun little demo! I (Digit) have done this, in case you didn't know it already.. I hope you like it! Bye!                                "

  length = len(message$)

' Somekind of intro..

  do
    refresh off
    graphics clear 31/255,31/255,31/255

    for what = 0 to 31
      draw color 0, (what * 8)/255, 0
      draw text "Digit presents" at sw/4, (what + 20)
    next what

    draw color 1,1,1
    draw text "Digit presents" at sw/4, 20+31

    draw color 1, 0, 1
    draw text "..Tricky.." at sw/3, 51+22

    draw color 0, 1, 0
    
    draw text "Touch to Start" at 0, sh-20

    refresh on
  until touch_x(0) <> -1


  do
    refresh off
    graphics clear 

' Graphics!

    for what = 0 to 31
      x_slower = x_slower - 1

      if x_slower < 0 then
        if the_x = -1536 then the_x_direction = 1
        if the_x = 1536 then the_x_direction = 0
      

        if the_x_direction = 0 then the_x = the_x - 1
        if the_x_direction = 1 then the_x = the_x + 1
        

        if the_x = 0 then
          x_slower = 3072
        endif
      end if

      mm = mm + 2
      x = the_x + sw * sin(mm) + sw/2
      y = sh * cos(mm) + sh/2

      if the_x = 0 then
        'graphics clear 0, 0, 64/256
        draw color 0, 0, 1
      else
        'graphics clear  63/255, 0, 0
        draw color  1, 0, 0
      end if

      draw line sw/2, sh/2 to x, y
    next what

    block_slower = block_slower - 1

    for y = 0 to 7
      for x = 0 to 9
        if block_slower < 0 then
          block(x, y) = int(rnd(2))
        end if

        if block(x, y) = 1 then
          if the_x = 0 then
            fill color 0, 0, 1
          else
            fill color 1, 0, 0
          endif

          fill rect  x * bs, y * bs to x * bs + bs, y * bs + bs
        end if
      next x
    next y

    if block_slower < 0 then
      block_slower = 16
    end if


    text_x = text_x + 0.2

    if text_x > length - 32 then
      text_x = 0
    endif

    text_to_show$ = mid$(message$, text_x, sw)

    draw color 1,1,1
    draw text text_to_show$ at 0, 32

    draw color 0, 0, 0
    draw text "T   R   I   C   K   Y" at 0, 0
    draw color  127/255, 127/255, 127/255
    draw text "T   R   I   C   K   Y" at 2, 0

    lsec$ = sec$
    sec$ = right$(time$, 1)

    if lsec$ <> sec$ then
      rate$ = str$(rate)
    end if

    if lsec$ <> sec$ then
      rate = 0
    end if

    rate = rate + 1

    draw color 1,1,1
    draw text  "Frame(s) per second: " & rate$ at 0,sh-20
  refresh on
  until quit = 1

  end

' And that's the end of that demo :)
Attachments
image.jpg
image.jpg (247.84 KiB) Viewed 1553 times
image.jpg
image.jpg (232.95 KiB) Viewed 1553 times
image.jpg
image.jpg (210.21 KiB) Viewed 1553 times
image.jpg
image.jpg (244.96 KiB) Viewed 1553 times
image.jpg
image.jpg (241.89 KiB) Viewed 1553 times
Last edited by DrChip on Fri Sep 04, 2015 2:31 am, edited 3 times in total.

User avatar
Mr. Kibernetik
Site Admin
Posts: 4786
Joined: Mon Nov 19, 2012 10:16 pm
My devices: iPhone, iPad, MacBook
Location: Russia
Flag: Russia

Re: Tricky

Post by Mr. Kibernetik »

It's a fun!

This is a screenshot from iPad:
iOS Simulator Screen Shot 03 апр. 2015 г., 10.21.21.png
iOS Simulator Screen Shot 03 апр. 2015 г., 10.21.21.png (360.63 KiB) Viewed 1551 times

DrChip
Posts: 167
Joined: Wed Oct 22, 2014 3:26 pm
My devices: iPhone 4 to 6+,iPad mini to iPad air 2

Re: Tricky

Post by DrChip »

This is Digit. I'm using my dads account. I updated the code a little. If you change the bs variable to a larger number it should fit an iPad. (bs=128)

I don't know the time syntax yet. Can someone help fix my frames per second?

Thanks,
Digit

Post Reply