What do you think of this idea?
Good
 0%  [ 0 ]
Great
 0%  [ 0 ]
I want this
 25%  [ 1 ]
Gimme gimme gimme!!!!!!
 75%  [ 3 ]
Total Votes : 4

Again here's the code, which probably belongs here as well as prizm programming, for now it's just source code; I'm trying to figure out how to write and convert it into luaZM or to the prizm SDK in C.

As promised here http://twolivesleft.com/Codea/Talk/discussion/comment/512#Comment_512

Is where you may find the original author, as well as the software it was made on (condition of source use). But really the place is quite nice for programming Lua.

http://pastebin.com/y9qhmyJx
Ok so I'm having some issues, and I'm setting up the global Variables right now, tell me how this looks
Code:
---PRiZM ENDURO---
---Main.Lua---
-- global screen size constants
HEIGHT=216
WIDTH=384
bottomY = HEIGHT *.21
trackWidth = WIDTH * .9 -- width of the track at the bottom
horizonY = trackWidth * .55 + bottomY
trackHeight = horizonY - bottomY
trackLength = 100  -- in meters

-- main objects
myCar = nil
cars = {}
day = nil
track = nil

-- various global variables
speed = 0                 -- for showing to the user
location = 0              -- my location
maxPosition = -1000       -- the location relative to me where the front-most car is
lastCollisionT = -1000    -- last time i collided, for the penalty
gameTime = 0              -- for reporting to the user

startTime = 0             -- the time at which the game started

days = 1                  -- which day we're on

carsToPassInit = 150          -- on day 1 we need this many

carsToPass = carsToPassInit   -- how many cars to advance to the next day

gameOver = false

gameStarted = false           -- whether the user has started the game

gamePaused = false

maxSpeed = 150

regularSpeed = 85
The_Coded wrote:
Ok so I'm having some issues, and I'm setting up the global Variables right now, tell me how this looks


Looks like code to me.

What issues are you having? From what I can see, all you're doing is (correctly) declaring global variables.
Note that for this:
Code:
bottomY = HEIGHT *.21
trackWidth = WIDTH * .9 -- width of the track at the bottom
horizonY = trackWidth * .55 + bottomY
You might want:

Code:
bottomY = math.floor(HEIGHT *.21)
trackWidth = math.floor(WIDTH * .9) -- width of the track at the bottom
horizonY = math.floor(trackWidth * .55 + bottomY)
Here's the update, with NEW CODE!


Code:

---PRiZM ENDURO---
---Main.Lua---
-- global screen size constants
HEIGHT=216
WIDTH=384
bottomY = math.floor(HEIGHT *.21)
trackWidth = math.floor(WIDTH * .9) -- width of the track at the bottom
horizonY = math.floor(trackWidth * .55 + bottomY)
trackHeight = horizonY - bottomY
trackLength = 100  -- in meters

-- main objects
myCar = nil
cars = {}
day = nil
track = nil

-- various global variables
speed = 0                 -- for showing to the user
location = 0              -- my location
maxPosition = -1000       -- the location relative to me where the front-most car is
lastCollisionT = -1000    -- last time i collided, for the penalty
gameTime = 0              -- for reporting to the user

startTime = 0             -- the time at which the game started

days = 1                  -- which day we're on

carsToPassInit = 150          -- on day 1 we need this many

carsToPass = carsToPassInit   -- how many cars to advance to the next day

gameOver = false

gameStarted = false           -- whether the user has started the game

gamePaused = false

maxSpeed = 150

regularSpeed = 85
function setup()
    track = Track()
    day = Day()
    myCar = Car(0,0,0)
    myCar.speed = 120
end
What I do to increase speed is make all the vars local. I don't know if you would want to do this or not Wink
flyingfisch wrote:
What I do to increase speed is make all the vars local. I don't know if you would want to do this or not Wink


This is technically okay if all code being used is within a single file; locally-defined variables can still be global to entire file, or "chunk", if they're conceived outside of all blocks and strctures like normals globals. I'm not sure how LuaZM supports Lua programs over multiple files, but with a single file declaring everything as 'local' is a very good idea.
All my code for the enduro clone is in 1 file, as it is written as one on the iPad Codea, also after this work will come an asteroids clone (after I finish the iPad port)
Oh, cool, can't wait for asteroids Smile
yup, I'm going to do Lua only for the prizm so hopefully as I learn, many programs/games will come from me in lua on the Prizm.
Same here. I found C was a little above my level but I have always been comfortable with Lua.
Lua=love beginners c=just don't care about anything Very Happy well I'm home the rest of the week, can't really open my mouth and the muscles hurt, so looks like unless I have work to do, I'm free to keep porting enduro
The_Coded wrote:
Lua=love beginners c=just don't care about anything Very Happy well I'm home the rest of the week, can't really open my mouth and the muscles hurt, so looks like unless I have work to do, I'm free to keep porting enduro
Great! Are you happy in continuing to work on porting a program of this size as your first Lua project, or might you perhaps want to try something slightly smaller first? I have no particular investment in either option, just want to make sure you don't overwhelm and frustrate yourself. Smile
Well it's 1000 lines, idk how it's going to turn out, but I'm trying! Also if not enduro I'd be trying asteroids or something of the like, I feel it's the on,y way for me to ever learn this, without goals I just piddle around and never accomplish anything
The_Coded wrote:
Well it's 1000 lines, idk how it's going to turn out, but I'm trying! Also if not enduro I'd be trying asteroids or something of the like, I feel it's the on,y way for me to ever learn this, without goals I just piddle around and never accomplish anything


