Jump to content
  • Advertisement
Sign in to follow this  
Alpha_ProgDes

Is this good Scheme code?

This topic is 2533 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

[Scheme]
[Functional]


(define BOARDWIDTH 200)
(define BOARDHEIGHT 400)
(define STARTPOSITION 50)
(define ROCKET .)
(define UFO (overlay (circle 10 "solid" "red")
(rectangle 40 4 "solid" "green")))
(define (SPACESHIP option)
(cond
[(= option 1) ROCKET]
[(= option 2) UFO]))
(define SHOWNSHIP (SPACESHIP 2))
(define BOARDBKGR "blue")
(define SPACESHIP-BOTTOM (- BOARDHEIGHT (/ (image-height SHOWNSHIP) 2)))
(define (render-shownship x y)
(place-image SHOWNSHIP
x
y
(empty-scene BOARDWIDTH BOARDHEIGHT BOARDBKGR)))
(define (create-rocket-scene.v4 height)
(cond
[(<= height SPACESHIP-BOTTOM) (render-shownship STARTPOSITION height)]
[(> height SPACESHIP-BOTTOM) (render-shownship STARTPOSITION SPACESHIP-BOTTOM)]))


Would this be considered "good" Scheme code? I'm using the HTDP book (Chapter 1) and it looks good to me but I didn't know if this would be considered "n00b" code or if this is "good" Scheme code. IOW, would a practiced Scheme coder write his code like I did?

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!