It is currently Thu Jun 22, 2017 1:43 pm



Welcome
Welcome to rfobasic

You are currently viewing our boards as a guest, which gives you limited access to view most discussions and access our other features. By joining our free community, you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content, and access many other special features. In addition, registered members also see less advertisements. Registration is fast, simple, and absolutely free, so please, join our community today. **You are not required to provide truthful information to any registration questions. Be whomever you wish to be.!


Post new topic Reply to topic  [ 22 posts ]  Go to page Previous  1, 2, 3
Author Message
 Post subject: Re: gr.render in an apk instead of the editor
Unread postPosted: Thu Mar 16, 2017 1:47 am 
Offline

Joined: Sat Mar 02, 2013 11:04 am
Posts: 859
Location: France
Hello Danny,

dms wrote:
Whow i have to say, looks much more attractive
than mine

more attractive : I can't say that but with fewer lines of code and a different philosophy surely :)
I had fun using the function gr_collision() ;)
I must say that the majority of the tools I used in this program, I had already made them for a French regional variant of the CrazyHeight that I will share soon. 8-)

dms wrote:
Maybe one more point to add, if the cards are all done, ASIN
you cleared the deck, auto start a new game
Thats what i have done in my version

This is exactly the question I asked myself ...;)
I'll change the code to do that.

Hope to see your version soon.

Cheers

Gilles

_________________
"It is better to mobilize intelligence for stupid things, rather than mobilizing stupidity for intelligent things."
Galaxy TAB S 8.4, 2560x1600, Marshmallow 6.0.1
Galaxy Note II, 1280x720, JB4.1.2
Galaxy A3, 1280x720, Android 6.0.1


Last edited by Cassiope34 on Thu Mar 16, 2017 3:23 am, edited 1 time in total.

Report this post
Top
 Profile  
 
 Post subject: Re: gr.render in an apk instead of the editor
Unread postPosted: Thu Mar 16, 2017 2:13 am 
Offline

Joined: Sat Mar 02, 2013 11:04 am
Posts: 859
Location: France
Last update to have a continuous play...
Code:
REM copie de Maketen de 'dms' alias Danny sur le forum

Fn.def clc(n,ncp)    % card color   1=clover, 2=spade, 3=heart, 4=diamond
Fn.rtn int(n/(8+0.1+5*(ncp=52)))+1
Fn.end

Fn.def vlc(n,ncp)    % card value
d =8+5*(ncp=52) : noc =mod(n,d) : noc+=d*(noc=0)
if ncp=32 then Fn.rtn val(word$("1 7 8 9 10 11 12 13",noc)) else Fn.rtn noc
Fn.end

Fn.def LastPtr(ptr)  % puts the graphic pointer 'ptr' above all others (and so always visible).
  gr.getDL ndl[],1
  array.length sz, ndl[]
  if !ptr | sz=1 | ndl[sz] =ptr then array.delete ndl[] : Fn.rtn 0
  array.search ndl[],ptr,n
  if n
    for nn=n to sz-1 : ndl[nn] =ndl[nn+1] : next
    ndl[sz] =ptr : gr.newDL ndl[]
  endif
  array.delete ndl[]
Fn.end

Fn.def move2(ptr, arx, ary, pas)   % move smoothly the bitmap 'ptr' to arx,ary  (with 'pas' around 12 pixels)
LastPtr( ptr )
if pas>1
  gr.get.position ptr,dpx,dpy
  ex =int((arx-dpx)/pas) : ey =int((ary-dpy)/pas)
  for e=1 to pas-1 : gr.move ptr, ex, ey : gr.render : next
endif
gr.modify ptr, "x",arx, "y",ary : gr.render
Fn.end

FN.DEF RectR(x,y, c, lx,ly, fill)     %  make rectangle with rounded corners.
GR.ARC nul, x, y, x+c, y+c, -90, -90, fill     % top left
GR.ARC nul, x+lx-c,y, x+lx, y+c, -90, 90, fill   % top right
GR.ARC nul, x, y+ly-c,x+c, y+ly, -180, -90, fill   % bottom left
GR.ARC nul, x+lx-c, y+ly-c, x+lx, y+ly, 0, 90, fill  % bottom right
if !fill
  GR.LINE r1, x+c/2, y, x+lx-c/2, y     % left
  GR.LINE r2, x, y+c/2, x, y+ly-c/2     % up
  GR.LINE r3, x+c/2, y+ly, x+lx-c/2, y+ly  % right
  GR.LINE r4, x+lx, y+c/2, x+lx, y+ly-c/2  % down
