Squeak
  links to this page:    
View this PageEdit this PageUploads to this PageHistory of this PageTop of the SwikiRecent ChangesSearch the SwikiHelp Guide
Star Wars like Scroller
Last updated at 12:12 pm UTC on 16 January 2006
Author: Bert Freudenberg:

| warp src dest |
	"Star wars like scrolling"
	warp _ (WarpBlt toForm: Display)
		cellSize: 1;
		sourceForm: Display;
		cellSize: 2;
		combinationRule: Form over.
	src _ {-200@-100. -50@100. 50@100. 200@-100}.
	dest _ 0@0 corner: 200@100.
	Display restoreAfter: [
		[Sensor anyButtonPressed] whileFalse:
			[warp copyQuad: src + Sensor cursorPoint
				toRect: dest]]

Here's a version with correct perspective rendering :-)
Hans-Martin Mosner

 | warp src dest step |
	"Star wars like scrolling"
	warp _ (WarpBlt toForm: Display)
		cellSize: 1;
		sourceForm: Display;
		cellSize: 2;
		combinationRule: Form over.
	step _ 5.
	Display restoreAfter: [
		[Sensor anyButtonPressed] whileFalse:
			[p := Sensor cursorPoint.
			Display deferUpdatesIn: (0@0 extent: 400@400) while: [
				5 to: 400-step by: step do: [:i |
					d1 _ 200.0/i.
					d2 _ 200.0/(i+step).
					src _ {
						-200@-400 * d1.
						-200@-400 * d2 - (0@1).
						200@-400 * d2 - (1@1).
						200@-400 * d1 - (1@0)}.
					dest _ (0@i extent: 400@step).
					warp copyQuad: src + p+ (0@200)
						toRect: dest]]]]