+-Discord Shoutbox


Alternatively, join us on Discord directly.
You can help CodeWalrus stay online by donating here.

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Messages - semiprocoder

271
I searched for a chess game on ti calc, and I couldn't find it, so I decided to make my own. I so far am nowhere near finishing. All that is done drawing the board and moving the pieces, but the code doesnt check for illegal moves and it allowes anything to move anywhere, including blank spaces onto pieces, for now. Also I plan to maybe eventually make an ai, but im not sure. Anyways, here is the chess game. I will probably make a few more simple games and then go on to making an empire earth like rts game.


EDIT: I updated the chess file so that it checks whether you make a valid move. It doens't detect checkmates yet, but it doesnt let you move if you are checked. Please report any bugs you find cause there were a lot during development and I might have missed some.

Also now if you press clear(ctr+del) it clears the board.

Second Edit: sorry for uploading the screenshot instead of the actual game, I was rushing to upload it.
272
Yeah sorry I only saved the new file on my calc and didnt notice, because that glitch only happens on the calc, so I thought that everything worked, when in reality, it only worked on my calculator. I'll update the game file.
273
Last weekend I started making a game for the ti nspire based off of learn to fly idle on kongregate. I finished it, except that I only have 3 enemies and my pics are not too good. It will be very easy to add new enemies, I just need good pictures for them. I hope you like this simple game I made.

The rules, the game, and some images are attached.
274
I made the graphics my own, though they look bad, but I had to make the images my own.

Also I guess I will post this to the code showcase directory.
275
I only do it in on.paint because I only run the method when I open the upgrade tab, so it only runs once, which makes it fine. If I would run it more that once I would certainly not put it in the on.paint method. I know I should move it for good coding style, but eh.

Anyways, thank you all for helping me!
276
The scripting api is what I was using to find functions, except it doesnt fully explain them sometimes. I didn't really look through it, just when I needed to find something I looked through the sections, mainly the painting one. Also I had already started the previous tutorial for lua, but I kind of skipped over it because I wanted to start coding quickly. I will review it more later, but right now I am happy to say that everything now magically works. I still dont know why it was lagging before, but now after I fixed the bugs it doesnt even need me to optimise to only redraw portions of the screen. I don't know why it was lagging before and stopped, but im happy it did.

Now all I have to do is add more enemies and textures for them.

Anyways, here is the new code:

Learn to Fly Idle:
--variables
local screen=platform.window
local screenWidth=screen:width()
local screenHeight=screen:height()

local mouseX=0.0
local mouseY=0.0
--cannon vars
local cannonResource=image.new(_R.IMG.cannon)
local cannonBallResource=image.new(_R.IMG.cannonBall)
local AS=0.0
local ASR=0.0
local damage=1.0
local damageR=1.0
local bulletSpeed=60.0--per quarter sec
local bulletSpeedR=60.0
local angle=0.0
local SPC=1.0
local SPCR=1.0
local clickResetTime=300.0
--upgrades

--damage upgrades
local uDamageCost=1.0
local uDamageCostR=1.0
local damageVelocity=1.0
local damageVelocityR=1.0
local damageVelocityMultiplier=1.25
local uDamageAdder=2.0
local uDamageMultiplier=1.5

--bullet upgrades
local uBulletSpeedCost=5.0
local uBulletSpeedCostR=5.0
local bulletSpeedVelocity=12.0
local bulletSpeedVelocityR=12.0
local bulletSpeedAcceleration=2.5
local uBulletSpeedAdder=2.0
local uBulletSpeedMultiplier=1.6

--shotsPerClickUpgrades
local uSPCC=10.0
local uSPCCR=10.0
local SPCV=0.1
local uSPCVR=0.1
local SPCVM=1.1
local uSPCM=1.5
local uSPCA=1.3
local clickShots=0.0

--automatic shooting
local uASC=6.0
local uASCR=6.0
local ASV=0.1
local ASVM=1.1
local uASM=1.5
local uASA=2.0
local autoShots=0.0
local prevAutoShotTime=0.0

local upgradeCostMultiplier=1.5
local upgradeCostAddition=2.5--mainly for begining to make expensive later
--misc
local cannonBalls={0}--first velocity vector, then coords
local airVecMultiplier=0.985--per 5 distance
local gravity=9.5--per sec

local cannonLength=300/32

local money=0.0
local prevDisplayTime=0.0
--'enemy' vars
local enemies={{"snowman", image.new(_R.IMG.snowman), 4.0, 300.0, 1.0, 225.0, 50.0, 75.0}, {"snowman", image.new(_R.IMG.snowman), 15.0, 450.0, 4.0, 375.0, 50.0, 75.0}, {"snowman", image.new(_R.IMG.snowman), 30.0, 700.0, 10.0, 600.0, 60.0, 90.0}}
--first goes display name[1], pic[2], then maxHealth[3], then distance[4], then worth[5], then width[7], then startX[6], then Height[8]
local enemyID=1
local maxEnemyIDAllowed=1
local amountEnemies=3
local enemyHealth=4.0

local mouseDown=false

