1. sweemeng
  2. GtugGoSandbox

Commits

Chee Leong Chow  committed 7a0603f

Some updates I suppose.

  • Participants
  • Parent commits a64d48a
  • Branches default

Comments (0)

Files changed (5)

File mapgame/view.py

View file
         if user:
             auth_data["user"] = user.email()
             auth_data["link"] = users.create_logout_url("/")
+            
         else:
             auth_data["link"] = users.create_login_url("/")
 
         self.response.headers["Content-Type"] = "application/json"
         self.response.out.write(simplejson.dumps(auth_data))
 
+class Radar(webapp.RequestHandler):
+    def get(self):
+        user = users.get_current_user()
+        
+        
+

File mapgame/www/bk.html

View file
               draggable: false,
               flat: true
             });
-            
+           
           }
       
         return markers;

File mapgame/www/index.html

View file
   <body>
     <div id="header" class="container_12 clearfix">
       <div id="top" class="grid_12 alpha omega"></div>
-      <div id="panel" class="grid_12 alpha omega" style="display:none;">
+      <div id="panel" class="grid_12">
+        <div>
+        <a id="refresh" href="/refresh">
+          <button>refresh</button>
+        </a>
+        </div>
+      </div>
+      <style>
+        #logs p {margin-bottom:-5px;}
+      </style>
+      <div id="logs" class="grid_12" style="max-height:100px;overflow:scroll;">
+        
       </div>
     </div>
-      <div id="map">
-      </div>
-
-    <div id="content" class="container_12 clearfix">
-      <div id="control" class="grid_4 omega">
-        
-      </div>
+    <div id="map" style="width:940px;height:100%;margin-left:auto;margin-right:auto;">
+    </div>
+    <div id="infowin" style="display:none;">
+      <ul id="mob_info">
+        <li>name <span id="mob_name"></span></li>
+        <li>hp <span id="mob_hp">20</span></li>
+        <li>attack <span id="mob_attack">2</span></li>
+        <li>action <a id="mob_action" href="#">Attack!</a></li>
+      </ul>
     </div>
     <div id="footer" class="container_12 clearfix">
       footer

File mapgame/www/js/blank

View file
+var infowindow = null;
+
+$(document).ready(function () { initialize(); });
+
+function initialize() {
+
+    var centerMap = new google.maps.LatLng(39.828175, -98.5795);
+
+
+
+    var myOptions = {
+
+        zoom: 4,
+
+        center: centerMap,
+
+        mapTypeId: google.maps.MapTypeId.ROADMAP
+
+    }
+
+
+
+    var map = new google.maps.Map(document.getElementById("map"), myOptions);
+
+
+
+    setMarkers(map, sites);
+
+    infowindow = new google.maps.InfoWindow({
+
+        content: "loading..."
+
+    });
+
+}
+
+
+
+    var sites = [
+
+        ['Mount Evans', 39.58108, -105.63535, 4, 'This is Mount Evans.'],
+
+        ['Irving Homestead', 40.315939, -105.440630, 2, 'This is the Irving Homestead.'],
+
+        ['Badlands National Park', 43.785890, -101.90175, 1, 'This is Badlands National Park'],
+
+        ['Flatirons in the Spring', 39.99948, -105.28370, 3, 'These are the Flatirons in the spring.']
+
+    ];
+
+
+
+
+
+
+
+function setMarkers(map, markers) {
+
+
+
+    for (var i = 0; i < markers.length; i++) {
+
+        var sites = markers[i];
+
+        var siteLatLng = new google.maps.LatLng(sites[1], sites[2]);
+
+        var marker = new google.maps.Marker({
+
+            position: siteLatLng,
+
+            map: map,
+
+            title: sites[0],
+
+            zIndex: sites[3],
+
+            html: sites[4]
+
+        });
+
+
+
+        var contentString = "Some content";
+
+
+
+            
+
+
+
+        google.maps.event.addListener(marker, "click", function () {
+
+            alert(this.html);
+
+            infowindow.setContent(this.html);
+
+            infowindow.open(map, this);
+
+        });
+
+    }
+
+}
+

File mapgame/www/js/features.js

