1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- using System;
- using System.Collections.Generic;
- using System.Text;
- using Lisp;
- namespace Cobble {
- public class Background {
- public string image;
- public float speed;
- public Background(Parser parser) {
- int d = parser.Depth;
- while (parser.Parse() && parser.Depth >= d) {
- if (parser.Depth == d + 1) {
- if (parser.Type != Parser.LispType.SYMBOL)
- throw new Exception("expected SYMBOL");
- string symbol = parser.SymbolValue;
- parser.Parse();
- switch (symbol) {
- case "image":
- this.image = parser.StringValue;
- break;
- case "speed":
- this.speed = parser.FloatValue;
- break;
- default:
- throw new Exception("Unexpected entry in background list: " + parser.SymbolValue);
- }
- }
- }
- }
- public Background(string image, float speed) {
- this.image = image;
- this.speed = speed;
- }
- public void Write(LispWriter writer) {
- writer.StartList("background");
- writer.Write("image", this.image);
- writer.Write("speed", this.speed);
- writer.EndList("background");
- }
- }
- }
|