Permalink
Browse files

Teams o/ player infos o/

  • Loading branch information...
1 parent c306434 commit 5f8b97d8528cfa864ca5455dfe1e20b3f0448f24 nddrylliog committed Jun 20, 2010
Showing with 284 additions and 44 deletions.
  1. +6 −3 default.bam
  2. +11 −0 ooc-ai/AI.ooc
  3. +33 −8 ooc-ai/Canvas.ooc
  4. +52 −3 ooc-ai/Grid.ooc
  5. +172 −24 ooc-ai/Ndd2AI.ooc
  6. +5 −5 ooc-ai/NddAI.ooc
  7. +1 −1 ooc-ai/ooc-ai.ooc
  8. +2 −0 src/game/client/components/controls.cpp
  9. +2 −0 src/game/client/gameclient.hpp
View
@@ -157,9 +157,12 @@ function build(settings)
-- ooc AI !
settings.link.flags:Add("ooc-ai/.libs/ooc-ai-linux32.a")
settings.link.flags:Add("ooc-ai/.libs/sdk-linux32.a")
- -- settings.link.flags:Add("ooc-ai/.libs/ooc-cairo-linux32.a")
- -- settings.link.flags:Add("ooc-ai/.libs/ooc-gdk-linux32.a")
- -- settings.link.flags:Add("ooc-ai/.libs/gtk-vcs-danopia-linux32.a")
+ settings.link.flags:Add("ooc-ai/.libs/ooc-cairo-linux32.a")
+ settings.link.flags:Add("ooc-ai/.libs/ooc-gdk-linux32.a")
+ settings.link.flags:Add("ooc-ai/.libs/gtk-vcs-danopia-linux32.a")
+ settings.link.flags:Add("-lgtk-x11-2.0")
+ settings.link.flags:Add("-lgdk-x11-2.0")
+ settings.link.flags:Add("-lcairo")
settings.link.flags:Add("ooc-ai/libs/libgc.a")
settings.cc.includes:Add("ooc-ai/.libs/")
settings.cc.includes:Add("ooc-ai/.libs/ooc-ai/")
View
@@ -19,6 +19,17 @@ GameInfo: cover {
numChars: Int
chars: Vector2*
+ numPlayers: Int
+ playerInfos: PlayerInfo**
+}
+
+PlayerInfo: cover {
+ local: Int
+ cid: Int
+ team: Int
+ score: Int
+ latency: Int
+ latencyFlux: Int
}
/**
View
@@ -1,52 +1,77 @@
-/*
use cairo, gtk
import cairo/[Cairo, GdkCairo]
import gtk/[Gtk, Widget, Window]
+import structs/ArrayList
+import Grid
Canvas: class {
cr: GdkContext
win: Window
+ grid: Grid
+ paints := ArrayList<Func (Context)> new()
+
+ repaintCount := 0
init: func (width, height: Int) {
win = Window new("Hai.")
win setUSize(width, height) //.connect("delete_event", exit)
win setAppPaintable(true)
- win connect("expose-event", onExpose as Func)
+
+ win connect("expose-event", func (widget: Widget) {
+ this onExpose(widget)
+ })
win showAll()
//Gtk main()
}
+
+ addPaint: func (f: Func (Context)) {
+ paints add(f)
+ }
update: func {
+ if(repaintCount >= 0) {
+ win queueDraw()
+ repaintCount = 8
+ } else {
+ repaintCount -= 1
+ }
while(Gtk eventsPending()) {
Gtk mainIteration()
}
}
- onExpose: func (widget: Widget, event, userData: Pointer) -> Bool {
+ onExpose: func (widget: Widget) -> Bool {
// expose event is sent when the widget (or parts of it) needs to be redrawn.
// we repaint everything then.
- cr = GdkContext new(widget getWindow())
- repaint(cr)
+ cr = GdkContext new(widget getWindow())
+ repaint(cr)
cr destroy()
return true
}
repaint: func (cr: Context) {
+
// code from test.ooc!
- cr setSourceRGB(0, 0, 0)
+
+ cr setSourceRGB(0, 0, 0)
cr paint()
+ for(paint in paints) {
+ paint(cr)
+ }
+
+ /*
cr setLineWidth(15)
cr setSourceRGB(255, 0, 0)
cr moveTo(0, -100)
cr lineTo(100, 100)
cr relLineTo(-200, 0)
cr closePath()
cr stroke()
+ */
}
-}
-*/
+}
View
@@ -1,5 +1,8 @@
import Vector2, structs/ArrayList, math
+use cairo
+import cairo/[Cairo, GdkCairo]
+
Block: cover from Int
Blocks: class {
@@ -28,6 +31,53 @@ Grid: class {
}
}
+ paint: func (cr: Context) {
+ cr scale(1024.0 / width as Float, 768.0 / height as Float)
+
+ cr setLineWidth(4)
+ cr setSourceRGB(255, 0, 0)
+
+ cr moveTo(0, 0)
+ cr lineTo(width, 0)
+ cr lineTo(width, height)
+ cr lineTo(0, height)
+ cr lineTo(0, 0)
+
+ cr closePath()
+ cr stroke()
+
+ cr setSourceRGB(0.8, 0.8, 0.8)
+ for(y in 0..height) {
+ for(x in 0..width) {
+ if(get(x, y) == Blocks EMPTY) {
+ cr rectangle(x - 1, y - 1, 2, 2)
+ }
+ }
+ }
+ cr fill()
+
+ cr setSourceRGB(0.0, 0.5, 0.0)
+ for(y in 0..height) {
+ for(x in 0..width) {
+ if(get(x, y) == Blocks GROUND) {
+ cr rectangle(x - 1, y - 1, 2, 2)
+ }
+ }
+ }
+ cr fill()
+
+ cr setSourceRGB(1.0, 1.0, 0.0)
+ for(y in 0..height) {
+ for(x in 0..width) {
+ if(get(x, y) == Blocks DEADEND) {
+ cr rectangle(x - 2, y - 2, 4, 4)
+ }
+ }
+ }
+ cr fill()
+
+ }
+
print: func (playerx, playery: Int) {
for(x in 0..(width / 2 + 2)) {
@@ -53,7 +103,6 @@ Grid: class {
case Blocks GROUND => "_"
case Blocks CEIL => "~"
case Blocks FALL => "v"
- case Blocks UNKNOWN => "?"
case => " "
})
}
@@ -97,13 +146,13 @@ Grid: class {
ground: func (x, y: Int) {
set(x, y, Blocks GROUND)
set(x - 1, y, Blocks GROUND)
- set(y - 1, y, Blocks GROUND)
+ set(x + 1, y, Blocks GROUND)
}
ceil: func (x, y: Int) {
set(x, y, Blocks CEIL)
set(x - 1, y, Blocks CEIL)
- set(y - 1, y, Blocks CEIL)
+ set(x + 1, y, Blocks CEIL)
}
deadend: func (x, y: Int) {
Oops, something went wrong.

0 comments on commit 5f8b97d

Please sign in to comment.