local prevShootTime=0.0
--values for quicksine calculator
local sineIndex={0.001745, 0.003491, 0.005236, 0.006981, 0.008727, 0.010472, 0.012217, 0.013962, 0.015707, 0.017452, 0.019197, 0.020942, 0.022687, 0.024432, 0.026177, 0.027922, 0.029666, 0.031411, 0.033155, 0.034899, 0.036644, 0.038388, 0.040132, 0.041876, 0.043619, 0.045363, 0.047106, 0.048850, 0.050593, 0.052336, 0.054079, 0.055822, 0.057564, 0.059306, 0.061049, 0.062791, 0.064532, 0.066274, 0.068015, 0.069756, 0.071497, 0.073238, 0.074979, 0.076719, 0.078459, 0.080199, 0.081939, 0.083678, 0.085417, 0.087156, 0.088894, 0.090633, 0.092371, 0.094108, 0.095846, 0.097583, 0.099320, 0.101056, 0.102793, 0.104528, 0.106264, 0.107999, 0.109734, 0.111469, 0.113203, 0.114937, 0.116671, 0.118404, 0.120137, 0.121869, 0.123601, 0.125333, 0.127065, 0.128796, 0.130526, 0.132256, 0.133986, 0.135716, 0.137445, 0.139173, 0.140901, 0.142629, 0.144356, 0.146083, 0.147809, 0.149535, 0.151261, 0.152986, 0.154710, 0.156434, 0.158158, 0.159881, 0.161604, 0.163326, 0.165048, 0.166769, 0.168489, 0.170209, 0.171929, 0.173648, 0.175367, 0.177085, 0.178802, 0.180519, 0.182236, 0.183951, 0.185667, 0.187381, 0.189095, 0.190809, 0.192522, 0.194234, 0.195946, 0.197657, 0.199368, 0.201078, 0.202787, 0.204496, 0.206204, 0.207912, 0.209619, 0.211325, 0.213030, 0.214735, 0.216440, 0.218143, 0.219846, 0.221548, 0.223250, 0.224951, 0.226651, 0.228351, 0.230050, 0.231748, 0.233445, 0.235142, 0.236838, 0.238533, 0.240228, 0.241922, 0.243615, 0.245307, 0.246999, 0.248690, 0.250380, 0.252069, 0.253758, 0.255446, 0.257133, 0.258819, 0.260505, 0.262189, 0.263873, 0.265556, 0.267238, 0.268920, 0.270600, 0.272280, 0.273959, 0.275637, 0.277315, 0.278991, 0.280667, 0.282341, 0.284015, 0.285688, 0.287361, 0.289032, 0.290702, 0.292372, 0.294040, 0.295708, 0.297375, 0.299041, 0.300706, 0.302370, 0.304033, 0.305695, 0.307357, 0.309017, 0.310676, 0.312335, 0.313992, 0.315649, 0.317305, 0.318959, 0.320613, 0.322266, 0.323917, 0.325568, 0.327218, 0.328867, 0.330514, 0.332161, 0.333807, 0.335452, 0.337095, 0.338738, 0.340380, 0.342020, 0.343660, 0.345298, 0.346936, 0.348572, 0.350207, 0.351842, 0.353475, 0.355107, 0.356738, 0.358368, 0.359997, 0.361625, 0.363251, 0.364877, 0.366501, 0.368125, 0.369747, 0.371368, 0.372988, 0.374607, 0.376224, 0.377841, 0.379456, 0.381070, 0.382683, 0.384295, 0.385906, 0.387516, 0.389124, 0.390731, 0.392337, 0.393942, 0.395546, 0.397148, 0.398749, 0.400349, 0.401948, 0.403545, 0.405142, 0.406737, 0.408330, 0.409923, 0.411514, 0.413104, 0.414693, 0.416281, 0.417867, 0.419452, 0.421036, 0.422618, 0.424199, 0.425779, 0.427358, 0.428935, 0.430511, 0.432086, 0.433659, 0.435231, 0.436802, 0.438371, 0.439939, 0.441506, 0.443071, 0.444635, 0.446198, 0.447759, 0.449319, 0.450878, 0.452435, 0.453990, 0.455545, 0.457098, 0.458650, 0.460200, 0.461749, 0.463296, 0.464842, 0.466387, 0.467930, 0.469472, 0.471012, 0.472551, 0.474088, 0.475624, 0.477159, 0.478692, 0.480223, 0.481754, 0.483282, 0.484810, 0.486335, 0.487860, 0.489382, 0.490904, 0.492424, 0.493942, 0.495459, 0.496974, 0.498488, 0.500000, 0.501511, 0.503020, 0.504528, 0.506034, 0.507538, 0.509041, 0.510543, 0.512043, 0.513541, 0.515038, 0.516533, 0.518027, 0.519519, 0.521010, 0.522499, 0.523986, 0.525472, 0.526956, 0.528438, 0.529919, 0.531399, 0.532876, 0.534352, 0.535827, 0.537300, 0.538771, 0.540240, 0.541708, 0.543174, 0.544639, 0.546102, 0.547563, 0.549023, 0.550481, 0.551937, 0.553392, 0.554844, 0.556296, 0.557745, 0.559193, 0.560639, 0.562083, 0.563526, 0.564967, 0.566406, 0.567844, 0.569280, 0.570714, 0.572146, 0.573576, 0.575005, 0.576432, 0.577858, 0.579281, 0.580703, 0.582123, 0.583541, 0.584958, 0.586372, 0.587785, 0.589196, 0.590606, 0.592013, 0.593419, 0.594823, 0.596225, 0.597625, 0.599024, 0.600420, 0.601815, 0.603208, 0.604599, 0.605988, 0.607376, 0.608761, 0.610145, 0.611527, 0.612907, 0.614285, 0.615661, 0.617036, 0.618408, 0.619779, 0.621148, 0.622515, 0.623880, 0.625243, 0.626604, 0.627963, 0.629320, 0.630676, 0.632029, 0.633381, 0.634731, 0.636078, 0.637424, 0.638768, 0.640110, 0.641450, 0.642788, 0.644124, 0.645458, 0.646790, 0.648120, 0.649448, 0.650774, 0.652098, 0.653421, 0.654741, 0.656059, 0.657375, 0.658689, 0.660002, 0.661312, 0.662620, 0.663926, 0.665230, 0.666532, 0.667833, 0.669131, 0.670427, 0.671721, 0.673013, 0.674302, 0.675590, 0.676876, 0.678160, 0.679441, 0.680721, 0.681998, 0.683274, 0.684547, 0.685818, 0.687088, 0.688355, 0.689620, 0.690882, 0.692143, 0.693402, 0.694658, 0.695913, 0.697165, 0.698415, 0.699663, 0.700909, 0.702153, 0.703395, 0.704634, 0.705872, 0.707107, 0.708340, 0.709571, 0.710799, 0.712026, 0.713250, 0.714473, 0.715693, 0.716911, 0.718126, 0.719340, 0.720551, 0.721760, 0.722967, 0.724172, 0.725374, 0.726575, 0.727773, 0.728969, 0.730162, 0.731354, 0.732543, 0.733730, 0.734915, 0.736097, 0.737277, 0.738455, 0.739631, 0.740805, 0.741976, 0.743145, 0.744312, 0.745476, 0.746638, 0.747798, 0.748956, 0.750111, 0.751264, 0.752415, 0.753563, 0.754710, 0.755853, 0.756995, 0.758134, 0.759271, 0.760406, 0.761538, 0.762668, 0.763796, 0.764921, 0.766044, 0.767165, 0.768284, 0.769400, 0.770513, 0.771625, 0.772734, 0.773840, 0.774944, 0.776046, 0.777146, 0.778243, 0.779338, 0.780430, 0.781520, 0.782608, 0.783693, 0.784776, 0.785857, 0.786935, 0.788011, 0.789084, 0.790155, 0.791224, 0.792290, 0.793353, 0.794415, 0.795473, 0.796530, 0.797584, 0.798636, 0.799685, 0.800731, 0.801776, 0.802817, 0.803857, 0.804894, 0.805928, 0.806960, 0.807990, 0.809017, 0.810042, 0.811064, 0.812084, 0.813101, 0.814116, 0.815128, 0.816138, 0.817145, 0.818150, 0.819152, 0.820152, 0.821149, 0.822144, 0.823136, 0.824126, 0.825113, 0.826098, 0.827081, 0.828060, 0.829038, 0.830012, 0.830984, 0.831954, 0.832921, 0.833886, 0.834848, 0.835807, 0.836764, 0.837719, 0.838671, 0.839620, 0.840567, 0.841511, 0.842452, 0.843391, 0.844328, 0.845262, 0.846193, 0.847122, 0.848048, 0.848972, 0.849893, 0.850811, 0.851727, 0.852640, 0.853551, 0.854459, 0.855364, 0.856267, 0.857167, 0.858065, 0.858960, 0.859852, 0.860742, 0.861629, 0.862514, 0.863396, 0.864275, 0.865151, 0.866025, 0.866897, 0.867765, 0.868632, 0.869495, 0.870356, 0.871214, 0.872069, 0.872922, 0.873772, 0.874620, 0.875465, 0.876307, 0.877146, 0.877983, 0.878817, 0.879649, 0.880477, 0.881303, 0.882127, 0.882948, 0.883766, 0.884581, 0.885394, 0.886204, 0.887011, 0.887815, 0.888617, 0.889416, 0.890213, 0.891007, 0.891798, 0.892586, 0.893371, 0.894154, 0.894934, 0.895712, 0.896486, 0.897258, 0.898028, 0.898794, 0.899558, 0.900319, 0.901077, 0.901833, 0.902585, 0.903335, 0.904083, 0.904827, 0.905569, 0.906308, 0.907044, 0.907777, 0.908508, 0.909236, 0.909961, 0.910684, 0.911403, 0.912120, 0.912834, 0.913545, 0.914254, 0.914960, 0.915663, 0.916363, 0.917060, 0.917755, 0.918446, 0.919135, 0.919821, 0.920505, 0.921185, 0.921863, 0.922538, 0.923210, 0.923880, 0.924546, 0.925210, 0.925871, 0.926529, 0.927184, 0.927836, 0.928486, 0.929133, 0.929776, 0.930418, 0.931056, 0.931691, 0.932324, 0.932954, 0.933580, 0.934204, 0.934826, 0.935444, 0.936060, 0.936672, 0.937282, 0.937889, 0.938493, 0.939094, 0.939693, 0.940288, 0.940881, 0.941471, 0.942057, 0.942641, 0.943223, 0.943801, 0.944376, 0.944949, 0.945519, 0.946085, 0.946649, 0.947210, 0.947768, 0.948324, 0.948876, 0.949425, 0.949972, 0.950516, 0.951057, 0.951594, 0.952129, 0.952661, 0.953191, 0.953717, 0.954240, 0.954761, 0.955278, 0.955793, 0.956305, 0.956814, 0.957319, 0.957822, 0.958323, 0.958820, 0.959314, 0.959805, 0.960294, 0.960779, 0.961262, 0.961741, 0.962218, 0.962692, 0.963163, 0.963630, 0.964095, 0.964557, 0.965016, 0.965473, 0.965926, 0.966376, 0.966823, 0.967268, 0.967709, 0.968148, 0.968583, 0.969016, 0.969445, 0.969872, 0.970296, 0.970716, 0.971134, 0.971549, 0.971961, 0.972370, 0.972776, 0.973179, 0.973579, 0.973976, 0.974370, 0.974761, 0.975149, 0.975535, 0.975917, 0.976296, 0.976672, 0.977046, 0.977416, 0.977783, 0.978148, 0.978509, 0.978867, 0.979223, 0.979575, 0.979925, 0.980271, 0.980615, 0.980955, 0.981293, 0.981627, 0.981959, 0.982287, 0.982613, 0.982935, 0.983255, 0.983571, 0.983885, 0.984196, 0.984503, 0.984808, 0.985109, 0.985408, 0.985703, 0.985996, 0.986286, 0.986572, 0.986856, 0.987136, 0.987414, 0.987688, 0.987960, 0.988228, 0.988494, 0.988756, 0.989016, 0.989272, 0.989526, 0.989776, 0.990024, 0.990268, 0.990509, 0.990748, 0.990983, 0.991216, 0.991445, 0.991671, 0.991894, 0.992115, 0.992332, 0.992546, 0.992757, 0.992966, 0.993171, 0.993373, 0.993572, 0.993768, 0.993961, 0.994151, 0.994338, 0.994522, 0.994703, 0.994881, 0.995056, 0.995227, 0.995396, 0.995562, 0.995725, 0.995884, 0.996041, 0.996195, 0.996345, 0.996493, 0.996637, 0.996779, 0.996917, 0.997053, 0.997185, 0.997314, 0.997441, 0.997564, 0.997684, 0.997801, 0.997916, 0.998027, 0.998135, 0.998240, 0.998342, 0.998441, 0.998537, 0.998630, 0.998719, 0.998806, 0.998890, 0.998971, 0.999048, 0.999123, 0.999194, 0.999263, 0.999328, 0.999391, 0.999450, 0.999507, 0.999560, 0.999610, 0.999657, 0.999701, 0.999743, 0.999781, 0.999816, 0.999848, 0.999877, 0.999903, 0.999925, 0.999945, 0.999962, 0.999976, 0.999986, 0.999994, 0.999998, 1.000000}
local aSineIndex={0.028648, 0.057296, 0.085944, 0.114592, 0.143240, 0.171888, 0.200536, 0.229184, 0.257832, 0.286480, 0.315128, 0.343777, 0.372425, 0.401074, 0.429722, 0.458371, 0.487020, 0.515669, 0.544318, 0.572967, 0.601617, 0.630266, 0.658916, 0.687566, 0.716216, 0.744866, 0.773517, 0.802167, 0.830818, 0.859469, 0.888120, 0.916772, 0.945423, 0.974075, 1.002727, 1.031380, 1.060032, 1.088685, 1.117339, 1.145992, 1.174646, 1.203300, 1.231954, 1.260609, 1.289264, 1.317919, 1.346575, 1.375231, 1.403887, 1.432544, 1.461201, 1.489858, 1.518516, 1.547174, 1.575833, 1.604492, 1.633151, 1.661811, 1.690471, 1.719131, 1.747792, 1.776454, 1.805116, 1.833778, 1.862441, 1.891104, 1.919768, 1.948432, 1.977097, 2.005762, 2.034428, 2.063094, 2.091761, 2.120428, 2.149096, 2.177764, 2.206433, 2.235102, 2.263772, 2.292443, 2.321114, 2.349786, 2.378458, 2.407131, 2.435804, 2.464478, 2.493153, 2.521828, 2.550504, 2.579181, 2.607858, 2.636536, 2.665215, 2.693894, 2.722574, 2.751255, 2.779936, 2.808618, 2.837301, 2.865984, 2.894668, 2.923353, 2.952039, 2.980725, 3.009412, 3.038100, 3.066788, 3.095478, 3.124168, 3.152859, 3.181551, 3.210243, 3.238936, 3.267630, 3.296325, 3.325021, 3.353718, 3.382415, 3.411114, 3.439813, 3.468513, 3.497214, 3.525915, 3.554618, 3.583322, 3.612026, 3.640732, 3.669438, 3.698145, 3.726853, 3.755562, 3.784272, 3.812983, 3.841695, 3.870408, 3.899122, 3.927837, 3.956553, 3.985269, 4.013987, 4.042706, 4.071426, 4.100147, 4.128869, 4.157592, 4.186316, 4.215041, 4.243767, 4.272494, 4.301222, 4.329952, 4.358682, 4.387414, 4.416146, 4.444880, 4.473615, 4.502351, 4.531088, 4.559826, 4.588566, 4.617306, 4.646048, 4.674791, 4.703535, 4.732280, 4.761027, 4.789775, 4.818523, 4.847274, 4.876025, 4.904777, 4.933531, 4.962286, 4.991043, 5.019800, 5.048559, 5.077319, 5.106080, 5.134843, 5.163607, 5.192372, 5.221139, 5.249907, 5.278676, 5.307447, 5.336219, 5.364992, 5.393766, 5.422542, 5.451320, 5.480099, 5.508879, 5.537660, 5.566443, 5.595227, 5.624013, 5.652800, 5.681589, 5.710379, 5.739170, 5.767963, 5.796758, 5.825554, 5.854351, 5.883150, 5.911950, 5.940752, 5.969555, 5.998360, 6.027167, 6.055974, 6.084784, 6.113595, 6.142407, 6.171221, 6.200037, 6.228854, 6.257673, 6.286494, 6.315316, 6.344139, 6.372964, 6.401791, 6.430620, 6.459450, 6.488282, 6.517115, 6.545950, 6.574787, 6.603625, 6.632465, 6.661307, 6.690150, 6.718995, 6.747842, 6.776691, 6.805541, 6.834393, 6.863247, 6.892103, 6.920960, 6.949819, 6.978680, 7.007542, 7.036407, 7.065273, 7.094141, 7.123011, 7.151882, 7.180756, 7.209631, 7.238508, 7.267387, 7.296268, 7.325151, 7.354035, 7.382922, 7.411810, 7.440700, 7.469592, 7.498486, 7.527382, 7.556280, 7.585180, 7.614082, 7.642985, 7.671891, 7.700799, 7.729708, 7.758620, 7.787533, 7.816449, 7.845367, 7.874286, 7.903208, 7.932131, 7.961057, 7.989985, 8.018914, 8.047846, 8.076780, 8.105716, 8.134654, 8.163594, 8.192536, 8.221481, 8.250427, 8.279376, 8.308326, 8.337279, 8.366234, 8.395191, 8.424151, 8.453112, 8.482076, 8.511041, 8.540009, 8.568980, 8.597952, 8.626927, 8.655903, 8.684882, 8.713864, 8.742847, 8.771833, 8.800821, 8.829812, 8.858804, 8.887799, 8.916796, 8.945796, 8.974798, 9.003802, 9.032808, 9.061817, 9.090828, 9.119842, 9.148857, 9.177876, 9.206896, 9.235919, 9.264945, 9.293972, 9.323002, 9.352035, 9.381070, 9.410107, 9.439147, 9.468190, 9.497234, 9.526282, 9.555331, 9.584384, 9.613438, 9.642495, 9.671555, 9.700617, 9.729682, 9.758749, 9.787819, 9.816891, 9.845966, 9.875044, 9.904124, 9.933206, 9.962291, 9.991379, 10.020470, 10.049563, 10.078658, 10.107756, 10.136857, 10.165961, 10.195067, 10.224176, 10.253287, 10.282401, 10.311518, 10.340638, 10.369760, 10.398885, 10.428012, 10.457143, 10.486276, 10.515412, 10.544550, 10.573692, 10.602836, 10.631983, 10.661132, 10.690285, 10.719440, 10.748598, 10.777759, 10.806923, 10.836089, 10.865259, 10.894431, 10.923606, 10.952784, 10.981965, 11.011149, 11.040335, 11.069525, 11.098717, 11.127913, 11.157111, 11.186312, 11.215516, 11.244724, 11.273934, 11.303147, 11.332363, 11.361582, 11.390804, 11.420029, 11.449257, 11.478488, 11.507722, 11.536959, 11.566199, 11.595442, 11.624689, 11.653938, 11.683190, 11.712446, 11.741705, 11.770966, 11.800231, 11.829499, 11.858770, 11.888044, 11.917322, 11.946602, 11.975886, 12.005173, 12.034463, 12.063756, 12.093053, 12.122352, 12.151655, 12.180961, 12.210271, 12.239583, 12.268899, 12.298218, 12.327540, 12.356866, 12.386195, 12.415527, 12.444863, 12.474202, 12.503544, 12.532889, 12.562238, 12.591590, 12.620946, 12.650305, 12.679667, 12.709033, 12.738402, 12.767775, 12.797150, 12.826530, 12.855913, 12.885299, 12.914688, 12.944082, 12.973478, 13.002878, 13.032282, 13.061689, 13.091099, 13.120513, 13.149931, 13.179352, 13.208777, 13.238205, 13.267636, 13.297072, 13.326511, 13.355953, 13.385399, 13.414849, 13.444302, 13.473759, 13.503219, 13.532684, 13.562151, 13.591623, 13.621098, 13.650577, 13.680059, 13.709545, 13.739035, 13.768529, 13.798026, 13.827527, 13.857032, 13.886540, 13.916053, 13.945569, 13.975088, 14.004612, 14.034139, 14.063671, 14.093206, 14.122745, 14.152287, 14.181834, 14.211384, 14.240938, 14.270496, 14.300058, 14.329624, 14.359194, 14.388768, 14.418345, 14.447927, 14.477512, 14.507102, 14.536695, 14.566292, 14.595894, 14.625499, 14.655108, 14.684721, 14.714339, 14.743960, 14.773585, 14.803215, 14.832848, 14.862485, 14.892127, 14.921773, 14.951422, 14.981076, 15.010734, 15.040396, 15.070062, 15.099732, 15.129407, 15.159085, 15.188768, 15.218455, 15.248146, 15.277842, 15.307541, 15.337245, 15.366953, 15.396665, 15.426381, 15.456102, 15.485827, 15.515556, 15.545290, 15.575028, 15.604770, 15.634516, 15.664267, 15.694022, 15.723781, 15.753545, 15.783313, 15.813086, 15.842863, 15.872644, 15.902430, 15.932220, 15.962014, 15.991813, 16.021616, 16.051424, 16.081237, 16.111053, 16.140875, 16.170700, 16.200531, 16.230365, 16.260205, 16.290049, 16.319897, 16.349750, 16.379607, 16.409469, 16.439336, 16.469207, 16.499083, 16.528964, 16.558849, 16.588738, 16.618633, 16.648532, 16.678435, 16.708344, 16.738257, 16.768175, 16.798097, 16.828024, 16.857956, 16.887893, 16.917834, 16.947780, 16.977731, 17.007687, 17.037647, 17.067613, 17.097583, 17.127558, 17.157537, 17.187522, 17.217511, 17.247506, 17.277505, 17.307509, 17.337518, 17.367532, 17.397551, 17.427574, 17.457603, 17.487637, 17.517675, 17.547719, 17.577767, 17.607821, 17.637880, 17.667943, 17.698012, 17.728085, 17.758164, 17.788248, 17.818336, 17.848430, 17.878529, 17.908633, 17.938742, 17.968857, 17.998976, 18.029101, 18.059230, 18.089365, 18.119505, 18.149651, 18.179801, 18.209957, 18.240118, 18.270284, 18.300455, 18.330632, 18.360814, 18.391001, 18.421193, 18.451391, 18.481594, 18.511803, 18.542016, 18.572235, 18.602460, 18.632690, 18.662925, 18.693165, 18.723411, 18.753663, 18.783920, 18.814182, 18.844450, 18.874723, 18.905001, 18.935285, 18.965575, 18.995870, 19.026171, 19.056477, 19.086788, 19.117106, 19.147429, 19.177757, 19.208091, 19.238430, 19.268775, 19.299126, 19.329483, 19.359845, 19.390212, 19.420586, 19.450965, 19.481350, 19.511740, 19.542136, 19.572538, 19.602946, 19.633359, 19.663778, 19.694203, 19.724634, 19.755070, 19.785512, 19.815960, 19.846414, 19.876874, 19.907340, 19.937811, 19.968289, 19.998772, 20.029261, 20.059756, 20.090257, 20.120764, 20.151277, 20.181796, 20.212321, 20.242851, 20.273388, 20.303931, 20.334480, 20.365035, 20.395596, 20.426163, 20.456736, 20.487315, 20.517900, 20.548492, 20.579089, 20.609693, 20.640303, 20.670919, 20.701541, 20.732169, 20.762804, 20.793444, 20.824091, 20.854745, 20.885404, 20.916070, 20.946742, 20.977420, 21.008104, 21.038795, 21.069492, 21.100196, 21.130906, 21.161622, 21.192345, 21.223074, 21.253809, 21.284551, 21.315299, 21.346054, 21.376815, 21.407583, 21.438357, 21.469137, 21.499924, 21.530718, 21.561518, 21.592325, 21.623138, 21.653958, 21.684784, 21.715617, 21.746457, 21.777303, 21.808156, 21.839015, 21.869882, 21.900754, 21.931634, 21.962520, 21.993413, 22.024313, 22.055219, 22.086132, 22.117052, 22.147979, 22.178913, 22.209853, 22.240800, 22.271754, 22.302715, 22.333683, 22.364657, 22.395639, 22.426627, 22.457622, 22.488625, 22.519634, 22.550650, 22.581673, 22.612703, 22.643740, 22.674784, 22.705836, 22.736894, 22.767959, 22.799031, 22.830111, 22.861197, 22.892291, 22.923392, 22.954499, 22.985614, 23.016737, 23.047866, 23.079003, 23.110146, 23.141297, 23.172456, 23.203621, 23.234794, 23.265974, 23.297161, 23.328356, 23.359558, 23.390767, 23.421984, 23.453208, 23.484440, 23.515679, 23.546925, 23.578178, 23.609440, 23.640708, 23.671984, 23.703268, 23.734559, 23.765857, 23.797164, 23.828477, 23.859798, 23.891127, 23.922464, 23.953807, 23.985159, 24.016518, 24.047885, 24.079260, 24.110642, 24.142032, 24.173429, 24.204835, 24.236248, 24.267669, 24.299097, 24.330534, 24.361978, 24.393430, 24.424890, 24.456357, 24.487833, 24.519316, 24.550808, 24.582307, 24.613814, 24.645329, 24.676852, 24.708383, 24.739922, 24.771469, 24.803024, 24.834587, 24.866159, 24.897738, 24.929325, 24.960920, 24.992524, 25.024135, 25.055755, 25.087383, 25.119019, 25.150663, 25.182316, 25.213977, 25.245646, 25.277323, 25.309008, 25.340702, 25.372404, 25.404114, 25.435833, 25.467560, 25.499296, 25.531039, 25.562792, 25.594552, 25.626321, 25.658099, 25.689885, 25.721679, 25.753482, 25.785294, 25.817114, 25.848943, 25.880780, 25.912625, 25.944480, 25.976343, 26.008214, 26.040095, 26.071984, 26.103881, 26.135787, 26.167702, 26.199626, 26.231559, 26.263500, 26.295450, 26.327409, 26.359377, 26.391353, 26.423339, 26.455333, 26.487336, 26.519348, 26.551369, 26.583399, 26.615438, 26.647486, 26.679543, 26.711609, 26.743684, 26.775768, 26.807861, 26.839963, 26.872074, 26.904195, 26.936324, 26.968463, 27.000611, 27.032768, 27.064934, 27.097110, 27.129294, 27.161488, 27.193692, 27.225904, 27.258126, 27.290358, 27.322598, 27.354848, 27.387108, 27.419376, 27.451655, 27.483942, 27.516239, 27.548546, 27.580862, 27.613188, 27.645523, 27.677868, 27.710222, 27.742586, 27.774960, 27.807343, 27.839736, 27.872138, 27.904550, 27.936972, 27.969404, 28.001845, 28.034297, 28.066758, 28.099228, 28.131709, 28.164199, 28.196700, 28.229210, 28.261730, 28.294260, 28.326800, 28.359350, 28.391910, 28.424480, 28.457060, 28.489650, 28.522250, 28.554860, 28.587480, 28.620111, 28.652751, 28.685402, 28.718063, 28.750734, 28.783415, 28.816107, 28.848809, 28.881521, 28.914243, 28.946976, 28.979719, 29.012472, 29.045236, 29.078010, 29.110795, 29.143590, 29.176396, 29.209212, 29.242039, 29.274876, 29.307723, 29.340582, 29.373450, 29.406330, 29.439220, 29.472121, 29.505032, 29.537954, 29.570887, 29.603831, 29.636785, 29.669750, 29.702726, 29.735713, 29.768711, 29.801719, 29.834739, 29.867769, 29.900810, 29.933863, 29.966926, 30.000000, 30.033085, 30.066182, 30.099289, 30.132407, 30.165537, 30.198678, 30.231830, 30.264993, 30.298167, 30.331352, 30.364549, 30.397757, 30.430976, 30.464207, 30.497449, 30.530702, 30.563967, 30.597243, 30.630531, 30.663830, 30.697140, 30.730462, 30.763796, 30.797141, 30.830497, 30.863866, 30.897246, 30.930637, 30.964040, 30.997455, 31.030882, 31.064320, 31.097770, 31.131232, 31.164705, 31.198191, 31.231688, 31.265197, 31.298718, 31.332251, 31.365796, 31.399353, 31.432922, 31.466503, 31.500096, 31.533702, 31.567319, 31.600948, 31.634590, 31.668243, 31.701909, 31.735587, 31.769278, 31.802980, 31.836695, 31.870422, 31.904162, 31.937914, 31.971678, 32.005455, 32.039244, 32.073046, 32.106860, 32.140687, 32.174526, 32.208378, 32.242242, 32.276119, 32.310009, 32.343911, 32.377827, 32.411754, 32.445695, 32.479648, 32.513615, 32.547594, 32.581586, 32.615590, 32.649608, 32.683639, 32.717683, 32.751739, 32.785809, 32.819892, 32.853987, 32.888096, 32.922218, 32.956354, 32.990502, 33.024664, 33.058839, 33.093027, 33.127228, 33.161443, 33.195671, 33.229913, 33.264167, 33.298436, 33.332718, 33.367013, 33.401322, 33.435644, 33.469980, 33.504330, 33.538693, 33.573070, 33.607461, 33.641865, 33.676283, 33.710715, 33.745160, 33.779620, 33.814093, 33.848581, 33.883082, 33.917597, 33.952126, 33.986669, 34.021226, 34.055798, 34.090383, 34.124983, 34.159596, 34.194224, 34.228866, 34.263523, 34.298193, 34.332878, 34.367578, 34.402291, 34.437019, 34.471762, 34.506519, 34.541290, 34.576076, 34.610877, 34.645692, 34.680522, 34.715367, 34.750226, 34.785100, 34.819988, 34.854892, 34.889810, 34.924743, 34.959691, 34.994654, 35.029632, 35.064624, 35.099632, 35.134655, 35.169693, 35.204746, 35.239814, 35.274897, 35.309996, 35.345110, 35.380239, 35.415383, 35.450543, 35.485718, 35.520908, 35.556114, 35.591335, 35.626572, 35.661824, 35.697092, 35.732376, 35.767675, 35.802990, 35.838321, 35.873667, 35.909029, 35.944407, 35.979801, 36.015210, 36.050636, 36.086077, 36.121535, 36.157008, 36.192498, 36.228003, 36.263525, 36.299063, 36.334617, 36.370188, 36.405774, 36.441377, 36.476996, 36.512632, 36.548284, 36.583953, 36.619638, 36.655339, 36.691057, 36.726792, 36.762543, 36.798311, 36.834096, 36.869898, 36.905716, 36.941551, 36.977403, 37.013272, 37.049158, 37.085060, 37.120980, 37.156917, 37.192871, 37.228842, 37.264830, 37.300836, 37.336858, 37.372898, 37.408955, 37.445030, 37.481122, 37.517232, 37.553358, 37.589503, 37.625665, 37.661845, 37.698042, 37.734257, 37.770490, 37.806740, 37.843008, 37.879294, 37.915598, 37.951920, 37.988260, 38.024618, 38.060994, 38.097388, 38.133800, 38.170231, 38.206679, 38.243146, 38.279631, 38.316134, 38.352656, 38.389197, 38.425755, 38.462333, 38.498928, 38.535543, 38.572176, 38.608828, 38.645498, 38.682187, 38.718896, 38.755622, 38.792368, 38.829133, 38.865917, 38.902720, 38.939542, 38.976383, 39.013243, 39.050123, 39.087021, 39.123939, 39.160877, 39.197834, 39.234810, 39.271806, 39.308821, 39.345856, 39.382910, 39.419984, 39.457078, 39.494192, 39.531326, 39.568479, 39.605652, 39.642846, 39.680059, 39.717292, 39.754546, 39.791819, 39.829113, 39.866427, 39.903762, 39.941117, 39.978492, 40.015887, 40.053304, 40.090740, 40.128198, 40.165675, 40.203174, 40.240694, 40.278234, 40.315795, 40.353377, 40.390980, 40.428604, 40.466249, 40.503915, 40.541602, 40.579310, 40.617040, 40.654791, 40.692564, 40.730357, 40.768173, 40.806010, 40.843868, 40.881748, 40.919650, 40.957573, 40.995519, 41.033486, 41.071475, 41.109486, 41.147519, 41.185574, 41.223652, 41.261751, 41.299873, 41.338017, 41.376183, 41.414372, 41.452583, 41.490817, 41.529073, 41.567352, 41.605654, 41.643978, 41.682325, 41.720695, 41.759088, 41.797504, 41.835943, 41.874406, 41.912891, 41.951399, 41.989931, 42.028486, 42.067065, 42.105667, 42.144292, 42.182941, 42.221614, 42.260310, 42.299031, 42.337775, 42.376543, 42.415334, 42.454150, 42.492990, 42.531854, 42.570742, 42.609655, 42.648592, 42.687553, 42.726539, 42.765549, 42.804584, 42.843643, 42.882727, 42.921836, 42.960970, 43.000128, 43.039312, 43.078521, 43.117755, 43.157013, 43.196298, 43.235607, 43.274942, 43.314302, 43.353688, 43.393100, 43.432537, 43.471999, 43.511488, 43.551002, 43.590543, 43.630109, 43.669701, 43.709320, 43.748964, 43.788635, 43.828333, 43.868057, 43.907807, 43.947584, 43.987387, 44.027217, 44.067074, 44.106958, 44.146869, 44.186806, 44.226771, 44.266763, 44.306782, 44.346829, 44.386903, 44.427004, 44.467133, 44.507289, 44.547473, 44.587685, 44.627925, 44.668193, 44.708488, 44.748812, 44.789164, 44.829544, 44.869952, 44.910389, 44.950855, 44.991348, 45.031871, 45.072422, 45.113002, 45.153611, 45.194249, 45.234915, 45.275611, 45.316336, 45.357091, 45.397875, 45.438688, 45.479531, 45.520403, 45.561305, 45.602237, 45.643199, 45.684191, 45.725213, 45.766265, 45.807347, 45.848460, 45.889603, 45.930776, 45.971980, 46.013215, 46.054480, 46.095777, 46.137104, 46.178462, 46.219852, 46.261273, 46.302725, 46.344208, 46.385723, 46.427270, 46.468848, 46.510458, 46.552100, 46.593774, 46.635480, 46.677218, 46.718988, 46.760791, 46.802626, 46.844494, 46.886394, 46.928327, 46.970293, 47.012292, 47.054324, 47.096389, 47.138488, 47.180620, 47.222785, 47.264984, 47.307216, 47.349482, 47.391782, 47.434117, 47.476485, 47.518887, 47.561324, 47.603795, 47.646300, 47.688841, 47.731416, 47.774025, 47.816670, 47.859350, 47.902065, 47.944815, 47.987600, 48.030422, 48.073278, 48.116171, 48.159099, 48.202063, 48.245063, 48.288100, 48.331173, 48.374282, 48.417427, 48.460610, 48.503829, 48.547085, 48.590378, 48.633708, 48.677075, 48.720480, 48.763922, 48.807402, 48.850920, 48.894475, 48.938069, 48.981700, 49.025370, 49.069078, 49.112824, 49.156610, 49.200434, 49.244296, 49.288198, 49.332139, 49.376119, 49.420139, 49.464198, 49.508297, 49.552435, 49.596614, 49.640832, 49.685091, 49.729390, 49.773729, 49.818109, 49.862530, 49.906992, 49.951495, 49.996039, 50.040624, 50.085251, 50.129919, 50.174629, 50.219381, 50.264174, 50.309010, 50.353889, 50.398810, 50.443773, 50.488779, 50.533828, 50.578921, 50.624056, 50.669235, 50.714457, 50.759723, 50.805033, 50.850386, 50.895784, 50.941226, 50.986713, 51.032244, 51.077820, 51.123441, 51.169107, 51.214819, 51.260575, 51.306378, 51.352226, 51.398120, 51.444060, 51.490046, 51.536079, 51.582159, 51.628285, 51.674458, 51.720678, 51.766946, 51.813261, 51.859624, 51.906034, 51.952493, 51.998999, 52.045554, 52.092158, 52.138810, 52.185511, 52.232262, 52.279061, 52.325911, 52.372809, 52.419758, 52.466757, 52.513806, 52.560905, 52.608055, 52.655256, 52.702507, 52.749810, 52.797165, 52.844571, 52.892029, 52.939539, 52.987101, 53.034715, 53.082382, 53.130102, 53.177875, 53.225702, 53.273581, 53.321515, 53.369502, 53.417544, 53.465640, 53.513790, 53.561995, 53.610255, 53.658571, 53.706942, 53.755368, 53.803850, 53.852389, 53.900984, 53.949635, 53.998343, 54.047109, 54.095931, 54.144812, 54.193749, 54.242745, 54.291800, 54.340912, 54.390084, 54.439314, 54.488604, 54.537953, 54.587362, 54.636831, 54.686360, 54.735950, 54.785600, 54.835312, 54.885084, 54.934919, 54.984815, 55.034773, 55.084794, 55.134877, 55.185023, 55.235233, 55.285505, 55.335842, 55.386243, 55.436708, 55.487237, 55.537832, 55.588491, 55.639216, 55.690007, 55.740864, 55.791788, 55.842778, 55.893834, 55.944959, 55.996150, 56.047410, 56.098738, 56.150134, 56.201600, 56.253134, 56.304738, 56.356412, 56.408155, 56.459969, 56.511854, 56.563811, 56.615838, 56.667938, 56.720109, 56.772353, 56.824670, 56.877060, 56.929523, 56.982061, 57.034672, 57.087358, 57.140120, 57.192956, 57.245868, 57.298857, 57.351921, 57.405063, 57.458281, 57.511578, 57.564952, 57.618405, 57.671936, 57.725546, 57.779236, 57.833006, 57.886857, 57.940788, 57.994800, 58.048894, 58.103070, 58.157328, 58.211669, 58.266094, 58.320602, 58.375194, 58.429871, 58.484633, 58.539481, 58.594414, 58.649434, 58.704541, 58.759735, 58.815017, 58.870387, 58.925845, 58.981394, 59.037031, 59.092759, 59.148578, 59.204488, 59.260489, 59.316583, 59.372769, 59.429049, 59.485422, 59.541890, 59.598452, 59.655110, 59.711864, 59.768714, 59.825661, 59.882705, 59.939848, 59.997089, 60.054430, 60.111870, 60.169410, 60.227052, 60.284795, 60.342640, 60.400588, 60.458639, 60.516795, 60.575055, 60.633420, 60.691891, 60.750468, 60.809153, 60.867945, 60.926846, 60.985856, 61.044976, 61.104206, 61.163547, 61.223000, 61.282566, 61.342245, 61.402038, 61.461945, 61.521968, 61.582107, 61.642363, 61.702737, 61.763229, 61.823840, 61.884571, 61.945423, 62.006397, 62.067492, 62.128711, 62.190054, 62.251521, 62.313114, 62.374834, 62.436681, 62.498656, 62.560760, 62.622994, 62.685359, 62.747855, 62.810484, 62.873247, 62.936144, 62.999177, 63.062346, 63.125652, 63.189097, 63.252681, 63.316405, 63.380270, 63.444278, 63.508430, 63.572726, 63.637167, 63.701755, 63.766490, 63.831375, 63.896409, 63.961594, 64.026931, 64.092422, 64.158067, 64.223868, 64.289826, 64.355941, 64.422216, 64.488652, 64.555249, 64.622010, 64.688935, 64.756025, 64.823283, 64.890709, 64.958305, 65.026072, 65.094011, 65.162124, 65.230413, 65.298879, 65.367523, 65.436346, 65.505352, 65.574540, 65.643912, 65.713470, 65.783217, 65.853152, 65.923278, 65.993597, 66.064111, 66.134820, 66.205727, 66.276834, 66.348142, 66.419653, 66.491369, 66.563293, 66.635425, 66.707768, 66.780324, 66.853094, 66.926082, 66.999288, 67.072716, 67.146366, 67.220242, 67.294345, 67.368679, 67.443244, 67.518043, 67.593080, 67.668355, 67.743872, 67.819633, 67.895640, 67.971897, 68.048405, 68.125167, 68.202187, 68.279466, 68.357008, 68.434815, 68.512890, 68.591237, 68.669858, 68.748756, 68.827934, 68.907396, 68.987145, 69.067184, 69.147516, 69.228145, 69.309074, 69.390307, 69.471847, 69.553699, 69.635865, 69.718350, 69.801158, 69.884292, 69.967757, 70.051556, 70.135695, 70.220177, 70.305007, 70.390189, 70.475728, 70.561629, 70.647897, 70.734535, 70.821551, 70.908947, 70.996731, 71.084907, 71.173481, 71.262458, 71.351845, 71.441646, 71.531869, 71.622519, 71.713603, 71.805128, 71.897099, 71.989524, 72.082410, 72.175764, 72.269594, 72.363906, 72.458710, 72.554012, 72.649822, 72.746147, 72.842996, 72.940379, 73.038304, 73.136780, 73.235819, 73.335429, 73.435620, 73.536405, 73.637793, 73.739795, 73.842424, 73.945692, 74.049610, 74.154192, 74.259451, 74.365401, 74.472055, 74.579429, 74.687537, 74.796396, 74.906021, 75.016429, 75.127638, 75.239665, 75.352531, 75.466253, 75.580853, 75.696351, 75.812770, 75.930132, 76.048462, 76.167783, 76.288122, 76.409506, 76.531963, 76.655523, 76.780217, 76.906077, 77.033136, 77.161432, 77.291000, 77.421881, 77.554116, 77.687748, 77.822824, 77.959392, 78.097504, 78.237213, 78.378578, 78.521659, 78.666522, 78.813236, 78.961875, 79.112517, 79.265247, 79.420156, 79.577340, 79.736904, 79.898961, 80.063633, 80.231052, 80.401362, 80.574719, 80.751295, 80.931278, 81.114876, 81.302316, 81.493853, 81.689770, 81.890386, 82.096056, 82.307188, 82.524243, 82.747753, 82.978336, 83.216711, 83.463732, 83.720419, 83.988010, 84.268032, 84.562405, 84.873600, 85.204892, 85.560778, 85.947732, 86.375693, 86.861389, 87.437441, 88.188073, 90.0}

