all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Randomise spawning apples in snake.el
@ 2009-05-07 19:57 Stuart Hacking
  2009-05-08  0:57 ` Stefan Monnier
  2009-08-19 20:05 ` Stefan Monnier
  0 siblings, 2 replies; 3+ messages in thread
From: Stuart Hacking @ 2009-05-07 19:57 UTC (permalink / raw)
  To: emacs-devel


[-- Attachment #1.1: Type: text/plain, Size: 716 bytes --]

Hi,

This is my first quick modification to emacs.  I hope I've produced  
the .diff correctly, if not, please yell at me for not correctly  
reading the submission guidelines. (Also: I apologise if this is not  
the correct place to submit patches - I didn't see anything about code  
submission on savannah. Please advise if necessary.)

The modification changes snake.el so that new apples will be spawned  
at random locations rather than being deposited behind the snake.  I  
intended to govern the spawn rate based on score, however, since the  
game speed increases I decided this was unnecessary.

Hope this provides enjoyment for someone - now onto bigger and better  
things! :-)

Kindest Regards
Stuart


[-- Attachment #1.2: snake_rand_apples.el.diff --]
[-- Type: application/octet-stream, Size: 770 bytes --]

Index: lisp/play/snake.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/play/snake.el,v
retrieving revision 1.24
diff -r1.24 snake.el
149a150
> (defvar spawn-rate 10)
169a171
> (make-variable-buffer-local 'spawn-rate)
242a245
> 	spawn-rate              10
280,282c283,285
< 				    (if (= (% snake-cycle 5) 0)
< 					snake-dot
< 				      snake-blank))
---
>                             snake-blank)
>          (if (= (% snake-cycle spawn-rate) 0)
>              (snake-put-dot))
289a293,298
> (defun snake-put-dot ()
>   (let ((x (1+ (random (- snake-width 2))))
>         (y (1+ (random (- snake-height 2)))))
>     (if (= (gamegrid-get-cell x y) snake-blank)
>         (gamegrid-set-cell x y snake-dot))))
> 

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 186 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2009-08-19 20:05 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-05-07 19:57 Randomise spawning apples in snake.el Stuart Hacking
2009-05-08  0:57 ` Stefan Monnier
2009-08-19 20:05 ` Stefan Monnier

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.