else
  c*=0.4
  gr.rect nul, x+c, y, x+lx-c, y+ly
  gr.rect nul, x, y+c, x+lx, y+ly-c
endif
FN.END

gr.open 255,84,140,78,0,1   % kind of green
gr.screen w,h
scx = 800
scy = 1280
sx  = w/scx
sy  = h/scy
gr.scale sx,sy
path$ ="Maketen/"
gr.bitmap.load bmps, path$ + "52_cards.png"
ncp =52 : dcx =158 : dcy =246 : bdos =2 : ptr =1 : vlr =2
DIM bc[ncp], dos[6], p[ncp,2], f[3]

GOSUB MakeCards

DO
  GOSUB InitGame
  new =0 : gover =0
  DO
    do
      gr.touch touched,x,y
      if !background() then gr.render
    until touched | quit | new
    if quit | new then d_u.continue
    do
      gr.touch touched,x,y
    until !touched
    x/=sx : y/=sy
    gr.modify curs, "x",x ,"y",y
   
    for c=1 to ncp
      if gr_collision (curs, p[c,ptr]) then f_n.break     % what card I'm touching.
    next
   
    if c<=ncp & ntc
      gr.get.position p[c,ptr], pcx, pcy
      if pcy>=(gy+3*dcy) then d_u.continue   %  out of one the 9 cards
      if !tch
        vc =vlc(p[c,vlr],ncp)
        oldpcx =pcx : oldpcy =pcy : oldptr =p[c,ptr] : oldc =c
        gr.modify cadre, "x", pcx-10, "y", pcy-10 : gr.show cadre
        tch =1
        if vc=10
          tch =0 : gr.hide cadre
          move2(p[c,ptr], scx,gy+3*dcy, 6) : ntc--
          if nc then move2(p[nc,ptr], pcx,pcy, 8) : gr.modify p[nc,ptr], "bitmap", bc[p[nc,vlr]] : nc--
        endif
      else
        nvc =vlc(p[c,vlr],ncp) : gr.hide cadre : tch =0
        if ((nvc>10 & nvc=vc) | nvc+vc=10) & p[c,ptr]<>oldptr
          move2(p[c,ptr], scx,gy+3*dcy, 6) : ntc--
          move2(p[oldc,ptr], scx,gy+3*dcy, 6) : ntc--
          if nc then move2(p[nc,ptr], pcx,pcy, 8) : gr.modify p[nc,ptr], "bitmap", bc[p[nc,vlr]] : nc--
          if nc then move2(p[nc,ptr], oldpcx,oldpcy, 8) : gr.modify p[nc,ptr], "bitmap", bc[p[nc,vlr]] : nc--
        endif
      endif
      gr.modify ptnc, "text", int$(nc)+" cards left."
      if !ntc then gr.modify ptnc, "text", "end of game..." else GOSUB GameOver
    endif
    if ntc =0
      gr.render : pause 4000 : new =1
    elseif gover
      ntc=0 : POPUP "  GAME OVER  "
    endif
   
  UNTIL new
UNTIL quit
END

OnBackKey:
  GOSUB BoiteMenu
back.resume

BoiteMenu:
  Dialog.message win$,"       What do you want ?", ok, " Exit ", " We continue ? ", " Cancel "
  new  =(ok=1 | ok=2) : quit =(ok=1)
return

GameOver:  % detection
c$ ="" : nn =0
for yy=1 to 3
  for xx=1 to 3
    gr.modify curs, "x",gx+(xx-1)*(dcx+40), "y",gy+(yy-1)*(dcy+40)
    for c=1 to ncp
      if gr_collision(curs, p[c,ptr]) then f_n.break
    next
    if c<=ncp then c$+=format$("%%", vlc(p[c,vlr],ncp)) : nn++   % a string of the 9 cards values.
  next