--image rotations
--first num is always going to be enemyID, because it is going to first be enemyID for scaling, then angle for rotation
local cannonRotations={}
local degAccuracy=3.0

--functions


function fastSin(degree)
    if degree<0 then
        return -fastSin(degree+180)
    elseif degree<=90 then
        degree=degree*10
        degree=math.floor(degree)
        return sineIndex[degree]
    elseif degree>90 and degree<=180 then
        return fastSin(180-degree)
    else
        return -fastSin(degree-180)
    end
end

function fastCos(degree)
    return fastSin(degree-90)
end

function fastTan(degree)
    return fastSin(degree)/fastCos(degree)
end

function fastASin(val)--returns in degrees
    val=val*2000
    val=math.floor(val)
    if val==0.0 then
        return 0.0
    end
    if val>0.0 and val<=2000.0 then
        return aSineIndex[val]
    elseif val<0.0 and val>=-2000.0 then
        return -aSineIndex[-val]
    end
end

function fastACos(val)--returns in degrees
    return (90-fastASin(val))
end

function fastATan(val)--returns in degrees
    newval=math.sqrt(1/(1+math.pow(val,2)))
    if val>0 then
        return fastACos(newval)
    else
        return -fastACos(newval)
    end
end


function on.construction()
    if var.recallAt("dataLFI", 1)~=nil then
        enemyID=var.recallAt("dataLFI", 1)
    end
    if var.recallAt("dataLFI", 2)~=nil then
        maxEnemyIDAllowed=var.recallAt("dataLFI", 2)
    end
    if var.recallAt("dataLFI", 3)~=nil then
        money=var.recallAt("dataLFI", 3)
    end
    if var.recallAt("dataLFI", 4)~=nil then
        damage=var.recallAt("dataLFI", 4)
    end
    if var.recallAt("dataLFI", 5)~=nil then
        damageVelocity=var.recallAt("dataLFI", 5)
    end
    if var.recallAt("dataLFI", 6)~=nil then
       uDamageCost=var.recallAt("dataLFI", 6)
    end
    if var.recallAt("dataLFI", 7)~=nil then
        bulletSpeed=var.recallAt("dataLFI", 7)
    end
    if var.recallAt("dataLFI", 8)~=nil then
        bulletSpeedVelocity=var.recallAt("dataLFI", 8)
    end
    if var.recallAt("dataLFI", 9)~=nil then
       uBulletSpeedCost=var.recallAt("dataLFI", 9)
    end
    if var.recallAt("dataLFI", 10)~=nil then
        SPC=var.recallAt("dataLFI", 10)
    end
    if var.recallAt("dataLFI", 11)~=nil then
        SPCV=var.recallAt("dataLFI", 11)
    end
    if var.recallAt("dataLFI", 12)~=nil then
        uSPCC=var.recallAt("dataLFI", 12)
    end
    if var.recallAt("dataLFI", 13)~=nil then
        AS=var.recallAt("dataLFI", 13)
    end
    if var.recallAt("dataLFI", 14)~=nil then
        ASV=var.recallAt("dataLFI", 14)
    end
    if var.recallAt("dataLFI", 15)~=nil then
        uASC=var.recallAt("dataLFI", 15)
    end
    for i=1, amountEnemies do--theoretically(sort of) goes from -90 to 270 degrees, so 360 degs
        cannonRotations[i]={}
        local tempRescale=cannonResource:copy(cannonResource:width()/distancePerPixell(enemies[i][4])+2, cannonResource:height()/distancePerPixell(enemies[i][4])+2)
        for j=1,360/degAccuracy do
            cannonRotations[i][j]=tempRescale
            cannonRotations[i][j]=cannonResource:rotate((j-360/degAccuracy/4-1)*3)
        end
    end
   
    timer.start(1/30)