View file
+var infowindow = null;
+
+$(document).ready(function () {
+    checkLogin();
+    // checkUser();
+    var lat = 3.088;
+    var lng = 101.70;
+
+    if ($("#map").html() != '') {
+        $("#refresh button").text("enter realm");
+        logStuff("The portal is open.");
+    }
+
+    $("#refresh").click(function (e) {
+        e.preventDefault();
+        $("#refresh button").text("refresh");
+        logStuff("Waaarghhh!");
+        var latlng = new google.maps.LatLng(lat, lng);
+
+        var mapOptions = {
+            zoom: 8,
+            center: latlng,
+            mapTypeId: google.maps.MapTypeId.ROADMAP,
+            streetViewControl: false,
+        }
+
+        var map = new google.maps.Map(document.getElementById("map"),
+                                      mapOptions);
+
+        var marker = new google.maps.Marker({
+            position: latlng,
+            map: map,
+            title: 'me',
+            icon: 'http://google-maps-icons.googlecode.com/files/revolution.png',
+        });
+
+        generateEnemies(lat, lng, map);
+        infowindow = new google.maps.InfoWindow({content:'loading'});
+    });
+});
+
 var checkLogin = function () {
     $.ajax({
         type: "GET",
             if (data.user != null) {
                 $("<span id='user_email'/>").text(data.user).appendTo("div#top");
                 $("<a>logout</a>").attr("href", data.link).appendTo("div#top");
-                executePlan();
             } else {
                 $("<a>login</a>").attr("href", data.link).appendTo("div#top");
                 window.location = data.link;
     });
 }
 
-var executePlan = function () {
-    $("div#panel").show();
-    getMap();
+var checkUser = function () {
+    $.ajax({});
 }
 
-var getMap = function () {
-    var lat = 3.088;
-    var lng = 101.70;
-    var latlng = new google.maps.LatLng(lat, lng);
-    var mapOptions = {
-        zoom: 8,
-        center: latlng,
-        mapTypeId: google.maps.MapTypeId.ROADMAP,
-        streetViewControl: false,
-    };
-    var map = new google.maps.Map(document.getElementById("map"),
-                                  mapOptions);
-    var mgr = new MarkerManager(map, {trackMarkers: true,
-                                      maxZoom: 15});
-    var mgr2 = new MarkerManager(map, {trackMarkers: true,
-                                       maxZoom: 15});
-    var mylocation = null;
+var mobs = [['goblin', 20, 2],
+            ['butterfly', 50, 0.1]]
 
-    function array_to_markers(array) {
-        var markers = [];
-        for (var i=0; i<array.length; i++) {
-            var details = array[i];
-            markers[i] = new google.maps.Marker({
-                title: details.name,
-                position: new googl.map.LatLng(details.location[0],
-                                               details.location[1]),
-                clickable: false,
-                draggable: false,
-                flat: true,
+var generateEnemies = function (lat, lng, map) {
+    var enemy_count = Math.floor(Math.random() * 11);
+    for (var i=0; i<enemy_count; i++) {
+        var m = mobs[Math.floor((Math.random()*1))];
+        var h = $("#infowin");
+        h.find("#mob_name").html(m[0]);
+        h.find("#mob_hp").html(m[1]);
+        h.find("#mob_attack").html(m[2]);
+        var y = lat + Math.random();
+        var x = lng + Math.random();
+        var position = new google.maps.LatLng(y, x);
+        var mob = new google.maps.Marker({
+            position: position,
+            map: map,
+            title: m[0],
+            zIndex: i+1,
+            html: $("#infowin").html(),
+            icon: 'http://google-maps-icons.googlecode.com/files/zoo.png',
+        });
+
+        google.maps.event.addListener(mob, 'click', function () {
+            infowindow.setContent(this.html);
+            infowindow.open(map, this);
+            $("a#mob_action").bind("click", function(e) {
+                e.preventDefault();
+                var maub = $(this).parent().parent(); 
+                var hp = maub.find("#mob_hp");
+                hp.html(hp.html() - 2);
+                logStuff("perhaps I fought this beautiful beast");
             });
-        }
-        return markers;
+        });
     }
-
-    navigator.geolocation.getCurrentPosition(function (location) {
-        var latlng = new google.maps.LatLng(location.coords.latitude,
-                                            location.coords.longitude);
-        var loc = [{'name': 'My Location',
-                    'location': [location.coords.latitude,
-                                 location.coords.longitude]
-                   }];
-        if (!mylocation) {
-            var a = array_to_markers(loc);
-            google.maps.event.addListener(mgr, 'loaded', function () {
-                mgr.clearMarkers();
-                mgr.addMarkers(a, 0, 15);
-                mgr.refresh();
-            });
-        }
-        mylocation = latlng;
-    });
 }
 
-$(document).ready(function() {
-    checkLogin();
-});
+var logStuff = function (msg) {
+    var p = $("<p/>").html(msg);
+    p.appendTo($("div#logs"));
+    $("div#logs").scrollTop($("div#logs").height());
+}