Omnimaga
Calculator Community => Other Calc-Related Projects and Ideas => TI-Nspire => Topic started by: njaddison on November 11, 2011, 04:57:15 pm
-
Hey guys, I finally decided to be a man, and show my self worth. I'm creating a clone of Galaga for the nspire. But, my creation of the game is paused until i can make the spacefighter move with the arrow keys, and the animate the galaga. For example, how do I make an explosion animation if the spacefighter is hit by a enemy shot or a galaga? and, how do I keep the file size from becoming too large? please help. I will post my progress online when i get to my laptop at home.
-
did you already started making the real game, or is this just the beginning of the project?
If you have just started, i recommend to not think about the animation of the explosion yet, first get your basic game idea ready, and then start adding new features like the animation.
for the arrowkeys, use the code bellow, with fighter- as x-value and fighter[y] as y value of the spacefighter.
function on.arrowLeft()
if fighter[x]>(min x-value here, eg. 0) then
fighter[x] = fighter[x]-1
end
platform.window:invalidate()
end
function on.arrowRight()
if fighter[x]<(max x-value here, eg. 300)
fighter[x]=fighter[x]+1
end
platform.window:invalidate()
end
if you work with a platform.window:invalidate() called from a timer.start function, you don't have to put it there (if your period is small enough at least), otherwise you have to put it there to redraw the fighter on the new position.
and for the filesize, avoid using TI.images in the file, it makes it slower and larger. But if you'd like to use them to draw the spacefighter, you shouldn't hesitate, cause it's quite small.
i think you should first start programming everything you want, and clean it afterwards, otherwise you'll spend more time on thinking how to program something small instead of programming something good. once you know how it works, you can start cleaning it an certainly reduce the filesize
-
Erm... caps-lock much? ???
-
This is what I did for my blockbreaker : it handles a basic linear acceleration/deceleration (the "dx" part)
This allows the paddle (or whatever is moving) to have a smooth scrolling.
the paddleStuff function gets called when the ball(s) move(s) via a timer, from on.paint, basically)
...
function on.arrowKey(key)
if key == "right" and paddle.x < platform.window:width()-20-XLimit then
paddle.dx = 8
elseif key == "left" and paddle.x >= 25 then
paddle.dx = -8
end
end
...
function paddleStuff(gc)
if paddle.dx > 0 then
paddle.x = paddle.x + paddle.dx
paddle.dx = paddle.dx - 1 -- more if on-calc
elseif paddle.dx < 0 then
paddle.x = paddle.x + paddle.dx
paddle.dx = paddle.dx + 1 -- more if on-calc
end
end
-
thanks guys! i will be online for a while, so tell me if you have any good ideas for my project.
And guys, I have already started. I made the title screen, and assigned the enter key to start the game. Now, I am drawing sprites.
Guys, I have another question. I won't be doing this any time soon, but what do I use to raycast? Another user explained to me the basic concept of it, but I don't know what materials I need. I hope I don't have to buy anything (I don't like lying to my parents about stuff that costs money)
-
Hey, guys, I want to know something. I can't figure out how to draw things, so I found the smallest image of a spacefighter on google images that I could. I used ti-nspire scripting tools to convert it to a TI-Image. Nick, I tried using your script(The script you gave me is correct). But, when I defined the picture "spacefighter" as the TI-Image string, and then ran the script in nspire student software, the title screen shows, but after I press enter, the picture doesn't show. I didn't get an error message, so I obviously typed valid program syntaxes and arguments.
-
:D
good luck XD
-
You should cross-post your questions in the Lua help sub-forum. You migth get some help faster there.
-
Hey, guys, I want to know something. I can't figure out how to draw things, so I found the smallest image of a spacefighter on google images that I could. I used ti-nspire scripting tools to convert it to a TI-Image. Nick, I tried using your script(The script you gave me is correct). But, when I defined the picture "spacefighter" as the TI-Image string, and then ran the script in nspire student software, the title screen shows, but after I press enter, the picture doesn't show. I didn't get an error message, so I obviously typed valid program syntaxes and arguments.
your picture = image.new("....") has to be put at the very end of your program, for example, not in any functions.
your gc:drawImage(picture,x,y) has to be put in the on.paint(gc) function (or any other function where gc is passed)
Then, each time the screen gets refreshed, on.paint(gc) will draw your image.