end

function norm(x,y)
    return math.sqrt(math.pow(x,2)+math.pow(y,2))
end

function distancePerPixel()
    return enemies[enemyID][4]/screenWidth
end

function distancePerPixell(enemyDist)--doesnt work if last l removed
    return enemyDist/screenWidth
end

function on.timer()
    if timer.getMilliSecCounter()>prevAutoShotTime+1000.0 then
        autoShots=autoShots+AS
        autoShotsCopy=autoShots
        for i=1,autoShotsCopy do
            createCannonBall(i)
            autoShots=autoShots-1
        end
        prevAutoShotTime=timer.getMilliSecCounter()
    end
    numCB=cannonBalls[1]
    for i=2, numCB+1 do
        local temp=false
        if cannonBalls[i]~=nil then
            velX=cannonBalls[i][1]
            velY=cannonBalls[i][2]
            X=cannonBalls[i][3]
            Y=cannonBalls[i][4]
            prevX=cannonBalls[i][5]
            prevY=cannonBalls[i][6]
            X=X+velX/7.5
            Y=Y+velY/7.5
            velY=velY-gravity/7.5
            while norm(X-prevX,Y-prevY)>=5 and X-prevX>=0 and Y-prevY>=0 do
                velX=velX*airVecMultiplier
                velY=velY*airVecMultiplier
                mag=norm(X-prevX, Y-prevY)
                mag=mag-5
                tempPrevX=prevX
                tempPrevY=prevY
                tempPrevX=X-math.sqrt(math.pow(mag,2)*math.pow(X-prevX,2)/(math.pow(X-prevX,2)+math.pow(Y-prevY,2)))
                tempPrevY=Y-math.sqrt(math.pow(mag,2)*math.pow(Y-prevY,2)/(math.pow(X-prevX,2)+math.pow(Y-prevY,2)))
                prevX=tempPrevX
                prevY=tempPrevY
            end
            if Y<0 or X/distancePerPixel()>screenWidth then
                cannonBalls[i]=nil
                for j=i, numCB do
                    cannonBalls[j]={}
                    for f=1,6 do
                        cannonBalls[j][f]=cannonBalls[j+1][f]
                    end
                end
                cannonBalls[1]=cannonBalls[1]-1
                cannonBalls[numCB+2]=nil
                numCB=numCB-1
                i=i-1
                temp=true
            else
                cannonBalls[i][1]=velX
                cannonBalls[i][2]=velY
                cannonBalls[i][3]=X
                cannonBalls[i][4]=Y
                cannonBalls[i][5]=prevX
                cannonBalls[i][6]=prevY
                if X>=enemies[enemyID][6] and X<=enemies[enemyID][6]+enemies[enemyID][7] then
                    if Y<=enemies[enemyID][8] then
                        enemyHealth=enemyHealth-damage
                        if enemyHealth<=0 then
                            enemyHealth=enemies[enemyID][3]
                            money=money+enemies[enemyID][5]
                            if maxEnemyIDAllowed==enemyID then
                                maxEnemyIDAllowed=enemyID+1
                            end
                        end
                        cannonBalls[i]=nil
                        for j=i, numCB do
                            cannonBalls[j]={}
                            for f=1,6 do
                                cannonBalls[j][f]=cannonBalls[j+1][f]
                            end
                        end
                        cannonBalls[1]=cannonBalls[1]-1
                        cannonBalls[numCB+2]=nil
                        numCB=numCB-1
                        i=i-1
                        temp=true
                    end
                end
            end
        else
            if temp==false then
                for j=i, numCB do
                    cannonBalls[j]={}
                    for f=1,6 do
                        cannonBalls[j][f]=cannonBalls[j+1][f]
                    end
                end
                cannonBalls[1]=cannonBalls[1]-1
                numCB=cannonBalls[1]
                cannonBalls[numCB+2]=nil
                i=i-1
            end
        end
    end
    screen:invalidate()

end

function on.arrowLeft()
    if enemyID>1 then
        enemyID=enemyID-1
        enemyHealth=enemies[enemyID][3]
    end
end

function on.arrowRight()
    if maxEnemyIDAllowed>enemyID and enemies[enemyID+1]~=nil then
        enemyID=enemyID+1
        enemyHealth=enemies[enemyID][3]
    end
end

function createCannonBall(i)
    cannonBalls[cannonBalls[1]+2]={(mouseX-10)/norm(mouseX-10,screenHeight-mouseY+10)*bulletSpeed,(screenHeight-mouseY+10)/norm(mouseX-10,screenHeight-mouseY+10)*bulletSpeed, 10*distancePerPixel()+(32+(i-1)*8*distancePerPixel())*mouseX/norm(mouseX,screenHeight-mouseY),20*distancePerPixel()+(32+(i-1)*8*distancePerPixel())*(screenHeight-mouseY)/norm(mouseX,screenHeight-mouseY), (10)*distancePerPixel()+(32+(i-1)*8*distancePerPixel())*mouseX/norm(mouseX,screenHeight-mouseY), (20)*distancePerPixel()+(32+(i-1)*8*distancePerPixel())*(mouseY-screenHeight)/norm(mouseX,screenHeight-mouseY)}
    cannonBalls[1]=cannonBalls[1]+1
end

function on.mouseDown(x,y)
    mouseDown=true
    if timer.getMilliSecCounter()>prevShootTime+400 and mouseDown==true then
        clickShots=clickShots+SPC
        clickShotsCopy=clickShots
        for i=1, clickShotsCopy do
            createCannonBall(i)
            clickShots=clickShots-1
        end
        prevShootTime=timer.getMilliSecCounter()
    end
end

function on.mouseUp(x,y)
    mouseDown=false--doesnt always update, so I dont use it
end

function on.mouseMove(x,y)
    mouseX=x
    mouseY=y
    angle=fastATan((screenHeight-y-10)/(x-10))
    if angle<0 and screenHeight-y-10>0 then
        angle=angle+180
    end
    if x-10<0 and screenHeight-y-10<0 then
        angle=angle+180
    end
    screen:invalidate()
end

function on.charIn(ch)
    if ch=="1" and uDamageCost<=money then
       damage=damage+damageVelocity
       damageVelocity=damageVelocity*damageVelocityMultiplier
       damage=math.floor(damage)
       money=money-uDamageCost
       uDamageCost=uDamageCost*uDamageMultiplier
       uDamageCost=uDamageCost+uDamageAdder
       uDamageCost=math.floor(uDamageCost)
   elseif ch=="2" and uBulletSpeedCost<=money then
        bulletSpeed=bulletSpeed+bulletSpeedVelocity
        bulletSpeedVelocity=bulletSpeedVelocity*damageVelocityMultiplier
        bulletSpeed=math.floor(bulletSpeed)
        money=money-uBulletSpeedCost
        uBulletSpeedCost=uBulletSpeedCost*uBulletSpeedMultiplier
        uBulletSpeedCost=uBulletSpeedCost+uBulletSpeedAdder
        uBulletSpeedCost=math.floor(uBulletSpeedCost)
   elseif ch=="3" and uSPCC<=money then
        SPC=SPC+SPCV
        SPCV=SPCV*SPCVM
        --SPC=math.floor(SPCV)
        money=money-uSPCC
        uSPCC=uSPCC*uSPCM
        uSPCC=uSPCC+uSPCA
        uSPCC=math.floor(uSPCC)
    elseif ch=="4" and uASC<=money then
        AS=AS+ASV
        ASV=ASV*ASVM
        --AS=math.floor(ASV)
        money=money-uASC
        uASC=uASC*uASM
        uASC=uASC+uASA
        uASC=math.floor(uASC)
   end
   money=math.floor(money)
end

function on.clearKey()
    resetSave()
end

function resetSave()
    uSPCC=uSPCCR
    money=0.0
    SPC=SPCR
    SPCV=SPCVR
    uSPCC=uSPCCR
    AS=ASR
    ASV=ASVR
    uASC=uASCR
    damage=damageR
    damageVelocity=damageVelocityR
    uDamageCost=uDamageCostR
    bulletSpeed=bulletSpeedR
    bulletSpeedVelocity=bulletSpeedVelocityR
    uBulletSpeedCost=uBulletSpeedCostR
    enemyID=1
    maxEnemyIDAllowed=1
    enemyHealth=enemies[enemyID][3]
    var.store("uSPCCLFI", nil)
    var.store("moneyLFI", nil)
    var.store("SPCLFI", nil)
    var.store("SPCVLFI", nil)
    var.store("uSPCCLFI", nil)
    var.store("ASLFI", nil)
    var.store("ASVLFI", nil)
    var.store("uASCLFI", nil)
    var.store("damageLFI", nil)
    var.store("damageVelocityLFI", nil)
    var.store("uDamageCostLFI", nil)
    var.store("bulletSpeedLFI", nil)
    var.store("bulletSpeedVelocityLFI", nil)
    var.store("uBulletSpeedCostLFI", nil)
    var.store("enemyIDLFI", nil)
    var.store("maxEnemyIDAllowedLFI", nil)
    var.store("dataLFI", {enemyID, maxEnemyIDAllowed, money, damage, damageVelocity, uDamageCost, bulletSpeed, bulletSpeedVelocity, uBulletSpeedCost, SPC, SPCV, uSPCC, AS, ASV, uASC})
end

function on.deactivate()
    var.store("dataLFI", {enemyID, maxEnemyIDAllowed, money, damage, damageVelocity, uDamageCost, bulletSpeed, bulletSpeedVelocity, uBulletSpeedCost, SPC, SPCV, uSPCC, AS, ASV, uASC})
end

function on.destroy()
    var.store("dataLFI", {enemyID, maxEnemyIDAllowed, money, damage, damageVelocity, uDamageCost, bulletSpeed, bulletSpeedVelocity, uBulletSpeedCost, SPC, SPCV, uSPCC, AS, ASV, uASC})
end

function on.paint(gc)
    rotatedCannon=cannonRotations[enemyID][math.floor(angle/3)+31]
    gc:drawImage(rotatedCannon, 10+1*math.cos(angle/180*math.pi), screen:height()-10-(1*math.sin(angle/180*math.pi))-rotatedCannon:height())
    gc:drawLine(0, 50, screen:width(), 50) 
    --text allignment is reversed comp to calc
    --cannonball displaying
    numCB=cannonBalls[1]
    for i=2,numCB+1 do
        if cannonBalls[i]~=nil then
            if cannonBalls[i][3]/distancePerPixel()<screenWidth then
                gc:fillArc(cannonBalls[i][3]/distancePerPixel(), screenHeight-cannonBalls[i][4]/distancePerPixel(), 12/distancePerPixel(), 12/distancePerPixel(), 0, 360)
            end
        end
    end
    --displaying the enemy
    enemyImage=enemies[enemyID][2]:copy(enemies[enemyID][7]/distancePerPixel(), enemies[enemyID][8]/distancePerPixel())
    gc:drawImage(enemyImage, enemies[enemyID][6]/distancePerPixel(), screenHeight-enemies[enemyID][8]/distancePerPixel())
   
    --stats
    gc:drawString("health: "..enemyHealth, screenWidth-gc:getStringWidth("health: "..enemyHealth), 0, "top")
    gc:drawString("dist: "..enemies[enemyID][6], screenWidth-gc:getStringWidth("dist: "..enemies[enemyID][6]), gc:getStringHeight("health: "..enemyHealth), "top")
    gc:drawString("$"..money.." X: "..mouseX.." Y: "..mouseY.." SPC: "..math.floor(SPC*10)/10, 0, 0, "top")

end




Upgradetab:

screen=platform.window
screenWidth=screen:width()
screenHeight=screen:height()

function on.activate()
    screen:invalidate()
end

function on.paint(gc)
    SH=gc:getStringHeight("d")
    if var.recallAt("dataLFI",4)~=nil and var.recallAt("dataLFI",6)~=nil then
        gc:drawString("D: "..var.recallAt("dataLFI",4).." uDC: "..var.recallAt("dataLFI",6), 0, 0, "top")
    end
    if var.recallAt("dataLFI",7)~=nil and var.recallAt("dataLFI",9)~=nil then
        gc:drawString("BS: "..var.recallAt("dataLFI",7).." uBSC: "..var.recallAt("dataLFI",9), 0, SH, "top")
    end
    if var.recallAt("dataLFI",10)~=nil and var.recallAt("dataLFI",12)~=nil then
        gc:drawString("SPC: "..var.recallAt("dataLFI",10).." uSPCC: "..var.recallAt("dataLFI",12), 0, SH*2, "top")
    end
    if var.recallAt("dataLFI",13)~=nil and var.recall("dataLFI",15)~=nil then
        gc:drawString("AS: "..var.recallAt("dataLFI",13).." uASC: "..var.recallAt("dataLFI",15), 0, SH*3, "top")
    end
    gc:drawString("screenHeight= "..screenHeight, 0, SH*4, "top")
end
277
I updated the program so that the rotations and rescales are preloaded. I am not sure, but I think that for some reason the program got(maybe) slight even slower, but maybe thats just me. Definately no noticeable improvements though.

I added these variables:

local cannonRotations={}
local cannonBallRescales={}
local degAccuracy=3.0


I added this to on.construction:

if timer.getMilliSecCounter()>prevShootTime+400 and mouseDown==true then
        clickShots=clickShots+SPC
        clickShotsCopy=clickShots
        for i=1, clickShotsCopy do
            createCannonBall(i)
            clickShots=clickShots-1
        end
        prevShootTime=timer.getMilliSecCounter()
    end



I changed on.paint:

--rotatedCannon=cannonResource:copy(cannonResource:width()/distancePerPixel()+2, cannonResource:height()/distancePerPixel()+2)
    --rotatedCannon=rotatedCannon:rotate(angle) changed to this:
    rotatedCannon=cannonRotations[enemyID][math.floor(angle/3)+31]
    cannonBallResourceCopy=cannonBallRescales[enemyID]--used to be cannonBallResource:copy(cannonBallResource:width()/distancePerPixel()/2,cannonBallResource:height()/distancePerPixel()/2)
