[plt-scheme] Programing problems (without attachments)
--Apple-Mail-2-69059469
Content-Type: text/plain;
charset=US-ASCII;
format=flowed;
delsp=yes
Content-Transfer-Encoding: 7bit
Hi,
I am a french IT student, and I have been working on scheme since
september. I am working on a project with Two other colleagues. Our
projects is to remake a game called Copter , but our way, adding a few
things to give it a bit action. (--> http://www.albinoblacksheep.com/flash/copter)
.
Therefor , we have two main problems, that we would like some help in.
First of all, we created a new canvas using
(define canvas (new canvas% (parent FRAME) ... etc And we would like
to add the Copter image to it. Should we use
bitmap% ? Thank you.
Second of all, In our program the Copter just goes Up and Down, and
The canvas moves with a random level advance.
To creat Our level, we call (niveau dc) our level editor, in our canvas.
CANVAS :
(define canvas (new canvas% (parent FRAME)
(style '(hscroll))
(paint-callback (lambda (obj dc)
(niveau dc))
)))
Our level editor is :
(define (niveau dc)
(let ((a 0)
(b 1)
(crayon (make-object pen% "BLACK" 1 'solid))
( x (X 10))
(y (Y 10)))
(For i from 1 to 4
(send dc set-pen crayon)
(send dc draw-line a (vector-ref y b) (+ a (vector-ref x
b)) 0)
(send dc draw-line (+ a (vector-ref x b)) 0 (+ a 300)
(vector-ref y (+ b 1)))
(send dc draw-line a (- 300 (vector-ref y b)) (+ a (vector-
ref x b)) 300)
(send dc draw-line (+ a (vector-ref x b)) 300 (+ a 300) (-
300 (vector-ref y (+ b 1))))
(set! a (+ 300 a))
(set! b (+ 1 b))
)))
In order to move our canvas, we use:
(define c 0)
(define (move-niveau)
(if (= c 1)
(set! c 0)
(begin (send canvas init-auto-scrollbars 2000 #f c 0)
(set! c (+ c 0.001))
(send canvas show-scrollbars #f #f)
(send canvas refresh))))
But each time we call the Timer, our 'for' loop keeps, recreating the
lines of our level,
(define TIMER (new timer% (notify-callback move-niveau)))
How can we make the canvas advance with-out touching our 'for' Loop in
(niveau dc)?
Thank you for your time, and sorry for any possible english mistakes.
Sincerely.
--Apple-Mail-2-69059469
Content-Type: text/html;
charset=US-ASCII
Content-Transfer-Encoding: quoted-printable
<html><body style=3D"word-wrap: break-word; -webkit-nbsp-mode: space; =
-webkit-line-break: after-white-space; ">Hi, <div><br></div><div>I =
am a french IT student, and I have been working on scheme since =
september. I am working on a project with Two other colleagues. Our =
projects is to remake a game called Copter , but our way, adding a few =
things to give it a bit action. (--> <a =
href=3D"http://www.albinoblacksheep.com/flash/copter)">http://www.albinobl=
acksheep.com/flash/copter)</a>.</div><div><br></div><div>Therefor , =
we have two main problems, that we would like some help in. First of =
all, we created a new canvas using</div><div><font =
class=3D"Apple-style-span" color=3D"#3648FF">(define canvas (new canvas% =
(parent FRAME)</font> ... etc And we would like to add the =
Copter image to it. Should we use </div><div>bitmap% ? Thank =
you.</div><div>Second of all, In our program the Copter =
just goes Up and Down, and The canvas moves with a random level =
advance.</div><div><br></div><div>To creat Our level, we call (niveau =
dc) our level editor, in our canvas.</div><div><br></div><div><font =
class=3D"Apple-style-span" color=3D"#FF1016">CANVAS =
:</font></div><div><div><font class=3D"Apple-style-span" =
color=3D"#585DFF">(define canvas (new canvas% (parent =
FRAME) </font></div><div><font class=3D"Apple-style-span" =
color=3D"#585DFF"> =
</font></div><div><font class=3D"Apple-style-span" =
color=3D"#585DFF"> =
(style '(hscroll)) </font></div><div><font =
class=3D"Apple-style-span" color=3D"#585DFF"> =
</font></div><div><font =
class=3D"Apple-style-span" color=3D"#585DFF"> =
</font></div><div><font =
class=3D"Apple-style-span" color=3D"#585DFF"> =
(paint-callback (lambda =
(obj dc) </font></div><div><font class=3D"Apple-style-span" =
color=3D"#585DFF"> =
=
(niveau dc))</font></div><div><font =
class=3D"Apple-style-span" color=3D"#585DFF"> =
=
=
)))</font></div><div><br></div></div><div><div><font =
class=3D"Apple-style-span" color=3D"#FF1013">Our level editor is =
:</font></div><div><br></div><div><div><font class=3D"Apple-style-span" =
color=3D"#3648FF">(define (niveau dc)</font></div><div><font =
class=3D"Apple-style-span" color=3D"#3648FF"> (let ((a =
0)</font></div><div><font class=3D"Apple-style-span" =
color=3D"#3648FF"> (b =
1)</font></div><div><font class=3D"Apple-style-span" =
color=3D"#3648FF"> =
</font></div><div><font class=3D"Apple-style-span" =
color=3D"#3648FF"> (crayon (make-object =
pen% "BLACK" 1 'solid))</font></div><div><font class=3D"Apple-style-span" =
color=3D"#3648FF"> ( x (X 10)) =
</font></div><div><font class=3D"Apple-style-span" =
color=3D"#3648FF"> (y (Y 10))) =
</font></div><div><font class=3D"Apple-style-span" =
color=3D"#3648FF"><br></font></div><div><font class=3D"Apple-style-span" =
color=3D"#3648FF"> (For i from 1 to =
4 </font></div><div><font class=3D"Apple-style-span" =
color=3D"#3648FF"> =
</font></div><div><font class=3D"Apple-style-span" =
color=3D"#3648FF"> (send dc =
set-pen crayon) </font></div><div><font class=3D"Apple-style-span" =
color=3D"#3648FF"> (send dc =
draw-line a (vector-ref y b) (+ a (vector-ref x b)) =
0)</font></div><div><font class=3D"Apple-style-span" =
color=3D"#3648FF"> (send dc =
draw-line (+ a (vector-ref x b)) 0 (+ a 300) (vector-ref y (+ b =
1)))</font></div><div><font class=3D"Apple-style-span" =
color=3D"#3648FF"> (send dc =
draw-line a (- 300 (vector-ref y b)) (+ a (vector-ref x b)) =
300)</font></div><div><font class=3D"Apple-style-span" =
color=3D"#3648FF"> (send dc =
draw-line (+ a (vector-ref x b)) 300 (+ a 300) (- 300 (vector-ref y (+ b =
1))))</font></div><div><font class=3D"Apple-style-span" =
color=3D"#3648FF"> (set! a (+ =
300 a))</font></div><div><font class=3D"Apple-style-span" =
color=3D"#3648FF"> (set! b (+ 1 =
b))</font></div><div><font class=3D"Apple-style-span" =
color=3D"#3648FF"> =
)))</font></div><div><br></div></div><div><br></div><div><font =
class=3D"Apple-style-span" color=3D"#FF1013">In order to move our =
canvas, we use:</font></div><div><br></div><div><div><font =
class=3D"Apple-style-span" color=3D"#3648FF">(define c =
0)</font></div><div><font class=3D"Apple-style-span" =
color=3D"#3648FF">(define (move-niveau)</font></div><div><font =
class=3D"Apple-style-span" =
color=3D"#3648FF"> </font></div><div><font =
class=3D"Apple-style-span" =
color=3D"#3648FF"> </font></div><div><font =
class=3D"Apple-style-span" color=3D"#3648FF"> (if (=3D c =
1)</font></div><div><font class=3D"Apple-style-span" =
color=3D"#3648FF"> (set! c =
0)</font></div><div><font class=3D"Apple-style-span" =
color=3D"#3648FF"> (begin (send canvas =
init-auto-scrollbars 2000 #f c =
0) </font></div><div><font class=3D"Apple-style-span" =
color=3D"#3648FF"> (set! =
c (+ c 0.001))</font></div><div><font class=3D"Apple-style-span" =
color=3D"#3648FF"> (send =
canvas show-scrollbars #f #f)</font></div><div><font =
class=3D"Apple-style-span" color=3D"#3648FF"> =
</font></div><div><font =
class=3D"Apple-style-span" color=3D"#3648FF"> =
(send canvas refresh))))</font></div><div><font =
class=3D"Apple-style-span" =
color=3D"#3648FF"><br></font></div></div><div><font =
class=3D"Apple-style-span" color=3D"#FF1013">But each time we =
call the Timer, our 'for' loop keeps, recreating the lines of our =
level, </font></div><div><font class=3D"Apple-style-span" =
color=3D"#FF1013"><br></font></div><div><font class=3D"Apple-style-span" =
color=3D"#3648FF">(define TIMER (new timer% (notify-callback =
move-niveau)))</font></div><div><br></div><div>How can we make the =
canvas advance with-out touching our 'for' Loop in (niveau =
dc)?</div><div><br></div><div>Thank you for your time, and sorry for any =
possible english =
mistakes. </div><div><br></div><div>Sincerely.<br></div></div></body>=
</html>=
--Apple-Mail-2-69059469--