[plt-scheme] Programing problems (without attachments)

From: CHAMLY (marc.chamly at gmail.com)
Date: Wed Mar 4 20:50:18 EST 2009

--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,&nbsp;<div><br></div><div>I =
am a french IT&nbsp;student, and I have been working on scheme since =
september. I am working on a project with Two other&nbsp;colleagues. Our =
projects is to remake a game called Copter , but our way, adding a few =
things to give it a bit action. (-->&nbsp;<a =
href=3D"http://www.albinoblacksheep.com/flash/copter)">http://www.albinobl=
acksheep.com/flash/copter)</a>.</div><div><br></div><div>Therefor&nbsp;, =
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>&nbsp;... etc &nbsp;And we would like to add the =
Copter image to it. Should we use&nbsp;</div><div>bitmap% ? Thank =
you.</div><div>Second of all, In our&nbsp;program&nbsp;&nbsp;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)&nbsp;</font></div><div><font class=3D"Apple-style-span" =
color=3D"#585DFF">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; =
&nbsp; &nbsp; &nbsp;</font></div><div><font class=3D"Apple-style-span" =
color=3D"#585DFF">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; =
&nbsp; &nbsp; &nbsp;(style '(hscroll))&nbsp;</font></div><div><font =
class=3D"Apple-style-span" color=3D"#585DFF">&nbsp;&nbsp; &nbsp; &nbsp; =
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</font></div><div><font =
class=3D"Apple-style-span" color=3D"#585DFF">&nbsp;&nbsp; &nbsp; &nbsp; =
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</font></div><div><font =
class=3D"Apple-style-span" color=3D"#585DFF">&nbsp;&nbsp; &nbsp; &nbsp; =
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;(paint-callback (lambda =
(obj dc)&nbsp;</font></div><div><font class=3D"Apple-style-span" =
color=3D"#585DFF">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; =
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; =
&nbsp; &nbsp;(niveau dc))</font></div><div><font =
class=3D"Apple-style-span" color=3D"#585DFF">&nbsp;&nbsp; &nbsp; &nbsp; =
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; =
&nbsp; &nbsp; &nbsp; &nbsp; =
&nbsp;)))</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">&nbsp;&nbsp;(let ((a =
0)</font></div><div><font class=3D"Apple-style-span" =
color=3D"#3648FF">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;(b =
1)</font></div><div><font class=3D"Apple-style-span" =
color=3D"#3648FF">&nbsp;&nbsp; &nbsp; =
&nbsp;&nbsp;</font></div><div><font class=3D"Apple-style-span" =
color=3D"#3648FF">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;(crayon (make-object =
pen% "BLACK" 1 'solid))</font></div><div><font class=3D"Apple-style-span" =
color=3D"#3648FF">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;( x (X 10)) &nbsp; =
&nbsp;&nbsp;</font></div><div><font class=3D"Apple-style-span" =
color=3D"#3648FF">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;(y (Y 10))) =
&nbsp;&nbsp;</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">&nbsp;&nbsp; &nbsp;(For i from 1 to =
4&nbsp;</font></div><div><font class=3D"Apple-style-span" =
color=3D"#3648FF">&nbsp;&nbsp; &nbsp; &nbsp; =
&nbsp;</font></div><div><font class=3D"Apple-style-span" =
color=3D"#3648FF">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (send dc =
set-pen crayon)&nbsp;</font></div><div><font class=3D"Apple-style-span" =
color=3D"#3648FF">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (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">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (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">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (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">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (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">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (set! a (+ =
300 a))</font></div><div><font class=3D"Apple-style-span" =
color=3D"#3648FF">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (set! b (+ 1 =
b))</font></div><div><font class=3D"Apple-style-span" =
color=3D"#3648FF">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; =
&nbsp;)))</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">&nbsp;&nbsp;</font></div><div><font =
class=3D"Apple-style-span" =
color=3D"#3648FF">&nbsp;&nbsp;</font></div><div><font =
class=3D"Apple-style-span" color=3D"#3648FF">&nbsp;&nbsp;(if (=3D c =
1)</font></div><div><font class=3D"Apple-style-span" =
color=3D"#3648FF">&nbsp;&nbsp; &nbsp; &nbsp;(set! c =
0)</font></div><div><font class=3D"Apple-style-span" =
color=3D"#3648FF">&nbsp;&nbsp; &nbsp; &nbsp;(begin (send canvas =
init-auto-scrollbars &nbsp;2000 #f &nbsp;c =
0)&nbsp;</font></div><div><font class=3D"Apple-style-span" =
color=3D"#3648FF">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (set! =
c (+ c 0.001))</font></div><div><font class=3D"Apple-style-span" =
color=3D"#3648FF">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (send =
canvas show-scrollbars #f #f)</font></div><div><font =
class=3D"Apple-style-span" color=3D"#3648FF">&nbsp;&nbsp; &nbsp; &nbsp; =
&nbsp; &nbsp; &nbsp;&nbsp;</font></div><div><font =
class=3D"Apple-style-span" color=3D"#3648FF">&nbsp;&nbsp; &nbsp; &nbsp; =
&nbsp; &nbsp; &nbsp; (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&nbsp;each&nbsp;time we =
call the Timer, our 'for' loop keeps, recreating the lines of our =
level,&nbsp;</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.&nbsp;</div><div><br></div><div>Sincerely.<br></div></div></body>=
</html>=

--Apple-Mail-2-69059469--


Posted on the users mailing list.