278
Oh yeah, also I was wondering whether it is possible to use the gc object outside of the paint function so as to not rewrite the whole screen but to specifically only make the nessesary pixels white so as to erase the previous fram without erasing the screen.
279
Ok. I put the code into a few txt files and packed it. It is not commented yet. Im sory about that but I wil try and comment it later. I have not made enough changes yet to optimize the code. It has two tabs, the main one and a tab that shows the stats, like damage and costs to upgrade damage. In case I need confirmation to be able to upload files, here is the code.

By the way DJ Omninaga how would you do that. I have a new calc that has os 4, so I don't notice it. Are there any functions I am using that rely on 3.9?
Edit: I put code tags(I hope) around the code

File 1: learn to fly idle

--variables
local screen=platform.window
local screenWidth=screen:width()
local screenHeight=screen:height()

local mouseX=0.0
local mouseY=0.0
--cannon vars
local cannonResource=image.new(_R.IMG.cannon)
local cannonBallResource=image.new(_R.IMG.cannonBall)
local AS=0.0
local ASR=0.0
local damage=1.0
local damageR=1.0
local bulletSpeed=60.0--per quarter sec
local bulletSpeedR=60.0
local angle=0.0
local SPC=1.0
local SPCR=1.0
local clickResetTime=300.0
--upgrades

--damage upgrades
local uDamageCost=1.0
local uDamageCostR=1.0
local damageVelocity=1.0
local damageVelocityR=1.0
local damageVelocityMultiplier=1.25
local uDamageAdder=2.0
local uDamageMultiplier=1.5

--bullet upgrades
local uBulletSpeedCost=5.0
local uBulletSpeedCostR=5.0
local bulletSpeedVelocity=12.0
local bulletSpeedVelocityR=12.0
local bulletSpeedAcceleration=2.5
local uBulletSpeedAdder=2.0
local uBulletSpeedMultiplier=1.6

--shotsPerClickUpgrades
local uSPCC=10.0
local uSPCCR=10.0
local SPCV=0.1
local uSPCVR=0.1
local SPCVM=1.1
local uSPCM=1.5
local uSPCA=1.3
local clickShots=0.0

--automatic shooting
local uASC=6.0
local uASCR=6.0
local ASV=0.1
local ASVM=1.1
local uASM=1.5
local uASA=2.0
local autoShots=0.0
local prevAutoShotTime=0.0

local upgradeCostMultiplier=1.5
local upgradeCostAddition=2.5--mainly for begining to make expensive later
--misc
local cannonBalls={0}--first velocity vector, then coords
local airVecMultiplier=0.985--per 5 distance
local gravity=9.5--per sec

local cannonLength=300/32

local money=0.0
local prevDisplayTime=0.0
--'enemy' vars
local enemies={{"snowman", image.new(_R.IMG.snowman), 4.0, 300.0, 1.0, 225.0, 50.0, 75.0}, {"snowman", image.new(_R.IMG.snowman), 15.0, 450.0, 4.0, 375.0, 50.0, 75.0}, {"snowman", image.new(_R.IMG.snowman), 30.0, 700.0, 10.0, 600.0, 60.0, 90.0}}
--first goes display name[1], pic[2], then maxHealth[3], then distance[4], then worth[5], then width[7], then startX[6], then Height[8]
local enemyID=1
local maxEnemyIDAllowed=1
local amountEnemies=3
local enemyHealth=4.0

local mouseDown=false