That's how I am too... I understand you completely.

1000 lines...wow. I wrote a racing game once but it was only 400 lines.
The_Coded wrote:
Well it's 1000 lines, idk how it's going to turn out, but I'm trying! Also if not enduro I'd be trying asteroids or something of the like, I feel it's the on,y way for me to ever learn this, without goals I just piddle around and never accomplish anything
Perfectly respectable. Smile Speaking of Lua racing games, I think there was an Nspire Lua project called Indy 500 that someone posted about a while back; I should see if I can find the topic about that.
KermMartian wrote:
The_Coded wrote:
Well it's 1000 lines, idk how it's going to turn out, but I'm trying! Also if not enduro I'd be trying asteroids or something of the like, I feel it's the on,y way for me to ever learn this, without goals I just piddle around and never accomplish anything
Perfectly respectable. Smile Speaking of Lua racing games, I think there was an Nspire Lua project called Indy 500 that someone posted about a while back; I should see if I can find the topic about that.


That was my LuaFX game Wink

Link (can't seem to find the cemetech thread):
http://community.casiocalc.org/topic/6820-my-first-luafx-game-indy500/

EDIT:
Cmetech link:
http://www.cemetech.net/forum/viewtopic.php?t=7874&start=0
OK so here's what I've got down, and I'm curious...where do I begin using libs from luaZM?


Code:

---PRiZM ENDURO---
---Main.Lua---
-- global screen size constants
HEIGHT=216
WIDTH=384
bottomY = math.floor(HEIGHT *.21)
trackWidth = math.floor(WIDTH * .9) -- width of the track at the bottom
horizonY = math.floor(trackWidth * .55 + bottomY)
trackHeight = horizonY - bottomY
trackLength = 100  -- in meters

-- main objects
myCar = nil
cars = {}
day = nil
track = nil

-- various global variables
speed = 0                 -- for showing to the user
location = 0              -- my location
maxPosition = -1000       -- the location relative to me where the front-most car is
lastCollisionT = -1000    -- last time i collided, for the penalty
gameTime = 0              -- for reporting to the user

startTime = 0             -- the time at which the game started

days = 1                  -- which day we're on

carsToPassInit = 150          -- on day 1 we need this many

carsToPass = carsToPassInit   -- how many cars to advance to the next day

gameOver = false

gameStarted = false           -- whether the user has started the game

gamePaused = false

maxSpeed = 150

regularSpeed = 85
function setup()
    track = Track()
    day = Day()
    myCar = Car(0,0,0)
    myCar.speed = 120
end

print("Instructions:")
    print("Press Shift to accelerate")
    print("Press Alpha to break")
    print("Press nothing to maintain speed")
    print("Use Prizm D-pad to Steer")
    print("F1 to Start")

function draw()

rectMode(CORNER)
      ellipseMode(RADIUS)
      speed = myCar.speed





------------- UPDATE GAME STATE ----------------
    if not gameOver then
        if not gameStarted or gamePaused then
            stoppedUserInputs()
        else
            accelerating = runningUserInputs()     -- start, left, right, brake, etc

-- move track around
            turnTrack(gameTime,track)
               
            -- move the day forward in time
            day:updateMode(gameTime)
       
            if gameStarted then
                gameTime = ElapsedTime - startTime
                location = location + DeltaTime*myCar.speed/100
                spawnNewCars()
                myCar:updateTireState()
                day:updateFogEnd(myCar.speed)
            end
LuaZM implements the standard Lua libraries and an additional zmg lib for Prizm-specific native aphids and other generic functions. A list of ZMG lib functions and what libraries aren't functional yet: http://prizm.cemetech.net/index.php?title=LuaZM_Reference
Thanks ashbad, I've read over the references for LuaZM for 2 days now, but looking at the code I have so far, I can't see where as of yet I need the ZMG commands
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 3
» All times are UTC - 5 Hours
 
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 vote in polls in this forum

 

Advertisement