XFC v1.0 : Extensions For Codea [update 1.1][1.2]

Hello!
Some of you may remember the project XFC i posted some months ago, as a proof of concept.
Well i have started giving some flesh to it. I have put 4 useful meters: FPS, ms, memory, and a clock. And an embeded update system, so once you’ve got it, updating will be as simple as a tap on a button! (2 buttons actually).
You can install them in your program just by making a dependancy to XFC (no line of code needed).
Here is the video:
http://www.youtube.com/watch?v=TQ9OI4JSQW0
For the install, you can get it as usual from my web site: http://jmv38.comze.com/CODEAbis/server.php
Note i had some difficulties to install the program on my ipad1:
1- i could not select the code from safari, i had to copy the adress in goodreader and download it from there.
2- when running the installer, you must paste it into a project named XFC. But it seems Codea does not take it into account immediately, so you have to exit the project, restart it from Codea project list, and then it works. (if you dont, codea tells the project does not exist, which is wrong).
Let me know if it works well for you.

@Jmv38 This is awesome! Will use it for sure!

@Jmv38 Looks even better! Trying it now.

@jmv38 looks great :wink:

Very useful thanks =D>

Finally got a chance to try it, And Yesss!!! I’ll never have to type

fps = .9*fps + .1/DeltaTime

A doubt though.

Have you forgotten to push and popMatrix somewhere?? cause this happens when I use it.

https://www.dropbox.com/s/1d4drwe9j5kdty3/2013-11-18%2019.37.47.png

Whereas this should have happened

https://www.dropbox.com/s/wi02wyefw161fys/2013-11-18%2019.37.57.png

Though it doesn’t happen in all projects, maybe because they others have push and PopMatrix before every text.

And just a suggestion even though it doesn’t make much of a difference. While the pop up animations take place while changing some options, that time too the Matrix isn’t popped as the text size changes, I couldn’t screencap it as it’s quite fast.

Well, I think you should never type fps = .9*fps + .1/DeltaTime at all because it isn’t a true measure of frame rate.

It would be nice to offer a few different computations of frame rate in a library like this.

But doesn’t it give the average??

Any other better way to measure FPS using little code?

EDIT: just read your other post.

@jmv38 , i had to reset codea 2 times, but finaly works great. :slight_smile: .

just a detail, when I put on one of my projects XFC dependence, pictures of my project for some reason change their position … but no matter, I think it’s my iPad.

look the last discussion: http://twolivesleft.com/Codea/Talk/discussion/4096/comics-tintin#Item_30

@saurabh and @luismi i will check this problem. I remember i had to clean that pb out before posting, but i forgot, sorry. That will be an opportunity to chek the embedded update functionnality! ;-).
@Andrew_Stacey well in this version i have written the exact average fps value. Not to comply with your standards, :wink: , but to update the fps text only every 0.5s (this avoids the memory and ms increase due to new string creation and delete at each draw). Then is easier to compute the exact average in last 0.5s period. I dont plan to add any other fps method, unless you convince me to.

@luismi btw, can explain a bit more what happened? Why did you have to have to restart codea? What happend?

when i try xfc with my bomberman project it works very fine, i have just the same issue ( picture move at the top right ). wonderfull program :)>-

@saurbh, @luismi or @hpsoft can one of you post a (small) program with the pb? Then it will be faster for me to solve it. Thanks!


function setup()
    
    hauteur=20
    xl=200  ; yl=200 ; vitl=12
    xr=600 ; yr=400 ; vitr=12
    displayMode(FULLSCREEN_NO_BUTTONS) ; supportedOrientations(LANDSCAPE_RIGHT)
    GlobalTouches = {} ; LeftStickOP={} ; RightStickOP={}
    DualStickLeft = { posx=120, posy=50, Radius=50, StickRadius=20 }
    DualStickRight = { posx=900, posy=50, Radius=50, StickRadius=20 }
    
    images =
    
    {
    
        { readImage("Planet Cute:Stone Block"), "Bloc Rocher" }, --1
        { readImage("Planet Cute:Stone Block Tall"), "Bloc RocherHaut" }, --2
        { readImage("Planet Cute:Dirt Block"), "Bloc Terre" }, --3
        { readImage("Planet Cute:Grass Block"), "Bloc Herbe" }, --4
        { readImage("Planet Cute:Wood Block"), "Bloc Bois" }, --5
        { readImage("Planet Cute:Water Block"), "Bloc Eau" }, --6
        { readImage("Planet Cute:Wall Block"), "Bloc Tour" }, --7
        { readImage("Planet Cute:Wall Block Tall"), "Bloc TourHaute" }, --8
        { readImage("Planet Cute:Plain Block"), "Bloc Gris" }, --9
        { readImage("Planet Cute:Window Tall"), "Bloc Fenetre" }, --10
        { readImage("Planet Cute:Tree Short"), "Bloc Buisson" }, --11
        
        { readImage("Planet Cute:Chest Closed"), "Coffre Fermé" }, --12
        { readImage("Planet Cute:Chest Open"), "Coffre Ouvert" }, --13

        { readImage("Planet Cute:Heart"), "Coeur" }, --14
        { readImage("Planet Cute:Key"), "Clef" }, --15
        { readImage("Planet Cute:Star"), "Etoile" } --16
        
    }

    -- Des tableaux 15x13 :

    levels = {}

    levels[1] =
    
    {
      {  1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,  1,   1  },
      {  1,  21,  22,  21,  21,  22,  21,  22,  21,  22,  21,  22,  21,  22,  1  },
      {  1,  22,   1,  22,   1,  22,   1,  22,   1,  22,   1,  22,   1,  22,  1  },
      {  1,  21,  22,  21,  21,  22,  21,  22,  21,  22,  21,  22,  21,  22,  1  },
      {  1,  22,   1,  22,   1,  22,   1,  22,   1,  22,   1,  22,   1,  22,  1  },
      {  1,  21,  22,  21,  21,  22,  21,  22,  21,  22,  21,  22,  21,  22,  1  },
      {  1,  22,   1,  22,   1,  22,   1,  22,   1,  22,   1,  22,   1,  22,  1  },
      {  1,  21,  22,  21,  21,  22,  21,  22,  21,  22,  21,  22,  21,  22,  1  },
      {  1,  22,   1,  22,   1,  22,   1,  22,   1,  22,   1,  22,   1,  22,  1  },
      {  1,  21,  22,  21,  21,  22,  21,  22,  21,  22,  21,  22,  21,  22,  1  },
      {  1,  22,   1,  22,   1,  22,   1,  22,   1,  22,   1,  22,   1,  22,  1  },
      {  1,  21,  22,  21,  21,  22,  21,  22,  21,  22,  21,  22,  21,  22,  1  },
      {  1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,  1,   1  }
    }

    hasard()