local prevShootTime=0.0
--values for quicksine calculator
local sineIndex={0.001745, 0.003491, 0.005236, 0.006981, 0.008727, 0.010472, 0.012217, 0.013962, 0.015707, 0.017452, 0.019197, 0.020942, 0.022687, 0.024432, 0.026177, 0.027922, 0.029666, 0.031411, 0.033155, 0.034899, 0.036644, 0.038388, 0.040132, 0.041876, 0.043619, 0.045363, 0.047106, 0.048850, 0.050593, 0.052336, 0.054079, 0.055822, 0.057564, 0.059306, 0.061049, 0.062791, 0.064532, 0.066274, 0.068015, 0.069756, 0.071497, 0.073238, 0.074979, 0.076719, 0.078459, 0.080199, 0.081939, 0.083678, 0.085417, 0.087156, 0.088894, 0.090633, 0.092371, 0.094108, 0.095846, 0.097583, 0.099320, 0.101056, 0.102793, 0.104528, 0.106264, 0.107999, 0.109734, 0.111469, 0.113203, 0.114937, 0.116671, 0.118404, 0.120137, 0.121869, 0.123601, 0.125333, 0.127065, 0.128796, 0.130526, 0.132256, 0.133986, 0.135716, 0.137445, 0.139173, 0.140901, 0.142629, 0.144356, 0.146083, 0.147809, 0.149535, 0.151261, 0.152986, 0.154710, 0.156434, 0.158158, 0.159881, 0.161604, 0.163326, 0.165048, 0.166769, 0.168489, 0.170209, 0.171929, 0.173648, 0.175367, 0.177085, 0.178802, 0.180519, 0.182236, 0.183951, 0.185667, 0.187381, 0.189095, 0.190809, 0.192522, 0.194234, 0.195946, 0.197657, 0.199368, 0.201078, 0.202787, 0.204496, 0.206204, 0.207912, 0.209619, 0.211325, 0.213030, 0.214735, 0.216440, 0.218143, 0.219846, 0.221548, 0.223250, 0.224951, 0.226651, 0.228351, 0.230050, 0.231748, 0.233445, 0.235142, 0.236838, 0.238533, 0.240228, 0.241922, 0.243615, 0.245307, 0.246999, 0.248690, 0.250380, 0.252069, 0.253758, 0.255446, 0.257133, 0.258819, 0.260505, 0.262189, 0.263873, 0.265556, 0.267238, 0.268920, 0.270600, 0.272280, 0.273959, 0.275637, 0.277315, 0.278991, 0.280667, 0.282341, 0.284015, 0.285688, 0.287361, 0.289032, 0.290702, 0.292372, 0.294040, 0.295708, 0.297375, 0.299041, 0.300706, 0.302370, 0.304033, 0.305695, 0.307357, 0.309017, 0.310676, 0.312335, 0.313992, 0.315649, 0.317305, 0.318959, 0.320613, 0.322266, 0.323917, 0.325568, 0.327218, 0.328867, 0.330514, 0.332161, 0.333807, 0.335452, 0.337095, 0.338738, 0.340380, 0.342020, 0.343660, 0.345298, 0.346936, 0.348572, 0.350207, 0.351842, 0.353475, 0.355107, 0.356738, 0.358368, 0.359997, 0.361625, 0.363251, 0.364877, 0.366501, 0.368125, 0.369747, 0.371368, 0.372988, 0.374607, 0.376224, 0.377841, 0.379456, 0.381070, 0.382683, 0.384295, 0.385906, 0.387516, 0.389124, 0.390731, 0.392337, 0.393942, 0.395546, 0.397148, 0.398749, 0.400349, 0.401948, 0.403545, 0.405142, 0.406737, 0.408330, 0.409923, 0.411514, 0.413104, 0.414693, 0.416281, 0.417867, 0.419452, 0.421036, 0.422618, 0.424199, 0.425779, 0.427358, 0.428935, 0.430511, 0.432086, 0.433659, 0.435231, 0.436802, 0.438371, 0.439939, 0.441506, 0.443071, 0.444635, 0.446198, 0.447759, 0.449319, 0.450878, 0.452435, 0.453990, 0.455545, 0.457098, 0.458650, 0.460200, 0.461749, 0.463296, 0.464842, 0.466387, 0.467930, 0.469472, 0.471012, 0.472551, 0.474088, 0.475624, 0.477159, 0.478692, 0.480223, 0.481754, 0.483282, 0.484810, 0.486335, 0.487860, 0.489382, 0.490904, 0.492424, 0.493942, 0.495459, 0.496974, 0.498488, 0.500000, 0.501511, 0.503020, 0.504528, 0.506034, 0.507538, 0.509041, 0.510543, 0.512043, 0.513541, 0.515038, 0.516533, 0.518027, 0.519519, 0.521010, 0.522499, 0.523986, 0.525472, 0.526956, 0.528438, 0.529919, 0.531399, 0.532876, 0.534352, 0.535827, 0.537300, 0.538771, 0.540240, 0.541708, 0.543174, 0.544639, 0.546102, 0.547563, 0.549023, 0.550481, 0.551937, 0.553392, 0.554844, 0.556296, 0.557745, 0.559193, 0.560639, 0.562083, 0.563526, 0.564967, 0.566406, 0.567844, 0.569280, 0.570714, 0.572146, 0.573576, 0.575005, 0.576432, 0.577858, 0.579281, 0.580703, 0.582123, 0.583541, 0.584958, 0.586372, 0.587785, 0.589196, 0.590606, 0.592013, 0.593419, 0.594823, 0.596225, 0.597625, 0.599024, 0.600420, 0.601815, 0.603208, 0.604599, 0.605988, 0.607376, 0.608761, 0.610145, 0.611527, 0.612907, 0.614285, 0.615661, 0.617036, 0.618408, 0.619779, 0.621148, 0.622515, 0.623880, 0.625243, 0.626604, 0.627963, 0.629320, 0.630676, 0.632029, 0.633381, 0.634731, 0.636078, 0.637424, 0.638768, 0.640110, 0.641450, 0.642788, 0.644124, 0.645458, 0.646790, 0.648120, 0.649448, 0.650774, 0.652098, 0.653421, 0.654741, 0.656059, 0.657375, 0.658689, 0.660002, 0.661312, 0.662620, 0.663926, 0.665230, 0.666532, 0.667833, 0.669131, 0.670427, 0.671721, 0.673013, 0.674302, 0.675590, 0.676876, 0.678160, 0.679441, 0.680721, 0.681998, 0.683274, 0.684547, 0.685818, 0.687088, 0.688355, 0.689620, 0.690882, 0.692143, 0.693402, 0.694658, 0.695913, 0.697165, 0.698415, 0.699663, 0.700909, 0.702153, 0.703395, 0.704634, 0.705872, 0.707107, 0.708340, 0.709571, 0.710799, 0.712026, 0.713250, 0.714473, 0.715693, 0.716911, 0.718126, 0.719340, 0.720551, 0.721760, 0.722967, 0.724172, 0.725374, 0.726575, 0.727773, 0.728969, 0.730162, 0.731354, 0.732543, 0.733730, 0.734915, 0.736097, 0.737277, 0.738455, 0.739631, 0.740805, 0.741976, 0.743145, 0.744312, 0.745476, 0.746638, 0.747798, 0.748956, 0.750111, 0.751264, 0.752415, 0.753563, 0.754710, 0.755853, 0.756995, 0.758134, 0.759271, 0.760406, 0.761538, 0.762668, 0.763796, 0.764921, 0.766044, 0.767165, 0.768284, 0.769400, 0.770513, 0.771625, 0.772734, 0.773840, 0.774944, 0.776046, 0.777146, 0.778243, 0.779338, 0.780430, 0.781520, 0.782608, 0.783693, 0.784776, 0.785857, 0.786935, 0.788011, 0.789084, 0.790155, 0.791224, 0.792290, 0.793353, 0.794415, 0.795473, 0.796530, 0.797584, 0.798636, 0.799685, 0.800731, 0.801776, 0.802817, 0.803857, 0.804894, 0.805928, 0.806960, 0.807990, 0.809017, 0.810042, 0.811064, 0.812084, 0.813101, 0.814116, 0.815128, 0.816138, 0.817145, 0.818150, 0.819152, 0.820152, 0.821149, 0.822144, 0.823136, 0.824126, 0.825113, 0.826098, 0.827081, 0.828060, 0.829038, 0.830012, 0.830984, 0.831954, 0.832921, 0.833886, 0.834848, 0.835807, 0.836764, 0.837719, 0.838671, 0.839620, 0.840567, 0.841511, 0.842452, 0.843391, 0.844328, 0.845262, 0.846193, 0.847122, 0.848048, 0.848972, 0.849893, 0.850811, 0.851727, 0.852640, 0.853551, 0.854459, 0.855364, 0.856267, 0.857167, 0.858065, 0.858960, 0.859852, 0.860742, 0.861629, 0.862514, 0.863396, 0.864275, 0.865151, 0.866025, 0.866897, 0.867765, 0.868632, 0.869495, 0.870356, 0.871214, 0.872069, 0.872922, 0.873772, 0.874620, 0.875465, 0.876307, 0.877146, 0.877983, 0.878817, 0.879649, 0.880477, 0.881303, 0.882127, 0.882948, 0.883766, 0.884581, 0.885394, 0.886204, 0.887011, 0.887815, 0.888617, 0.889416, 0.890213, 0.891007, 0.891798, 0.892586, 0.893371, 0.894154, 0.894934, 0.895712, 0.896486, 0.897258, 0.898028, 0.898794, 0.899558, 0.900319, 0.901077, 0.901833, 0.902585, 0.903335, 0.904083, 0.904827, 0.905569, 0.906308, 0.907044, 0.907777, 0.908508, 0.909236, 0.909961, 0.910684, 0.911403, 0.912120, 0.912834, 0.913545, 0.914254, 0.914960, 0.915663, 0.916363, 0.917060, 0.917755, 0.918446, 0.919135, 0.919821, 0.920505, 0.921185, 0.921863, 0.922538, 0.923210, 0.923880, 0.924546, 0.925210, 0.925871, 0.926529, 0.927184, 0.927836, 0.928486, 0.929133, 0.929776, 0.930418, 0.931056, 0.931691, 0.932324, 0.932954, 0.933580, 0.934204, 0.934826, 0.935444, 0.936060, 0.936672, 0.937282, 0.937889, 0.938493, 0.939094, 0.939693, 0.940288, 0.940881, 0.941471, 0.942057, 0.942641, 0.943223, 0.943801, 0.944376, 0.944949, 0.945519, 0.946085, 0.946649, 0.947210, 0.947768, 0.948324, 0.948876, 0.949425, 0.949972, 0.950516, 0.951057, 0.951594, 0.952129, 0.952661, 0.953191, 0.953717, 0.954240, 0.954761, 0.955278, 0.955793, 0.956305, 0.956814, 0.957319, 0.957822, 0.958323, 0.958820, 0.959314, 0.959805, 0.960294, 0.960779, 0.961262, 0.961741, 0.962218, 0.962692, 0.963163, 0.963630, 0.964095, 0.964557, 0.965016, 0.965473, 0.965926, 0.966376, 0.966823, 0.967268, 0.967709, 0.968148, 0.968583, 0.969016, 0.969445, 0.969872, 0.970296, 0.970716, 0.971134, 0.971549, 0.971961, 0.972370, 0.972776, 0.973179, 0.973579, 0.973976, 0.974370, 0.974761, 0.975149, 0.975535, 0.975917, 0.976296, 0.976672, 0.977046, 0.977416, 0.977783, 0.978148, 0.978509, 0.978867, 0.979223, 0.979575, 0.979925, 0.980271, 0.980615, 0.980955, 0.981293, 0.981627, 0.981959, 0.982287, 0.982613, 0.982935, 0.983255, 0.983571, 0.983885, 0.984196, 0.984503, 0.984808, 0.985109, 0.985408, 0.985703, 0.985996, 0.986286, 0.986572, 0.986856, 0.987136, 0.987414, 0.987688, 0.987960, 0.988228, 0.988494, 0.988756, 0.989016, 0.989272, 0.989526, 0.989776, 0.990024, 0.990268, 0.990509, 0.990748, 0.990983, 0.991216, 0.991445, 0.991671, 0.991894, 0.992115, 0.992332, 0.992546, 0.992757, 0.992966, 0.993171, 0.993373, 0.993572, 0.993768, 0.993961, 0.994151, 0.994338, 0.994522, 0.994703, 0.994881, 0.995056, 0.995227, 0.995396, 0.995562, 0.995725, 0.995884, 0.996041, 0.996195, 0.996345, 0.996493, 0.996637, 0.996779, 0.996917, 0.997053, 0.997185, 0.997314, 0.997441, 0.997564, 0.997684, 0.997801, 0.997916, 0.998027, 0.998135, 0.998240, 0.998342, 0.998441, 0.998537, 0.998630, 0.998719, 0.998806, 0.998890, 0.998971, 0.999048, 0.999123, 0.999194, 0.999263, 0.999328, 0.999391, 0.999450, 0.999507, 0.999560, 0.999610, 0.999657, 0.999701, 0.999743, 0.999781, 0.999816, 0.999848, 0.999877, 0.999903, 0.999925, 0.999945, 0.999962, 0.999976, 0.999986, 0.999994, 0.999998, 1.000000}
local aSineIndex={0.028648, 0.057296, 0.085944, 0.114592, 0.143240, 0.171888, 0.200536, 0.229184, 0.257832, 0.286480, 0.315128, 0.343777, 0.372425, 0.401074, 0.429722, 0.458371, 0.487020, 0.515669, 0.544318, 0.572967, 0.601617, 0.630266, 0.658916, 0.687566, 0.716216, 0.744866, 0.773517, 0.802167, 0.830818, 0.859469, 0.888120, 0.916772, 0.945423, 0.974075, 1.002727, 1.031380, 1.060032, 1.088685, 1.117339, 1.145992, 1.174646, 1.203300, 1.231954, 1.260609, 1.289264, 1.317919, 1.346575, 1.375231, 1.403887, 1.432544, 1.461201, 1.489858, 1.518516, 1.547174, 1.575833, 1.604492, 1.633151, 1.661811, 1.690471, 1.719131, 1.747792, 1.776454, 1.805116, 1.833778, 1.862441, 1.891104, 1.919768, 1.948432, 1.977097, 2.005762, 2.034428, 2.063094, 2.091761, 2.120428, 2.149096, 2.177764, 2.206433, 2.235102, 2.263772, 2.292443, 2.321114, 2.349786, 2.378458, 2.407131, 2.435804, 2.464478, 2.493153, 2.521828, 2.550504, 2.579181, 2.607858, 2.636536, 2.665215, 2.693894, 2.722574, 2.751255, 2.779936, 2.808618, 2.837301, 2.865984, 2.894668, 2.923353, 2.952039, 2.980725, 3.009412, 3.038100, 3.066788, 3.095478, 3.124168, 3.152859, 3.181551, 3.210243, 3.238936, 3.267630, 3.296325, 3.325021, 3.353718, 3.382415, 3.411114, 3.439813, 3.468513, 3.497214, 3.525915, 3.554618, 3.583322, 3.612026, 3.640732, 3.669438, 3.698145, 3.726853, 3.755562, 3.784272, 3.812983, 3.841695, 3.870408, 3.899122, 3.927837, 3.956553, 3.985269, 4.013987, 4.042706, 4.071426, 4.100147, 4.128869, 4.157592, 4.186316, 4.215041, 4.243767, 4.272494, 4.301222, 4.329952, 4.358682, 4.387414, 4.416146, 4.444880, 4.473615, 4.502351, 4.531088, 4.559826, 4.588566, 4.617306, 4.646048, 4.674791, 4.703535, 4.732280, 4.761027, 4.789775, 4.818523, 4.847274, 4.876025, 4.904777, 4.933531, 4.962286, 4.991043, 5.019800, 5.048559, 5.077319, 5.106080, 5.134843, 5.163607, 5.192372, 5.221139, 5.249907, 5.278676, 5.307447, 5.336219, 5.364992, 5.393766, 5.422542, 5.451320, 5.480099, 5.508879, 5.537660, 5.566443, 5.595227, 5.624013, 5.652800, 5.681589, 5.710379, 5.739170, 5.767963, 5.796758, 5.825554, 5.854351, 5.883150, 5.911950, 5.940752, 5.969555, 5.998360, 6.027167, 6.055974, 6.084784, 6.113595, 6.142407, 6.171221, 6.200037, 6.228854, 6.257673, 6.286494, 6.315316, 6.344139, 6.372964, 6.401791, 6.430620, 6.459450, 6.488282, 6.517115, 6.545950, 6.574787, 6.603625, 6.632465, 6.661307, 6.690150, 6.718995, 6.747842, 6.776691, 6.805541, 6.834393, 6.863247, 6.892103, 6.920960, 6.949819, 6.978680, 7.007542, 7.036407, 7.065273, 7.094141, 7.123011, 7.151882, 7.180756, 7.209631, 7.238508, 7.267387, 7.296268, 7.325151, 7.354035, 7.382922, 7.411810, 7.440700, 7.469592, 7.498486, 7.527382, 7.556280, 7.585180, 7.614082, 7.642985, 7.671891, 7.700799, 7.729708, 7.758620, 7.787533, 7.816449, 7.845367, 7.874286, 7.903208, 7.932131, 7.961057, 7.989985, 8.018914, 8.047846, 8.076780, 8.105716, 8.134654, 8.163594, 8.192536, 8.221481, 8.250427, 8.279376, 8.308326, 8.337279, 8.366234, 8.395191, 8.424151, 8.453112, 8.482076, 8.511041, 8.540009, 8.568980, 8.597952, 8.626927, 8.655903, 8.684882, 8.713864, 8.742847, 8.771833, 8.800821, 8.829812, 8.858804, 8.887799, 8.916796, 8.945796, 8.974798, 9.003802, 9.032808, 9.061817, 9.090828, 9.119842, 9.148857, 9.177876, 9.206896, 9.235919, 9.264945, 9.293972, 9.323002, 9.352035, 9.381070, 9.410107, 9.439147, 9.468190, 9.497234, 9.526282, 9.555331, 9.584384, 9.613438, 9.642495, 9.671555, 9.700617, 9.729682, 9.758749, 9.787819, 9.816891, 9.845966, 9.875044, 9.904124, 9.933206, 9.962291, 9.991379, 10.020470, 10.049563, 10.078658, 10.107756, 10.136857, 10.165961, 10.195067, 10.224176, 10.253287, 10.282401, 10.311518, 10.340638, 10.369760, 10.398885, 10.428012, 10.457143, 10.486276, 10.515412, 10.544550, 10.573692, 10.602836, 10.631983, 10.661132, 10.690285, 10.719440, 10.748598, 10.777759, 10.806923, 10.836089, 10.865259, 10.894431, 10.923606, 10.952784, 10.981965, 11.011149, 11.040335, 11.069525, 11.098717, 11.127913, 11.157111, 11.186312, 11.215516, 11.244724, 11.273934, 11.303147, 11.332363, 11.361582, 11.390804, 11.420029, 11.449257, 11.478488, 11.507722, 11.536959, 11.566199, 11.595442, 11.624689, 11.653938, 11.683190, 11.712446, 11.741705, 11.770966, 11.800231, 11.829499, 11.858770, 11.888044, 11.917322, 11.946602, 11.975886, 12.005173, 12.034463, 12.063756, 12.093053, 12.122352, 12.151655, 12.180961, 12.210271, 12.239583, 12.268899, 12.298218, 12.327540, 12.356866, 12.386195, 12.415527, 12.444863, 12.474202, 12.503544, 12.532889, 12.562238, 12.591590, 12.620946, 12.650305, 12.679667, 12.709033, 12.738402, 12.767775, 12.797150, 12.826530, 12.855913, 12.885299, 12.914688, 12.944082, 12.973478, 13.002878, 13.032282, 13.061689, 13.091099, 13.120513, 13.149931, 13.179352, 13.208777, 13.238205, 13.267636, 13.297072, 13.326511, 13.355953, 13.385399, 13.414849, 13.444302, 13.473759, 13.503219, 13.532684, 13.562151, 13.591623, 13.621098, 13.650577, 13.680059, 13.709545, 13.739035, 13.768529, 13.798026, 13.827527, 13.857032, 13.886540, 13.916053, 13.945569, 13.975088, 14.004612, 14.034139, 14.063671, 14.093206, 14.122745, 14.152287, 14.181834, 14.211384, 14.240938, 14.270496, 14.300058, 14.329624, 14.359194, 14.388768, 14.418345, 14.447927, 14.477512, 14.507102, 14.536695, 14.566292, 14.595894, 14.625499, 14.655108, 14.684721, 14.714339, 14.743960, 14.773585, 14.803215, 14.832848, 14.862485, 14.892127, 14.921773, 14.951422, 14.981076, 15.010734, 15.040396, 15.070062, 15.099732, 15.129407, 15.159085, 15.188768, 15.218455, 15.248146, 15.277842, 15.307541, 15.337245, 15.366953, 15.396665, 15.426381, 15.456102, 15.485827, 15.515556, 15.545290, 15.575028, 15.604770, 15.634516, 15.664267, 15.694022, 15.723781, 15.753545, 15.783313, 15.813086, 15.842863, 15.872644, 15.902430, 15.932220, 15.962014, 15.991813, 16.021616, 16.051424, 16.081237, 16.111053, 16.140875, 16.170700, 16.200531, 16.230365, 16.260205, 16.290049, 16.319897, 16.349750, 16.379607, 16.409469, 16.439336, 16.469207, 16.499083, 16.528964, 16.558849, 16.588738, 16.618633, 16.648532, 16.678435, 16.708344, 16.738257, 16.768175, 16.798097, 16.828024, 16.857956, 16.887893, 16.917834, 16.947780, 16.977731, 17.007687, 17.037647, 17.067613, 17.097583, 17.127558, 17.157537, 17.187522, 17.217511, 17.247506, 17.277505, 17.307509, 17.337518, 17.367532, 17.397551, 17.427574, 17.457603, 17.487637, 17.517675, 17.547719, 17.577767, 17.607821, 17.637880, 17.667943, 17.698012, 17.728085, 17.758164, 17.788248, 17.818336, 17.848430, 17.878529, 17.908633, 17.938742, 17.968857, 17.998976, 18.029101, 18.059230, 18.089365, 18.119505, 18.149651, 18.179801, 18.209957, 18.240118, 18.270284, 18.300455, 18.330632, 18.360814, 18.391001, 18.421193, 18.451391, 18.481594, 18.511803, 18.542016, 18.572235, 18.602460, 18.632690, 18.662925, 18.693165, 18.723411, 18.753663, 18.783920, 18.814182, 18.844450, 18.874723, 18.905001, 18.935285, 18.965575, 18.995870, 19.026171, 19.056477, 19.086788, 19.117106, 19.147429, 19.177757, 19.208091, 19.238430, 19.268775, 19.299126, 19.329483, 19.359845, 19.390212, 19.420586, 19.450965, 19.481350, 19.511740, 19.542136, 19.572538, 19.602946, 19.633359, 19.663778, 19.694203, 19.724634, 19.755070, 19.785512, 19.815960, 19.846414, 19.876874, 19.907340, 19.937811, 19.968289, 19.998772, 20.029261, 20.059756, 20.090257, 20.120764, 20.151277, 20.181796, 20.212321, 20.242851, 20.273388, 20.303931, 20.334480, 20.365035, 20.395596, 20.426163, 20.456736, 20.487315, 20.517900, 20.548492, 20.579089, 20.609693, 20.640303, 20.670919, 20.701541, 20.732169, 20.762804, 20.793444, 20.824091, 20.854745, 20.885404, 20.916070, 20.946742, 20.977420, 21.008104, 21.038795, 21.069492, 21.100196, 21.130906, 21.161622, 21.192345, 21.223074, 21.253809, 21.284551, 21.315299, 21.346054, 21.376815, 21.407583, 21.438357, 21.469137, 21.499924, 21.530718, 21.561518, 21.592325, 21.623138, 21.653958, 21.684784, 21.715617, 21.746457, 21.777303, 21.808156, 21.839015, 21.869882, 21.900754, 21.931634, 21.962520, 21.993413, 22.024313, 22.055219, 22.086132, 22.117052, 22.147979, 22.178913, 22.209853, 22.240800, 22.271754, 22.302715, 22.333683, 22.364657, 22.395639, 22.426627, 22.457622, 22.488625, 22.519634, 22.550650, 22.581673, 22.612703, 22.643740, 22.674784, 22.705836, 22.736894, 22.767959, 22.799031, 22.830111, 22.861197, 22.892291, 22.923392, 22.954499, 22.985614, 23.016737, 23.047866, 23.079003, 23.110146, 23.141297, 23.172456, 23.203621, 23.234794, 23.265974, 23.297161, 23.328356, 23.359558, 23.390767, 23.421984, 23.453208, 23.484440, 23.515679, 23.546925, 23.578178, 23.609440, 23.640708, 23.671984, 23.703268, 23.734559, 23.765857, 23.797164, 23.828477, 23.859798, 23.891127, 23.922464, 23.953807, 23.985159, 24.016518, 24.047885, 24.079260, 24.110642, 24.142032, 24.173429, 24.204835, 24.236248, 24.267669, 24.299097, 24.330534, 24.361978, 24.393430, 24.424890, 24.456357, 24.487833, 24.519316, 24.550808, 24.582307, 24.613814, 24.645329, 24.676852, 24.708383, 24.739922, 24.771469, 24.803024, 24.834587, 24.866159, 24.897738, 24.929325, 24.960920, 24.992524, 25.024135, 25.055755, 25.087383, 25.119019, 25.150663, 25.182316, 25.213977, 25.245646, 25.277323, 25.309008, 25.340702, 25.372404, 25.404114, 25.435833, 25.467560, 25.499296, 25.531039, 25.562792, 25.594552, 25.626321, 25.658099, 25.689885, 25.721679, 25.753482, 25.785294, 25.817114, 25.848943, 25.880780, 25.912625, 25.944480, 25.976343, 26.008214, 26.040095, 26.071984, 26.103881, 26.135787, 26.167702, 26.199626, 26.231559, 26.263500, 26.295450, 26.327409, 26.359377, 26.391353, 26.423339, 26.455333, 26.487336, 26.519348, 26.551369, 26.583399, 26.615438, 26.647486, 26.679543, 26.711609, 26.743684, 26.775768, 26.807861, 26.839963, 26.872074, 26.904195, 26.936324, 26.968463, 27.000611, 27.032768, 27.064934, 27.097110, 27.129294, 27.161488, 27.193692, 27.225904, 27.258126, 27.290358, 27.322598, 27.354848, 27.387108, 27.419376, 27.451655, 27.483942, 27.516239, 27.548546, 27.580862, 27.613188, 27.645523, 27.677868, 27.710222, 27.742586, 27.774960, 27.807343, 27.839736, 27.872138, 27.904550, 27.936972, 27.969404, 28.001845, 28.034297, 28.066758, 28.099228, 28.131709, 28.164199, 28.196700, 28.229210, 28.261730, 28.294260, 28.326800, 28.359350, 28.391910, 28.424480, 28.457060, 28.489650, 28.522250, 28.554860, 28.587480, 28.620111, 28.652751, 28.685402, 28.718063, 28.750734, 28.783415, 28.816107, 28.848809, 28.881521, 28.914243, 28.946976, 28.979719, 29.012472, 29.045236, 29.078010, 29.110795, 29.143590, 29.176396, 29.209212, 29.242039, 29.274876, 29.307723, 29.340582, 29.373450, 29.406330, 29.439220, 29.472121, 29.505032, 29.537954, 29.570887, 29.603831, 29.636785, 29.669750, 29.702726, 29.735713, 29.768711, 29.801719, 29.834739, 29.867769, 29.900810, 29.933863, 29.966926, 30.000000, 30.033085, 30.066182, 30.099289, 30.132407, 30.165537, 30.198678, 30.231830, 30.264993, 30.298167, 30.331352, 30.364549, 30.397757, 30.430976, 30.464207, 30.497449, 30.530702, 30.563967, 30.597243, 30.630531, 30.663830, 30.697140, 30.730462, 30.763796, 30.797141, 30.830497, 30.863866, 30.897246, 30.930637, 30.964040, 30.997455, 31.030882, 31.064320, 31.097770, 31.131232, 31.164705, 31.198191, 31.231688, 31.265197, 31.298718, 31.332251, 31.365796, 31.399353, 31.432922, 31.466503, 31.500096, 31.533702, 31.567319, 31.600948, 31.634590, 31.668243, 31.701909, 31.735587, 31.769278, 31.802980, 31.836695, 31.870422, 31.904162, 31.937914, 31.971678, 32.005455, 32.039244, 32.073046, 32.106860, 32.140687, 32.174526, 32.208378, 32.242242, 32.276119, 32.310009, 32.343911, 32.377827, 32.411754, 32.445695, 32.479648, 32.513615, 32.547594, 32.581586, 32.615590, 32.649608, 32.683639, 32.717683, 32.751739, 32.785809, 32.819892, 32.853987, 32.888096, 32.922218, 32.956354, 32.990502, 33.024664, 33.058839, 33.093027, 33.127228, 33.161443, 33.195671, 33.229913, 33.264167, 33.298436, 33.332718, 33.367013, 33.401322, 33.435644, 33.469980, 33.504330, 33.538693, 33.573070, 33.607461, 33.641865, 33.676283, 33.710715, 33.745160, 33.779620, 33.814093, 33.848581, 33.883082, 33.917597, 33.952126, 33.986669, 34.021226, 34.055798, 34.090383, 34.124983, 34.159596, 34.194224, 34.228866, 34.263523, 34.298193, 34.332878, 34.367578, 34.402291, 34.437019, 34.471762, 34.506519, 34.541290, 34.576076, 34.610877, 34.645692, 34.680522, 34.715367, 34.750226, 34.785100, 34.819988, 34.854892, 34.889810, 34.924743, 34.959691, 34.994654, 35.029632, 35.064624, 35.099632, 35.134655, 35.169693, 35.204746, 35.239814, 35.274897, 35.309996, 35.345110, 35.380239, 35.415383, 35.450543, 35.485718, 35.520908, 35.556114, 35.591335, 35.626572, 35.661824, 35.697092, 35.732376, 35.767675, 35.802990, 35.838321, 35.873667, 35.909029, 35.944407, 35.979801, 36.015210, 36.050636, 36.086077, 36.121535, 36.157008, 36.192498, 36.228003, 36.263525, 36.299063, 36.334617, 36.370188, 36.405774, 36.441377, 36.476996, 36.512632, 36.548284, 36.583953, 36.619638, 36.655339, 36.691057, 36.726792, 36.762543, 36.798311, 36.834096, 36.869898, 36.905716, 36.941551, 36.977403, 37.013272, 37.049158, 37.085060, 37.120980, 37.156917, 37.192871, 37.228842, 37.264830, 37.300836, 37.336858, 37.372898, 37.408955, 37.445030, 37.481122, 37.517232, 37.553358, 37.589503, 37.625665, 37.661845, 37.698042, 37.734257, 37.770490, 37.806740, 37.843008, 37.879294, 37.915598, 37.951920, 37.988260, 38.024618, 38.060994, 38.097388, 38.133800, 38.170231, 38.206679, 38.243146, 38.279631, 38.316134, 38.352656, 38.389197, 38.425755, 38.462333, 38.498928, 38.535543, 38.572176, 38.608828, 38.645498, 38.682187, 38.718896, 38.755622, 38.792368, 38.829133, 38.865917, 38.902720, 38.939542, 38.976383, 39.013243, 39.050123, 39.087021, 39.123939, 39.160877, 39.197834, 39.234810, 39.271806, 39.308821, 39.345856, 39.382910, 39.419984, 39.457078, 39.494192, 39.531326, 39.568479, 39.605652, 39.642846, 39.680059, 39.717292, 39.754546, 39.791819, 39.829113, 39.866427, 39.903762, 39.941117, 39.978492, 40.015887, 40.053304, 40.090740, 40.128198, 40.165675, 40.203174, 40.240694, 40.278234, 40.315795, 40.353377, 40.390980, 40.428604, 40.466249, 40.503915, 40.541602, 40.579310, 40.617040, 40.654791, 40.692564, 40.730357, 40.768173, 40.806010, 40.843868, 40.881748, 40.919650, 40.957573, 40.995519, 41.033486, 41.071475, 41.109486, 41.147519, 41.185574, 41.223652, 41.261751, 41.299873, 41.338017, 41.376183, 41.414372, 41.452583, 41.490817, 41.529073, 41.567352, 41.605654, 41.643978, 41.682325, 41.720695, 41.759088, 41.797504, 41.835943, 41.874406, 41.912891, 41.951399, 41.989931, 42.028486, 42.067065, 42.105667, 42.144292, 42.182941, 42.221614, 42.260310, 42.299031, 42.337775, 42.376543, 42.415334, 42.454150, 42.492990, 42.531854, 42.570742, 42.609655, 42.648592, 42.687553, 42.726539, 42.765549, 42.804584, 42.843643, 42.882727, 42.921836, 42.960970, 43.000128, 43.039312, 43.078521, 43.117755, 43.157013, 43.196298, 43.235607, 43.274942, 43.314302, 43.353688, 43.393100, 43.432537, 43.471999, 43.511488, 43.551002, 43.590543, 43.630109, 43.669701, 43.709320, 43.748964, 43.788635, 43.828333, 43.868057, 43.907807, 43.947584, 43.987387, 44.027217, 44.067074, 44.106958, 44.146869, 44.186806, 44.226771, 44.266763, 44.306782, 44.346829, 44.386903, 44.427004, 44.467133, 44.507289, 44.547473, 44.587685, 44.627925, 44.668193, 44.708488, 44.748812, 44.789164, 44.829544, 44.869952, 44.910389, 44.950855, 44.991348, 45.031871, 45.072422, 45.113002, 45.153611, 45.194249, 45.234915, 45.275611, 45.316336, 45.357091, 45.397875, 45.438688, 45.479531, 45.520403, 45.561305, 45.602237, 45.643199, 45.684191, 45.725213, 45.766265, 45.807347, 45.848460, 45.889603, 45.930776, 45.971980, 46.013215, 46.054480, 46.095777, 46.137104, 46.178462, 46.219852, 46.261273, 46.302725, 46.344208, 46.385723, 46.427270, 46.468848, 46.510458, 46.552100, 46.593774, 46.635480, 46.677218, 46.718988, 46.760791, 46.802626, 46.844494, 46.886394, 46.928327, 46.970293, 47.012292, 47.054324, 47.096389, 47.138488, 47.180620, 47.222785, 47.264984, 47.307216, 47.349482, 47.391782, 47.434117, 47.476485, 47.518887, 47.561324, 47.603795, 47.646300, 47.688841, 47.731416, 47.774025, 47.816670, 47.859350, 47.902065, 47.944815, 47.987600, 48.030422, 48.073278, 48.116171, 48.159099, 48.202063, 48.245063, 48.288100, 48.331173, 48.374282, 48.417427, 48.460610, 48.503829, 48.547085, 48.590378, 48.633708, 48.677075, 48.720480, 48.763922, 48.807402, 48.850920, 48.894475, 48.938069, 48.981700, 49.025370, 49.069078, 49.112824, 49.156610, 49.200434, 49.244296, 49.288198, 49.332139, 49.376119, 49.420139, 49.464198, 49.508297, 49.552435, 49.596614, 49.640832, 49.685091, 49.729390, 49.773729, 49.818109, 49.862530, 49.906992, 49.951495, 49.996039, 50.040624, 50.085251, 50.129919, 50.174629, 50.219381, 50.264174, 50.309010, 50.353889, 50.398810, 50.443773, 50.488779, 50.533828, 50.578921, 50.624056, 50.669235, 50.714457, 50.759723, 50.805033, 50.850386, 50.895784, 50.941226, 50.986713, 51.032244, 51.077820, 51.123441, 51.169107, 51.214819, 51.260575, 51.306378, 51.352226, 51.398120, 51.444060, 51.490046, 51.536079, 51.582159, 51.628285, 51.674458, 51.720678, 51.766946, 51.813261, 51.859624, 51.906034, 51.952493, 51.998999, 52.045554, 52.092158, 52.138810, 52.185511, 52.232262, 52.279061, 52.325911, 52.372809, 52.419758, 52.466757, 52.513806, 52.560905, 52.608055, 52.655256, 52.702507, 52.749810, 52.797165, 52.844571, 52.892029, 52.939539, 52.987101, 53.034715, 53.082382, 53.130102, 53.177875, 53.225702, 53.273581, 53.321515, 53.369502, 53.417544, 53.465640, 53.513790, 53.561995, 53.610255, 53.658571, 53.706942, 53.755368, 53.803850, 53.852389, 53.900984, 53.949635, 53.998343, 54.047109, 54.095931, 54.144812, 54.193749, 54.242745, 54.291800, 54.340912, 54.390084, 54.439314, 54.488604, 54.537953, 54.587362, 54.636831, 54.686360, 54.735950, 54.785600, 54.835312, 54.885084, 54.934919, 54.984815, 55.034773, 55.084794, 55.134877, 55.185023, 55.235233, 55.285505, 55.335842, 55.386243, 55.436708, 55.487237, 55.537832, 55.588491, 55.639216, 55.690007, 55.740864, 55.791788, 55.842778, 55.893834, 55.944959, 55.996150, 56.047410, 56.098738, 56.150134, 56.201600, 56.253134, 56.304738, 56.356412, 56.408155, 56.459969, 56.511854, 56.563811, 56.615838, 56.667938, 56.720109, 56.772353, 56.824670, 56.877060, 56.929523, 56.982061, 57.034672, 57.087358, 57.140120, 57.192956, 57.245868, 57.298857, 57.351921, 57.405063, 57.458281, 57.511578, 57.564952, 57.618405, 57.671936, 57.725546, 57.779236, 57.833006, 57.886857, 57.940788, 57.994800, 58.048894, 58.103070, 58.157328, 58.211669, 58.266094, 58.320602, 58.375194, 58.429871, 58.484633, 58.539481, 58.594414, 58.649434, 58.704541, 58.759735, 58.815017, 58.870387, 58.925845, 58.981394, 59.037031, 59.092759, 59.148578, 59.204488, 59.260489, 59.316583, 59.372769, 59.429049, 59.485422, 59.541890, 59.598452, 59.655110, 59.711864, 59.768714, 59.825661, 59.882705, 59.939848, 59.997089, 60.054430, 60.111870, 60.169410, 60.227052, 60.284795, 60.342640, 60.400588, 60.458639, 60.516795, 60.575055, 60.633420, 60.691891, 60.750468, 60.809153, 60.867945, 60.926846, 60.985856, 61.044976, 61.104206, 61.163547, 61.223000, 61.282566, 61.342245, 61.402038, 61.461945, 61.521968, 61.582107, 61.642363, 61.702737, 61.763229, 61.823840, 61.884571, 61.945423, 62.006397, 62.067492, 62.128711, 62.190054, 62.251521, 62.313114, 62.374834, 62.436681, 62.498656, 62.560760, 62.622994, 62.685359, 62.747855, 62.810484, 62.873247, 62.936144, 62.999177, 63.062346, 63.125652, 63.189097, 63.252681, 63.316405, 63.380270, 63.444278, 63.508430, 63.572726, 63.637167, 63.701755, 63.766490, 63.831375, 63.896409, 63.961594, 64.026931, 64.092422, 64.158067, 64.223868, 64.289826, 64.355941, 64.422216, 64.488652, 64.555249, 64.622010, 64.688935, 64.756025, 64.823283, 64.890709, 64.958305, 65.026072, 65.094011, 65.162124, 65.230413, 65.298879, 65.367523, 65.436346, 65.505352, 65.574540, 65.643912, 65.713470, 65.783217, 65.853152, 65.923278, 65.993597, 66.064111, 66.134820, 66.205727, 66.276834, 66.348142, 66.419653, 66.491369, 66.563293, 66.635425, 66.707768, 66.780324, 66.853094, 66.926082, 66.999288, 67.072716, 67.146366, 67.220242, 67.294345, 67.368679, 67.443244, 67.518043, 67.593080, 67.668355, 67.743872, 67.819633, 67.895640, 67.971897, 68.048405, 68.125167, 68.202187, 68.279466, 68.357008, 68.434815, 68.512890, 68.591237, 68.669858, 68.748756, 68.827934, 68.907396, 68.987145, 69.067184, 69.147516, 69.228145, 69.309074, 69.390307, 69.471847, 69.553699, 69.635865, 69.718350, 69.801158, 69.884292, 69.967757, 70.051556, 70.135695, 70.220177, 70.305007, 70.390189, 70.475728, 70.561629, 70.647897, 70.734535, 70.821551, 70.908947, 70.996731, 71.084907, 71.173481, 71.262458, 71.351845, 71.441646, 71.531869, 71.622519, 71.713603, 71.805128, 71.897099, 71.989524, 72.082410, 72.175764, 72.269594, 72.363906, 72.458710, 72.554012, 72.649822, 72.746147, 72.842996, 72.940379, 73.038304, 73.136780, 73.235819, 73.335429, 73.435620, 73.536405, 73.637793, 73.739795, 73.842424, 73.945692, 74.049610, 74.154192, 74.259451, 74.365401, 74.472055, 74.579429, 74.687537, 74.796396, 74.906021, 75.016429, 75.127638, 75.239665, 75.352531, 75.466253, 75.580853, 75.696351, 75.812770, 75.930132, 76.048462, 76.167783, 76.288122, 76.409506, 76.531963, 76.655523, 76.780217, 76.906077, 77.033136, 77.161432, 77.291000, 77.421881, 77.554116, 77.687748, 77.822824, 77.959392, 78.097504, 78.237213, 78.378578, 78.521659, 78.666522, 78.813236, 78.961875, 79.112517, 79.265247, 79.420156, 79.577340, 79.736904, 79.898961, 80.063633, 80.231052, 80.401362, 80.574719, 80.751295, 80.931278, 81.114876, 81.302316, 81.493853, 81.689770, 81.890386, 82.096056, 82.307188, 82.524243, 82.747753, 82.978336, 83.216711, 83.463732, 83.720419, 83.988010, 84.268032, 84.562405, 84.873600, 85.204892, 85.560778, 85.947732, 86.375693, 86.861389, 87.437441, 88.188073, 90.0}

