Omnimaga
Calculator Community => TI Calculators => General Calculator Help => Topic started by: annoyingcalc on September 02, 2012, 05:59:12 pm
-
My nspire software wont load my program im trying it on the emulator in it and if I drag and drop the program on to the emulator it freezes and so does windows explorer. I try loading it from file>open it still crashes nspire software! HELP
-
*bump* Id like help! I cant test my programs untill this is fixed!
-
Are those programs written in Lua/BASIC? Because if they're Ndless files (or Lua for an outdated Student Software version), then that might be why. (The software doesn't run Ndless files and even Lua programs will have troubles running sometimes, such as Nyan Cat)
-
I am using lua for 3.1 with a 3.1 student software
-
im posting the .lua file to see if anyone else has this problem
-
Oh wow, do NOT ever do image stuff in a loop, that's what causing your issue ;-)
Here's how you want to do it :
(after the 2 lines of images strings)
dx=50
dy=50
function on.paint(gc)
gc:drawImage(background,0,0)
gc:drawImage(duck,dx,dy)
end
function on.arrowKey(arrow)
if arrow == "right" then
dx = dx + 5
elseif arrow == "left" then
dx = dx - 5
elseif arrow == "up" then
dy = dy - 5
elseif arrow == "down" then
dy = dy + 5
end
platform.window:invalidate()
end
I suggest that you read Inspired-Lua's (http://www.inspired-lua.org/2012/01/starting-in-lua/) tutorials and Steve Arnold's (http://www.compasstech.com.au/TNS_Authoring/Scripting/) :)
They really well explain the basic concept of events, the base thing you need to understand first :)
Also, to have a full reference of the Nspire-Lua API, don't forget Inspired-Lua's wiki (http://wiki.inspired-lua.org) (based on (and improving) the official doc)
BTW, Levak and I have created a presentation some weeks ago : "Improving your Nspire-Lua skills" you would be interested in : http://tiplanet.org/forum/archives_voir.php?id=6720 (clic on "Télécharger") - you might prefer the powerpoint version)
-
Wow! Thanks adriweb,but I want it to be an ai not the character im making duck hunt!
-
Then, instead of using the function on.arrowKey(arrow), create one where you calculate the move, e.g:
function AI()
--place your Artificial Intelligence code here
--if direction==1 then
--dx=dx-1
--dy=dy-1
--else
--dx=dx+1
--dy=dy+1
--end
--if dx==0 then
--direction=1
--end
--if dy==240 then
--direction=0
--end
end
BTW, I see that you use an image from the NES & since the resolution is smaller, it will look awkward, so I would suggest to draw the rest of the background, this code would do:
function on.resize(width, height)
ww = width
wh = height
end
function on.paint(gc)
-- Paint background (sky)
gc:setColorRGB(96, 176, 248)
gc:fillRect(0, 0, ww, wh)
-- Paint floor (dirt)
gc:setColorRGB(104, 104, 0)
gc:fillRect(0, 175, ww, wh-175)
gc:drawImage(background,0,0)
gc:drawImage(duck,dx,dy)
AI()
end
Maybe you'll want to place drawing the duck image inside the AI() function, because if you're going to move the image a lot, it will look like it warps. So, you'll need to add the parameter "gc"
function on.paint(gc)
...
AI(gc)
end
function AI(gc)
gc:drawImage(duck,dx,dy)
end
-
Well, yes thats what im planning on doing with the background well it was >2,500 kb and I edited it wrongly.
-
Yeah try not to use > 15k :/