end

function hasard()
   -- Ajoute des obstacles au hasard dans le niveau

    for i=1, 15 do
        valy=math.random(13) ; valx=math.random(15) ; val=levels[1][valy][valx]
        if val==21 or val==22 then levels[1][valy][valx]=3 end
    end
    
    for i=1, 15 do
        valy=math.random(13) ; valx=math.random(15) ; val=levels[1][valy][valx]
        if val==21 or val==22 then levels[1][valy][valx]=5 end
    end

    for i=1, 15 do
        valy=math.random(13) ; valx=math.random(15) ; val=levels[1][valy][valx]
        if val==21 or val==22 then levels[1][valy][valx]=11 end
    end

end

function touched(touch)
    if touch.x>920 and touch.y>710 then close() end
    if touch.state == ENDED then GlobalTouches[touch.id] = nil
       LeftStickOP.status=false ; RightStickOP.status=false
    else    GlobalTouches[touch.id] = touch
    end
end

function draw()
    
    -- Pour faire trembler le sol
    -- hauteur=math.random(20)
    
    background(69, 180, 59, 255)
    DisplayLevel() ; DualStickDraw()
    sprite("Cargo Bot:Fast Button Inactive",870,743)
    sprite("Cargo Bot:Step Button",970,743)
    
    tint(76, 66, 76, 128)
    sprite("Tyrian Remastered:Sphere",40,50,23*2,23*2)
    sprite("Tyrian Remastered:Sphere",980,50,23*2,23*2)
    noTint()
    
    if LeftStickOP.status==true then xl=xl+LeftStickOP.xl/vitl ;  yl=yl+LeftStickOP.yl/vitl end
    sprite("Planet Cute:Character Boy",xl,yl,101*2/3,171*2/3)
    
    if RightStickOP.status==true then xr=xr+RightStickOP.xr/vitr ;  yr=yr+RightStickOP.yr/vitr end
    sprite("Planet Cute:Character Pink Girl",xr,yr,101*2/3,171*2/3)

end



function DualStickDraw()
    
    fill(60, 111, 161, 70) ; ellipseMode(RADIUS)
    local dsl = DualStickLeft; local dsr = DualStickRight
    ellipse(dsl.posx,dsl.posy,dsl.Radius) ; ellipse(dsr.posx,dsr.posy,dsr.Radius)
    
    for _,touch in pairs(GlobalTouches) do
        fill(216, 11, 11, 70)
        local dx, dy, r = (touch.x-dsl.posx), (touch.y-dsl.posy), dsl.Radius
        if ((dx * dx) + (dy * dy)) < (r * r) then
            ellipse(touch.x, touch.y, dsl.StickRadius)
            LeftStickOP.status = true ; LeftStickOP.xl = dx ; LeftStickOP.yl = dy
        end
        dx, dy, r = (touch.x-dsr.posx), (touch.y-dsr.posy), dsr.Radius
        if ((dx * dx) + (dy * dy)) < (r * r) then
            ellipse(touch.x, touch.y, dsr.StickRadius)
            RightStickOP.status = true ; RightStickOP.xr = dx ; RightStickOP.yr = dy
        end
    end

end

function DisplayLevel()
    
for lig=1, 13 do
    for col=1, 15 do
        val=levels[1][lig][col]
        if val<20 then
           sprite(images[val][1],101*2/3*col-27,750-55*lig,101*2/3,171*2/3)
        else
           sprite(images[4][1],101*2/3*col-27,750-hauteur-55*lig,101*2/3,171*2/3)
        end
    end
end

end

@jmv38 je ne sais pas comment inclure un screenshot dans un post du forum
ps : j ai un message d erreur quand j essai ton excellent programme 2d mesh avec xfc en dépendance.

@hpsoft ok thanks for the prog.
I have released a v1.1 can you download it from XFC itself and check if it solves your pb? I dont see any problem with this version.

@hpsoft concerning 2d mesh drawer, the problem is because i copied some of XFC in it, an old version, so it overides my new XFC! I will have to think about that…

Concerning the update let me know how it works for you. I meant to make it transparent, so afte loading and changing the tabs, i do restart(), but i a not sure it really works (on my ipad the new version is already there…). So maybe you have to leave the project and reload it for the new tabs to really work? Let me know.
By the way, i think i would be better to do the update from XFC itself, not another program (although it should work, in principle)

with this new version, i have no problem concerning picture position
and i like the button on the top

@hpsoft. Good!
What do you mean ‘i like the buttons on the top’? I put the buttons there, but their position should not have changed for you (normally i keep your settings unchanged in UserData tab… Another thing to correct!)