So, I've started hacking Hey Taxi into Tcl. I worked on it about 5 minutes last night, and in less than a half hour this morning, I've got a pretty fun framework. Here's a screen shot:
I've bound up arrow to -10 Y acceleration. If you go below 0, you move up properly. Not sure how much I'll need to add to keep it fun... I think I at least want X thrust.
Update: I added X thrust.
Source for heytaxi.tcl
set ::gravX 0
set ::gravY 1
set ::velX 1
set ::velY 1
set ::taxiID 0
proc eventLoop {} {
if {$::taxiID == 0} { return }
incr ::velX $::gravX
incr ::velY $::gravY
set coord [.c coords 1]
if {$::velY < 0 || [lindex $coord 3] < [.c cget -height]} {
.c move $::taxiID $::velX $::velY
}
after 1000 eventLoop
}
proc thrustUp {} {
incr ::velY -10
}
proc thrustLt {} {
incr ::velX -5
}
proc thrustRt {} {
incr ::velX 5
}
pack [frame .fVel] -side top
pack [label .fVel.lLX -text "X Velocity:"] -side left
pack [label .fVel.lVX -textvariable velX] -side left
pack [label .fVel.lVY -textvariable velY] -side right
pack [label .fVel.lLY -text "Y Velocity:"] -side right
pack [canvas .c] -side top
set ::taxiID [.c create rectangle 10 10 20 20 -fill yellow]
bind . <keypress-up> thrustUp
bind . <keypress-left> thrustLt
bind . <keypress-right> thrustRt
after 1 eventLoop
No comments:
Post a Comment