The Final Frontier

@Bri_G see attached.

I suggest you do a global search for “assets.documents”.

@UberGoober - I thought you should use project but couldn’t get that to work. The paths I put in worked for me - but they would wouldn’t they.

I haven’t done this for a long time. Do you use say pacman.file where pacman is the game name and file the asset name?

I think the new asset browser lets you cut and paste the asset string when you’re inside the project.

@dave1707 @UberGoober - need help on this one guys. I have all the files in the codea project folder but still get errors when addressing them. I have used
path = projectName
path = Project.filename
image = readImage(projectName.filename)

But none of them has worked - can you shed some light on how I need to address both text files and images in the project folder so that I can export the project to run independent of my pad?

@Bri_G You should be able to tap within the () of the sprite command or on the name within the (). It should bring up a list of folders with the project folder at the top. Open the project folder and tap on a sprite. It’s name is automatically inserted within the sprite() .

That should work for any other command that requires an asset.

@Bri_G It’s ‘asset.filename_here’ for files in the project’s .codea folder.

@Bri_G Here’s an example of assets that are in a project folder. Once the assets are ‘Move To’ the projects folder, it’s just a matter of touching between the () and selecting whatever shows.

function setup()
    img=readImage(asset.Character_Horn_Girl)
    txt=readText(asset.Info)
    sprite(asset.Character_Horn_Girl,300,300)
    a=craft.model(asset.Monkey)
    a=craft.material(asset.Basic)  
end

@dave1707 @Steppers - thanks guys, amended my code and will test on my other pad then update the original link. Only second time I’ve done this and that was yonks ago!! Thanks again.

@dave1707 @Steppers - link below for the project after trying to strip out all asset addressing mistakes. If this works yoou need to tap on G to switch back and forth between modes. Also adjusted link above so both should access the project.

Link to latest Poject update

Please let me know if this works - just tap on a planet to get it’s details.

@Bri_G Looks good. Didn’t have any trouble loading it. Looks like it’s been a lot of work so far. Especially the planet files.

@dave1707 - yeah took some doing, you helped a bit with rotation of touch on the galaxy selector. Tried calculation but in end used if then for each option. Will try to generate planet data directly by procedural generation next and that should make it slicker. But needs a lot of hex manipulation.

Then I was hoping to generate the space images rather than use images to slim down the project. Will be adding a video to the website next.

Thanks for testing and feedback, now a bit more confident in exporting projects.

@Bri_G Here’s an example of a smaller galaxySelector if you want to change yours or not. Put your selector in Dropbox if you want to try this.

viewer.mode=STANDARD

function setup()
    cx,cy=WIDTH/2,HEIGHT/2    
end

function draw()
    background()
    sprite(asset.documents.Dropbox.Planetarium3S,cx,cy)
end

function touched(touch)
    if touch.state==BEGAN then
        selectGalaxy(touch)
        print(pick)
    end    
end

function selectGalaxy(gs)
    local nbr={3,2,1,8,7,6,5,4}
    local ang=math.deg(math.atan2(gs.y-cy,gs.x-cx))+22.5
    if ang<0 then
        ang=ang+360
    end
    pick=nbr[ang//45+1]
end

I’m not sure what the “modes” are supposed to be—on iPhone tapping G just makes the selector move to the right side of the screen.

@Bri_G Heres a smaller selectGalaxy for the above code.

function selectGalaxy(gs)
    local nbr={7,6,5,4,3,2,1,8,7}
    local ang=math.deg(math.atan2(gs.y-cy,gs.x-cx))+22.5
    pick=nbr[ang//45+5]
end

@UberGoober Try tapping just below the G. I don’t think the check is quite right for inside the circle.

It doesn’t matter where I tap. In fact I think what’s happening is that the button isn’t sensing my tap at all, the selector is just moving out of the way to show whatever was behind it.

@UberGoober - the panel showing the planet info moves either left or right so that you can view all planet details. Just s crude way of doing it.

I think this could be down to screen dimensions and I need to ensure the check applies for all devices. Does the selector enable galaxy changes?

What screen dimensions do you have on your iPhone ?

@dave1707 - Thanks for the suggestions. i’ll try those out in my master and repost.

I tried for ages to get a geometry combination to give the correct angle and using a comparison table to get the galaxy number but it always produced errors. My math is very rusty. I’ll also check out the touch adjustment for different screen res.

I have mentioned before in the forum that it would be useful to have an in built library of aspect ratios so that you can check and adjust for screen size. Started one ages ago, I"LL see if I can find it.

Thanks again.

@Bri_G The only problem with the selectGalaxy functions I created above are they’re not very self explanatory. If I wait a week or so and look at them again, I wouldn’t know what I was doing or why.

@Bri_G it’s an iPhone 8, which I believe is one of the smallest dimensions that still supports the current OS, 1334 x 750.

What I’ve been doing recently is setting a “unit“ variable at the start of my files, and defining it as a fraction of width (such as WIDTH * 0.04), and then specifying all of my following dimensions as a multiple of “unit“.