--image rotations
--first num is always going to be enemyID, because it is going to first be enemyID for scaling, then angle for rotation
local cannonRotations={}
local cannonBallRescales={}
local degAccuracy=3.0

--functions


function fastSin(degree)
    if degree<0 then
        return -fastSin(degree+180)
    elseif degree<=90 then
        degree=degree*10
        degree=math.floor(degree)
        return sineIndex[degree]
    elseif degree>90 and degree<=180 then
        return fastSin(180-degree)
    else
        return -fastSin(degree-180)
    end
end

function fastCos(degree)
    return fastSin(degree-90)
end

function fastTan(degree)
    return fastSin(degree)/fastCos(degree)
end

function fastASin(val)--returns in degrees
    val=val*2000
    val=math.floor(val)
    if val==0.0 then
        return 0.0
    end
    if val>0.0 and val<=2000.0 then
        return aSineIndex[val]
    elseif val<0.0 and val>=-2000.0 then
        return -aSineIndex[-val]
    end
end

function fastACos(val)--returns in degrees
    return (90-fastASin(val))
end

function fastATan(val)--returns in degrees
    newval=math.sqrt(1/(1+math.pow(val,2)))
    if val>0 then
        return fastACos(newval)
    else
        return -fastACos(newval)
    end
end


function on.construction()
    --[[if var.recall("uSPCCLFI")~=nil and var.recall("SPCLFI")~=nil and var.recall("SPCVLFI")~=nil then
        uSPCC=var.recall("uSPCCLFI")
        SPC=var.recall("SPCLFI")
        SPCV=var.recall("SPCVLFI")
    end
    if var.recall("ASLFI")~=nil and var.recall("ASVLFI")~=nil and var.recall("uASCLFI")~=nil then
       AS=var.recall("ASLFI")
       ASV=var.recall("ASVLFI")
       ASC=var.recall("ASCLFI")
    end
    if var.recall("moneyLFI")~=nil then
        money=var.recall("moneyLFI")
    end
    if var.recall("damageLFI")~=nil and var.recall("damageVelocityLFI")~=nil and var.recall("uDamageCostLFI")~=nil then
        damage=var.recall("damageLFI")
        damageVelocity=var.recall("damageVelocityLFI")
        uDamageCost=var.recall("uDamageCostLFI")
    end
    if var.recall("bulletSpeedLFI")~=nil and var.recall("bulletSpeedVelocityLFI")~=nil and var.recall("uBulletSpeedCostLFI")~=nil then
        bulletSpeed=var.recall("bulletSpeedLFI")
        bulletSpeedVelocity=var.recall("bulletSpeedVelocityLFI")
        bulletSpeedCost=var.recall("uBulletSpeedCostLFI")
    end
    if var.recall("enemyIDLFI")~=nil then
        enemyID=var.recall("enemyIDLFI")
    end
    if var.recall("maxEnemyIDAllowedLFI")~=nil then
        maxEnemyIDAllowed=var.recall("maxEnemyIDAllowedLFI")
    end]]
    for i=1, amountEnemies do
       
    end
   
    timer.start(1/30)