next
if !IS_IN("10",c$)
  array.fill f[],0
  for c=1 to nn
    v =val(word$(c$,c)) : if v>10 then f[v-10]++
  next
  if f[1]<2 & f[2]<2 & f[3]<2
    gover =1
    for cc=1 to nn
      v1 =val(word$(c$,cc))
      for c=1 to nn
        v2 =val(word$(c$,c)) : if c<>cc & v1+v2=10 then gover =0 : f_n.break
      next
      if !gover then f_n.break
    next
  endif
endif
return

MakeCards:
for c=1 to ncp         %  all cards bitmaps.
  cc =clc(c,ncp) : vc =vlc(c,ncp)
  gr.bitmap.crop bc[c], bmps, (vc-1)*dcx, (cc-1)*dcy, dcx, dcy
next
for d=1 to 6
  gr.bitmap.crop nul, bmps, (d-1)*dcx, 4*dcy, dcx, dcy
  gr.bitmap.scale dos[d], nul, 100, 140 : gr.bitmap.delete nul
next
gr.bitmap.delete bmps     % free memory of the original .png file.
gr.bitmap.create cadr, dcx+20, dcy+20
gr.bitmap.drawinto.start cadr          % create the bitmap to show the selected card.
gr.set.stroke 8
gr.color 255, 200, 200, 200, 0
RectR(0,0, 30, dcx+20, dcy+20, 0)
gr.bitmap.drawinto.end
return

InitGame:
GR.CLS
gx  =(scx-3*(dcx+20))/2
gy  =0.6*dcy
pqx =gx
pqy =gy+3*(dcy+20)+15
ch$ =""
ntc =ncp : t =0
for c=1 to ncp     % make the deck (52 graphicals objects with the 'back' & at the same place)
  do
    n =int(rnd()*ncp)+1
  until !IS_IN(format$("%%",n),ch$)    %  unique...
  ch$+=format$("%%",n)
  p[c,vlr] =n-ncp*(n>ncp) : t+=0.33
  gr.bitmap.draw p[c,ptr], dos[bdos], pqx+t, pqy-t %: gr.render
next
gr.color 0 : gr.point curs, 0,0
gr.color 255, 255, 255, 0, 2
gr.set.stroke 2
gr.text.size 50
gr.text.align 2
gr.text.draw nul, scx/2, 80, "-   M a k e  T e n   -"
gr.color 255,0,0,0,0
RectR(40,20, 30, scx-80, 100, 0)
RectR(pqx+dcx-10, pqy+10, 30, 360, 80, 0)
RectR(40,pqy+160, 30, scx-80, 140, 0)
gr.color 255,0,240,255,1
gr.text.size 30
gr.text.align 1
gr.text.draw nul, 60, pqy+200, "Touch 2 cards or 1 if it's a 10."
gr.text.draw nul, 60, pqy+240, "If their sum =10 or if they are 2 same figures then"
gr.text.draw nul, 60, pqy+280, "new cards will be distributed at their place."
nc =ncp : dy=0
for c=1 to 9          %  distribution of the 9 cards.
  if c=1 | c=4 | c=7 then dx=1 : dy++ : else dx++
  cx =gx +(dx-1)*(dcx+20)
  cy =gy +(dy-1)*(dcy+20)
  move2( p[nc,ptr], cx, cy, 8)
  gr.modify p[nc,ptr], "bitmap", bc[p[nc,vlr]]
  nc--
next
gr.bitmap.draw cadre, cadr, gx+(2-1)*(dcx+20)-10, gy+(2-1)*(dcy+20)-10 : gr.hide cadre
gr.color 255, 255, 255, 0, 2
gr.text.size 40
gr.text.draw ptnc, pqx+1.1*dcx, pqy+60, int$(nc)+" cards left."
return

_________________
"It is better to mobilize intelligence for stupid things, rather than mobilizing stupidity for intelligent things."
Galaxy TAB S 8.4, 2560x1600, Marshmallow 6.0.1
Galaxy Note II, 1280x720, JB4.1.2
Galaxy A3, 1280x720, Android 6.0.1


Report this post
Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 22 posts ]  Go to page Previous  1, 2, 3


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
suspicion-preferred