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.


Topics - cypressx1

Pages: [1]
1
Lua / This is my first lua game
« on: August 02, 2011, 08:25:53 am »
Since l don't have enough posts to upload the file,l'll upload the code ,if you're interested in it, you can try it.
Code: [lua]
Code: [Select]
x=0 T,F=0,0  b="" u=0 t=0
aa=math.random(1,10)
bb=math.random(1,10)   ab=aa+bb
ts=0.06 life=10 level="learner"
function on.charIn(char)
mm=timer.getMilliSecCounter()
ch=char
if x>130 then u=1 t=t+1 end
end

function loop()
if x>220 then x=0 t=0 u=0
aa=math.random(1,10)
bb=math.random(1,10)   ab=aa+bb
draw1,draw2=0,0
return loop() end end

draw=class()
function draw:paint(gc)
gc:setPen("thick","dotted")
gc:drawRect(60,150,200,50)

if draw1==1 then
gc:setColorRGB(180,180,180)
gc:fillRect(60,150,200,50)
if mm+90<timer.getMilliSecCounter()
then draw1=0 end
end
if draw2==1 then
gc:setColorRGB(20,20,20)
gc:fillRect(60,150,200,50)
if mm+90<timer.getMilliSecCounter()
then draw2=0 end
end
end

function judge()
if x>130 and x<200 and  ab>10 and u==1 then
   if ch=="6"  then b="true"  
   elseif ch~="6" and ch~="a" and ch~="b" and ch~="c" and ch~="d" and ch~="p" then b="false" end
end
if x>130 and x<200  and  ab<10 and u==1 then
   if ch=="4"  then b="true"  
   elseif ch~="4" and ch~="a" and ch~="b" and ch~="c" and ch~="d" and ch~="p" then b="false" end
end
if x>130  and x<200 and  ab==10 and u==1 then
   if ch=="5"  then b="true"  
   elseif ch~="5" and ch~="a" and ch~="b" and ch~="c" and ch~="d" and ch~="p" then b="false" end
end
--if u==0 and t==0 then b="false" t=1 end
if b=="true" and t==1 then
T=T+1 b="" u=0 draw1=1 end
if b=="false" and t==1 then
F=F+1 b="" u=0 draw2=1 end
end
function on.paint(gc)
draw:paint(gc)
gc:setColorRGB(0,0,0)
gc:setFont("sansserif","bi",30)
gc:drawString(aa.." + "..bb,110,x,"top")
--gc:setColorRGB(100,100,100)
--gc:drawString(aa.." + "..bb,110,x-30,"top")
gc:setFont("sansserif","bi",10)
gc:drawString("T: "..T.."  ".."F: "..F,0,15,"top")
gc:drawString("u: "..u,0,30,"top")
gc:drawString("t: "..t,0,45,"top")
gc:drawString("ab: "..ab,0,60,"top")
gc:drawString("x: "..x,0,75,"top")
gc:drawString("life: "..life,0,90,"top")
gc:drawString("level: "..level,0,105,"top")
if F>life then
highscore()
gc:fillRect(0,0,330,250)
gc:setColorRGB(255,255,255)
gc:setFont("sansserif","bi",30)
gc:drawString("You Lost",95,50,"top")
gc:setFont("sansserif","bi",15)
gc:drawString("your score: "..T,120,110,"top")
gc:drawString("highscore: "..var.recall("highscore"),120,130,"top")
gc:drawString("Press R to restart",170,180,"top")
if ch=="r" then x=300 T=0 F=0
return loop() end
end
timer.start(ts)
if ch=="p" then timer.stop() end
if ch=="a" then ts=0.05 life=8 level="easy" end
if ch=="b" then ts=0.04 life=6 level="medium"end
if ch=="c" then ts=0.03 life=5 level="hard" end
if ch=="d" then ts=0.02 life=3 level="extreme" end
end
function on.enterKey()
ch="xx"
timer.start(ts)
platform.window:invalidate()
end
function highscore()
if var.recall("highscore")==nil or T>var.recall("highscore")
then var.store("highscore",T)
end
var.monitor("highscore")
end

--[[function on.varChange(varlist)
  local highscore=var.recall("highscore")
 if not highscore then return -3 end
if type(highscore)~="number" then return -2 end
if highscore<0 then return -1 end
end]]

function on.timer()
local ss=0.45*T+3
if ss>15 then ss=15 end
x=x+(ss)
loop()
judge()
platform.window:invalidate()
end
And of course, l didn't finish it,if you have some good ideas,you can tell me.
[4]-----"<10"
[5]-----"=10"
[6]-----">10"
[a\b\c\d]------"change speed"
[p\enter]-------"pause\continue"  

2
Lua / How can l make it ?
« on: July 22, 2011, 07:11:59 am »
Code:(lua)
Code: [Select]
----------block1-------------
block1=class()
bw,bh=80,70
cc=20 ff=25     t1="start" t2="stop"
tp=0.02
st=1
n=1/2.5

-----st must =ff or ff≥st+1------
function block1:init()
end
function block1:set()
wbx,wby=platform.window:width(),platform.window:height()
bx=wbx/2-bw/2
by=wby/2-bh/2
end

function block1:setc1()
block1:set()
c1x,c1y,c1w,c1h=bx,by+bh/2-cc/2,bw,cc
end
function block1:setc2()
block1:set()
c2x,c2y,c2w,c2h=bx+bw/2-cc/2,by,cc,bh
end