end

function norm(x,y)
    return math.sqrt(math.pow(x,2)+math.pow(y,2))
end

function distancePerPixel()
    return enemies[enemyID][4]/screenWidth
end

function on.timer()
    if timer.getMilliSecCounter()>prevShootTime+400 and mouseDown==true then
        clickShots=clickShots+SPC
        clickShotsCopy=clickShots
        for i=1, clickShotsCopy do
            createCannonBall(i)
            clickShots=clickShots-1
        end
        prevShootTime=timer.getMilliSecCounter()
    end
    numCB=cannonBalls[1]
    for i=2, numCB+1 do
        local temp=false
        if cannonBalls[i]~=nil then
            velX=cannonBalls[i][1]
            velY=cannonBalls[i][2]
            X=cannonBalls[i][3]
            Y=cannonBalls[i][4]
            prevX=cannonBalls[i][5]
            prevY=cannonBalls[i][6]
            X=X+velX/7.5
            Y=Y+velY/7.5
            velY=velY-gravity/7.5
            while norm(X-prevX,Y-prevY)>=5 and X-prevX>=0 and Y-prevY>=0 do
                velX=velX*airVecMultiplier
                velY=velY*airVecMultiplier
                mag=norm(X-prevX, Y-prevY)
                mag=mag-5
                tempPrevX=prevX
                tempPrevY=prevY
                tempPrevX=X-math.sqrt(math.pow(mag,2)*math.pow(X-prevX,2)/(math.pow(X-prevX,2)+math.pow(Y-prevY,2)))
                tempPrevY=Y-math.sqrt(math.pow(mag,2)*math.pow(Y-prevY,2)/(math.pow(X-prevX,2)+math.pow(Y-prevY,2)))
                prevX=tempPrevX
                prevY=tempPrevY
            end
            if Y<0 or X/distancePerPixel()>screenWidth then
                cannonBalls[i]=nil
                for j=i, numCB do
                    cannonBalls[j]={}
                    for f=1,6 do
                        cannonBalls[j][f]=cannonBalls[j+1][f]
                    end
                end
                cannonBalls[1]=cannonBalls[1]-1
                cannonBalls[numCB+2]=nil
                numCB=numCB-1
                i=i-1
                temp=true
            else
                cannonBalls[i][1]=velX
                cannonBalls[i][2]=velY
                cannonBalls[i][3]=X
                cannonBalls[i][4]=Y
                cannonBalls[i][5]=prevX
                cannonBalls[i][6]=prevY
                if X>=enemies[enemyID][6] and X<=enemies[enemyID][6]+enemies[enemyID][7] then
                    if Y<=enemies[enemyID][8] then
                        enemyHealth=enemyHealth-damage
                        if enemyHealth<=0 then
                            enemyHealth=enemies[enemyID][3]
                            money=money+enemies[enemyID][5]
                            var.store("moneyLFI", money)
                            if maxEnemyIDAllowed==enemyID then
                                maxEnemyIDAllowed=enemyID+1
                            end
                        end
                        cannonBalls[i]=nil
                        for j=i, numCB do
                            cannonBalls[j]={}
                            for f=1,6 do
                                cannonBalls[j][f]=cannonBalls[j+1][f]
                            end
                        end
                        cannonBalls[1]=cannonBalls[1]-1
                        cannonBalls[numCB+2]=nil
                        numCB=numCB-1
                        i=i-1
                        temp=true
                    end
                end
            end
        else
            if temp==false then
                for j=i, numCB do
                    cannonBalls[j]={}
                    for f=1,6 do
                        cannonBalls[j][f]=cannonBalls[j+1][f]
                    end
                end
                cannonBalls[1]=cannonBalls[1]-1
                numCB=cannonBalls[1]
                cannonBalls[numCB+2]=nil
                i=i-1
            end
        end
    end
    if timer.getMilliSecCounter()>prevAutoShotTime+1000.0 then
        autoShots=autoShots+AS
        autoShotsCopy=autoShots
        for i=1,autoShotsCopy do
            createCannonBall(i)
            autoShots=autoShots-1
        end
        prevAutoShotTime=timer.getMilliSecCounter()
    end
    var.store("enemyIDLFI", enemyID)
    var.store("maxEnemyIDAllowedLFI", maxEnemyIDAllowed)
    --if timer.getMilliSecCounter()>prevDisplayTime+1000/15 then
    screen:invalidate()
    --end
end

--[[function on.arrowUp()
    if angle<90 then
        angle=angle+2.5
        screen:invalidate()
    end
end

function on.arrowDown()
    if angle>0 then
        angle=angle-2.5
        screen:invalidate()
    end
end--]]
function on.arrowLeft()
    if enemyID>1 then
        enemyID=enemyID-1
        enemyHealth=enemies[enemyID][3]
    end
end

function on.arrowRight()
    if maxEnemyIDAllowed>enemyID and enemies[enemyID+1]~=nil then
        enemyID=enemyID+1
        enemyHealth=enemies[enemyID][3]
    end
end

function createCannonBall(i)
    cannonBalls[cannonBalls[1]+2]={(mouseX-10)/norm(mouseX-10,screenHeight-mouseY+10)*bulletSpeed,(screenHeight-mouseY+10)/norm(mouseX-10,screenHeight-mouseY+10)*bulletSpeed, 10*distancePerPixel()+(32+(i-1)*8*distancePerPixel())*mouseX/norm(mouseX,screenHeight-mouseY),20*distancePerPixel()+(32+(i-1)*8*distancePerPixel())*(screenHeight-mouseY)/norm(mouseX,screenHeight-mouseY), (10)*distancePerPixel()+(32+(i-1)*8*distancePerPixel())*mouseX/norm(mouseX,screenHeight-mouseY), (20)*distancePerPixel()+(32+(i-1)*8*distancePerPixel())*(mouseY-screenHeight)/norm(mouseX,screenHeight-mouseY)}
    cannonBalls[1]=cannonBalls[1]+1
end

function on.mouseDown(x,y)
    mouseDown=true
end

function on.mouseUp(x,y)
    mouseDown=false
end

function on.mouseMove(x,y)
    mouseX=x
    mouseY=y
    angle=fastATan((screenHeight-y-10)/(x-10))
    if angle<0 and screenHeight-y-10>0 then
        angle=angle+180
    end
    screen:invalidate()
end

function on.charIn(ch)
    if ch=="1" and uDamageCost<=money then
       damage=damage+damageVelocity
       damageVelocity=damageVelocity*damageVelocityMultiplier
       damage=math.floor(damage)
       var.store("damageLFI", damage)
       var.store("damageVelocityLFI", damageVelocity)
       money=money-uDamageCost
       uDamageCost=uDamageCost*uDamageMultiplier
       uDamageCost=uDamageCost+uDamageAdder
       uDamageCost=math.floor(uDamageCost)
       var.store("uDamageCostLFI", uDamageCost)
   elseif ch=="2" and uBulletSpeedCost<=money then
        bulletSpeed=bulletSpeed+bulletSpeedVelocity
        bulletSpeedVelocity=bulletSpeedVelocity*damageVelocityMultiplier
        bulletSpeed=math.floor(bulletSpeed)
        var.store("bulletSpeedLFI", bulletSpeed)
        var.store("bulletSpeedVelocityLFI", bulletSpeedVelocity)
        money=money-uBulletSpeedCost
        uBulletSpeedCost=uBulletSpeedCost*uBulletSpeedMultiplier
        uBulletSpeedCost=uBulletSpeedCost+uBulletSpeedAdder
        uBulletSpeedCost=math.floor(uBulletSpeedCost)
        var.store("uBulletSpeedCostLFI", uBulletSpeedCost)
   elseif ch=="3" and uSPCC<=money then
        SPC=SPC+SPCV
        SPCV=SPCV*SPCVM
        --SPC=math.floor(SPCV)
        var.store("SPCLFI", SPC)
        var.store("SPCVLFI", SPCV)
        money=money-uSPCC
        uSPCC=uSPCC*uSPCM
        uSPCC=uSPCC+uSPCA
        uSPCC=math.floor(uSPCC)
        var.store("uSPCCLFI", uSPCC)
    elseif ch=="4" and uASC<=money then
        AS=AS+ASV
        ASV=ASV*ASVM
        --AS=math.floor(ASV)
        var.store("ASLFI", AS)
        var.store("ASVLFI", ASV)
        money=money-uASC
        uASC=uASC*uASM
        uASC=uASC+uASA
        uASC=math.floor(uASC)
        var.store("uASCLFI", uASC)
   end
   money=math.floor(money)
   var.store("moneyLFI", money)
end

function on.clearKey()
    resetSave()
end

function resetSave()
    uSPCC=uSPCCR
    money=0.0
    SPC=SPCR
    SPCV=SPCVR
    uSPCC=uSPCCR
    AS=ASR
    ASV=ASVR
    uASC=uASCR
    damage=damageR
    damageVelocity=damageVelocityR
    uDamageCost=uDamageCostR
    bulletSpeed=bulletSpeedR
    bulletSpeedVelocity=bulletSpeedVelocityR
    uBulletSpeedCost=uBulletSpeedCostR
    enemyID=1
    maxEnemyIDAllowed=1
    enemyHealth=enemies[enemyID][3]
    var.store("uSPCCLFI", uSPCCR)
    var.store("moneyLFI", money)
    var.store("SPCLFI", SPC)
    var.store("SPCVLFI", SPCV)
    var.store("uSPCCLFI", uSPCC)
    var.store("ASLFI", AS)
    var.store("ASVLFI", ASV)
    var.store("uASCLFI", uASC)
    var.store("damageLFI", damage)
    var.store("damageVelocityLFI", damageVelocity)
    var.store("uDamageCostLFI", uDamageCost)
    var.store("bulletSpeedLFI", bulletSpeed)
    var.store("bulletSpeedVelocityLFI", bulletSpeedVelocity)
    var.store("uBulletSpeedCostLFI", uBulletSpeedCost)
    var.store("enemyIDLFI", enemyID)
    var.store("maxEnemyIDAllowedLFI", maxEnemyIDAllowed)
end

function on.paint(gc)

--[[local w = screen:width()

local h = screen:height()

sc = (var.recall("scale") or 0.5)

imw = bridge1:width()

imh = bridge1:height()

im = bridge1:copy(sc * imw, sc * imh)

imw = im:width()

imh = im:height()

gc:drawImage(im, (w - imw)/2, (h - imh)/2)--]]
    --display the cannon
    rotatedCannon=cannonResource:copy(cannonResource:width()/distancePerPixel()+2, cannonResource:height()/distancePerPixel()+2)
    rotatedCannon=rotatedCannon:rotate(angle)
    gc:drawImage(rotatedCannon, 10+1*math.cos(angle/180*math.pi), screen:height()-10-(1*math.sin(angle/180*math.pi))-rotatedCannon:height())
    gc:drawLine(0, 50, screen:width(), 50) 
    --text allignment is reversed comp to calc
    --cannonball displaying
    numCB=cannonBalls[1]
    cannonBallResourceCopy=cannonBallResource:copy(cannonBallResource:width()/distancePerPixel()/2,cannonBallResource:height()/distancePerPixel()/2)
    for i=2,numCB+1 do
        if cannonBalls[i]~=nil then
            if cannonBalls[i][3]/distancePerPixel()<screenWidth then
                gc:drawImage(cannonBallResourceCopy, cannonBalls[i][3]/distancePerPixel(), screenHeight-cannonBalls[i][4]/distancePerPixel())
            end
        end
    end
    --displaying the enemy
    enemyImage=enemies[enemyID][2]:copy(enemies[enemyID][7]/distancePerPixel(), enemies[enemyID][8]/distancePerPixel())
    gc:drawImage(enemyImage, enemies[enemyID][6]/distancePerPixel(), screenHeight-enemies[enemyID][8]/distancePerPixel())
   
    --stats
    gc:drawString("health: "..enemyHealth, screenWidth-gc:getStringWidth("health: "..enemyHealth), 0, "top")
    gc:drawString("dist: "..enemies[enemyID][6], screenWidth-gc:getStringWidth("dist: "..enemies[enemyID][6]), gc:getStringHeight("health: "..enemyHealth), "top")
    gc:drawString("$"..money.." X: "..mouseX.." Y: "..mouseY.." SPC: "..math.floor(SPC*10)/10, 0, 0, "top")

end







-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

File 2: upgradeTab

screen=platform.window
screenWidth=screen:width()
screenHeight=screen:height()

function on.construction()
    timer.start(1/5)
end

function on.timer()
    screen:invalidate()
end

function on.paint(gc)
    SH=gc:getStringHeight("d")
    if var.recall("damageLFI")~=nil and var.recall("uDamageCostLFI")~=nil then
        gc:drawString("D: "..var.recall("damageLFI").." uDC: "..var.recall("uDamageCostLFI"), 0, 0, "top")
    end
    if var.recall("bulletSpeedLFI")~=nil and var.recall("uBulletSpeedCostLFI")~=nil then
        gc:drawString("BS: "..var.recall("bulletSpeedLFI").." uBSC: "..var.recall("uBulletSpeedCostLFI"), 0, SH, "top")
    end
    if var.recall("SPCLFI")~=nil and var.recall("uSPCCLFI")~=nil then
        gc:drawString("SPC: "..var.recall("SPCLFI").." uSPCC: "..var.recall("uSPCCLFI"), 0, SH*2, "top")
    end
    if var.recall("ASLFI")~=nil and var.recall("uASCLFI")~=nil then
        gc:drawString("AS: "..var.recall("ASLFI").." uASC: "..var.recall("uASCLFI"), 0, SH*3, "top")
    end
end
280
Right now I am reading through one of the optimization pdf. I don't understand the metatable tutorial. What are metatables?

Quote from: Adriweb on September 07, 2015, 04:05:32 PM
You could do everything inside Lua variables, then only export them in Document/Basic vars when needed (see on.deactivate()). Also, on the other sides, monitor the variables (var.monitor).
How do you do this? How do you store stuff into document/basic vars?
281
Ok. I will make everything local and prerender rotations with a few degrees of precision.

Should I store all of my save data in one document variable then, as a matrix/array and remove all the others, cause I was just using them for saves and so that I could display the game stats on the other tab easily. That is because there doesnt seem to be enough space to comfortably do it on the main game page, so I have to do it in a separate tab.

Is there any way to have non flash/ROM variables to transfer between separate tabs, because that would be very helpful.

By the way for the math functions in this game I will not use them a lot but in future games I plan to. Also what do you mean by localizing the math functions, and do you have any idea why does my quick sine function always return nil?

Btw, what does the local modifier do when a variable is in the global scope anyways?
282
I guess I could just make the canonballs outlines instead of images, since there is a draw arc function and I could just make the angle 360 degrees. Its just that in the original game the cannonball texture can change, which I think would be easier to do with just having images for the cannonball. Also, I am quite surprised at just how slow the calculator is. My code is not extensive whatsoever, and it already lags. The cannonballs move choppilly, as opposed to on the computer emulator. I thought that this calc had a 132 mhz ARM, or is that not fast enough? Also what is wierd is that the performance between many cannonballs on the screen and just one doesnt really change, except when there are a lot of cannonballs on the screen. Btw, the image I uploaded was from the emulator, and there the cannonball looks fine, and the code doesn't lag. It has the other issues though.

Furthermore, could you contact or give me a way to contact one of the people that you mentioned who have used the ti nspire, as I barely know it, since I just got it.
283
I recently learned some of the ti nspire lua language, so I decided to make a learn to fly idle game. Most of the begining progress is done, but the program has some problems with it.

First off, the cannonballs on the calc look bad, as opposed to on the computer. Second off, some of my variables don't save properly. Third off, a quick sine(which is just a list of sine values in an array that I generated with c) function I made just cause why not doesnt work. The third one has about zero priority because it is completely unessesary, but I was just wondering. Fourth off, after I fixed the auto fire, since it was partially linked to shots per click, it completely started being wierd. The adder for the auto shots and shots per click is completely wierded out

Also I was wondering if anyone would like to collab on this project with me, so as to make it look better. BTW the program only works in handheld view.

Attached, once approved, is the game and a screenshot.
Powered by EzPortal