Skip to content

Commit

Permalink
Fix camera code, fix leaderboard
Browse files Browse the repository at this point in the history
  • Loading branch information
Mutant Savior committed Aug 7, 2012
1 parent 4eaf7d7 commit 8e61e29
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 12 deletions.
5 changes: 3 additions & 2 deletions leaderboard/data/leaderboard.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
NOOB,2400,NOOB_2400.gif
NOOB,3700,NOOB_3700.gif
ZUL,77475,ZUL_77475.gif
IMP,58500,IMP_58500.gif
BBB,29450,BBB_29450.gif
B ,15700,B_15700.gif
COK,23200,COK_23200.gif
ABA,15625,ABA_15625.gif
BBB,15300,BBB_15300.gif
AME,13600,AME_13600.gif
CAK,12950,CAK_12950.gif
B ,11200,B_11200.gif
B ,10700,B_10700.gif
Expand Down
7 changes: 5 additions & 2 deletions leaderboard/leaderboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ function parseDataFile(fileContent){
}
}
leaders.sort(function(a,b){ return b['score'] - a['score'] });
leaders = leaders.slice(0, 20, leaders);
// leaders = leaders.slice(0, 20, leaders);
currentLeader = $.inArray(current, leaders);
//alert('last updated leader is in slot ' + currentLeader);
showCurrentEntry();
Expand Down Expand Up @@ -92,6 +92,8 @@ function rotateBorderPallette(){

function nextColorForId(itemId){
currentColor = $(itemId).css('border-color');
if (currentColor == "")
currentColor = $(itemId).css('border-left-color');
next = nextColor(currentColor);
$(itemId).css('border-color', next);
}
Expand All @@ -102,9 +104,10 @@ function nextColor(current){
if(nextIndex >= colors.length){
nextIndex = 0;
}

if(colors[i] == current){
return colors[nextIndex];
}
}
return colors[0];
return "nathan";
}
17 changes: 11 additions & 6 deletions mcor-dispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ def parse_scoreboard(msg):
return False

# We should save each death face to last_death.gif
capture_handle = cv.CaptureFromCAM(-1)
capture_handle = None
capture_images = []
last_capture = None
capturing = False
Expand All @@ -192,19 +192,24 @@ def capture_if_needed():
return
if ((last_capture != None) and (time.time() - last_capture < capture_delay)):
return
frame = cv.QueryFrame(capture)
frame = cv.QueryFrame(capture_handle)
mat = cv.GetMat(frame)
a = np.asarray(mat[:,:])
images.append(np.copy(a))
if (len(images) > num_photo_frames):
del images[0]
capture_images.append(np.copy(a))
if (len(capture_images) > num_photo_frames):
del capture_images[0]

def start_capture():
global capturing
global capture_handle
if (capture_handle == None):
capture_handle = cv.CaptureFromCAM(-1)
capturing = True
capture_if_needed()
print "Capture started."

def stop_capture():
global capturing
capturing = False
last_capture = None
print "Capture ended."
Expand All @@ -213,7 +218,7 @@ def save_player_face():
print "Saving deathface"
leaderboard_photocapture = os.path.join(leaderboard_dir, "photo_capture")
face_path = os.path.join(leaderboard_photocapture, "deathface" + scores_extension)
images2gif.writeGif(face_path, images, duration=0.5, dither=0)
images2gif.writeGif(face_path, capture_images, duration=0.5, dither=0)

dump_hex = lambda x: " ".join([hex(ord(c))[2:].zfill(2) for c in x])

Expand Down
4 changes: 2 additions & 2 deletions send_udp.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
import select
import socket

UDP_IP = "192.168.0.65"
UDP_PORT = 2084
UDP_IP = ""
UDP_PORT = 20666

MESSAGE = sys.argv[1]

Expand Down

0 comments on commit 8e61e29

Please sign in to comment.