function block1:paint(gc)
gc:setColorRGB(150,200,100)
block1:set()
gc:fillRect(bx,by,bw,bh)
-------c1------
gc:setColorRGB(0,0,0)
block1:setc1()
gc:fillRect(c1x,c1y,c1w,c1h)
-----c2-------
gc:setColorRGB(0,0,0)
block1:setc2()
gc:fillRect(c2x,c2y,c2w,c2h)
end
function block1:timer()
platform.window:invalidate()
end
--------mouse------
Mouse=class()
mx=0
my=0
function Mouse:init()
end
function Mouse:paint(gc)
gc:setFont("sansserif","i",10)
gc:drawString("MouseLocation : ( "..mx.." , "..my.." )",60,0,"top")
end
function on.mouseMove(x,y)
mx=x
my=y
end
function Mouse:send()
--Ox=mx
end
function Mouse:timer()
platform.window:invalidate()
end
--------------------------
--[[
function ST()
if B1x<140 or B1x>171
then st=1
elseif B1x>140 and B1x<171
then st=1
end end
--]]
-----------Steps----------
function step1()
  if B1x==c2x-ff  --and B2y==c1y
   then t1="start"
end
if B1x==c2x+ff
   then t1="stop"
return step2()
   end
--ST()
B1x=B1x+st
 B2y=B1y-(ff^2-(B1x-B2x)^2)^0.5
 --B2y=math.eval("round("..B2y..",0)")
end
 
function step2()
  if B1x==c2x+ff --and B2y==c1y
   then t2="start"
end
if B1x==c2x-ff
   then t2="stop" B1x=c2x-ff
--timer.stop()
return step1() 
 end
--ST()
B1x=B1x-st
 B2y=B1y+(ff^2-(B1x-B2x)^2)^0.5
--B2y=math.eval("round("..B2y..",0)")
end






B1=class()
block1:setc1()
 block1:setc2()
B1x,B1y,B2x,B2y=c2x-ff,c1y,c2x,c1y
function B1:paint(gc)
step1()
gc:fillArc(B1x,B1y,cc,cc,0,360)
gc:fillArc(B2x,B2y,cc,cc,0,360)
end
B2=class()
block1:setc1()
 block1:setc2()
function B2:paint(gc)
step2()
gc:fillArc(B1x,B1y,cc,cc,0,360)
gc:fillArc(B2x,B2y,cc,cc,0,360)
end



-----------------------
function on.paint(gc)
block1():paint(gc)
Mouse():paint(gc)
gc:setColorRGB(255,255,255)
if t1=="start" then
B1():paint(gc)
end
if t2=="start" then
B2():paint(gc)
end
gc:setColorRGB(0,0,0)
gc:setFont("sansserif","i",10)
gc:drawString(t1.." "..t2,0,0,"top")
gc:drawString("( "..B1x.." , "..B1y.." )",100,199)
gc:drawString(" ( "..B2x.." , "..B2y.." )",100,212)
d=((B1x-B2x)^2+(B1y-B2y)^2)^0.5
d=math.eval("iPart("..d..")")
gc:drawString(d..st,100,180)
-------o-------
--Mouse:send()
--l=math.eval("linsolve("..B1y.."=k*"..B1x.."+b and "..B2y.." =k*"..B2x.."+b,{k,b})")
Ox=(B2x*(1+n)-B1x)/n
Oy=(B2y*(1+n)-B1y)/n
gc:fillArc(Ox,Oy,cc,cc,0,360)
end


function on.timer()
timer.start(tp)
block1():timer()
Mouse():timer()
platform.window:invalidate()
end
on.timer()

l'm leaning the lua. l want to make a prgm to draw the oval. But l don't know how to draw the ball's locus on the screen.in addition, l also want to make the vertical ball move more smoothly? Please give me some ideas :)

3
Lua / what should l do if l want two speed? it doesn't work
« on: July 09, 2011, 07:40:13 am »
event1=class()
function event1:paint(gc)
   gc:drawString("XX",x1,y1)
timer.start(0.1)
end
function event1:timer()
   x1=x1+1
   y1=y1+1
platform.window.invalidate()
end

event2=class()
function event2:paint(gc)
   gc:drawString("XXX",x2,y2)
timer.start(1)
end
function event2:timer()
   x2=x2+1
   y2=y2+1
platform.window.invalidate()
end

function on.paint(gc)
 event1():paint(gc)
 event2():paint(gc)
end
function on.timer()
 event1():timer()
 event2():timer()
end


------you know, it doesn't work. what should l do?

4
Lua / setPen
« on: July 08, 2011, 09:00:20 am »
l'm learning lua now. l've learnt a lot such as on.timer(),class()...l found that lua is much much better than the Ti-Basic.but l still have plenty of questions ??? so where do we use the setPen ? and what can it do ? Can you give me some examples? Thanks a lot.. :)

5
Other / Can someone help ?My Ti connent software doesn't work ..T T
« on: June 05, 2011, 01:46:03 am »
l installed the TILP v1.15 witnout removing the Ti connect.But after l uninstalled the TILP ,l found my Ti connect didn't work.there's an error message.Maybe it says the Ti driver will not start ...l'm using a nspire. But l can't connect with the PC any longer. l'm worried.What can l do now?

Pages: [1]