diff --git a/gogame/color/color.go b/gogame/color/color.go deleted file mode 100644 index aa8d3f2..0000000 --- a/gogame/color/color.go +++ /dev/null @@ -1,36 +0,0 @@ -package color - -//import "github.com/veandco/go-sdl2/sdl" - - -type Color struct { - R uint32 - G uint32 - B uint32 - A uint32 -} - -func (c *Color) ToHex() int { - return int( c.A<< 24 | c.R << 16 | c.G << 8 | c.B ) -} - -func (c *Color) ToBytes() []byte { - bytes := make([]byte,4) - bytes[0] = byte(c.R) - bytes[1] = byte(c.G) - bytes[2] = byte(c.B) - bytes[3] = byte(c.A) - return bytes -} - -func (c *Color) RGBA() (r, g, b, a uint32) { - r = uint32(c.R) - r |= r << 8 - g = uint32(c.G) - g |= g << 8 - b = uint32(c.B) - b |= b << 8 - a = uint32(c.A) - a |= a << 8 - return -} diff --git a/gogame/color/color_test.go b/gogame/color/color_test.go deleted file mode 100644 index 1955d26..0000000 --- a/gogame/color/color_test.go +++ /dev/null @@ -1,14 +0,0 @@ -package color - -// > go test color.go color_test.go -v -// Or -// > go test -v -// to test all test files - -import "testing" - -func TestColor(t *testing.T) { - c := &Color{244,124,244,0} - t.Logf("%x", c.ToHex()) -} - diff --git a/gogame/display/display.go b/gogame/display/display.go deleted file mode 100644 index 77b7b6c..0000000 --- a/gogame/display/display.go +++ /dev/null @@ -1,63 +0,0 @@ -package display - -import ( - "github.com/veandco/go-sdl2/sdl" - "../../gogame" -) - -var Inited = false -var window *sdl.Window - -func AssertInited() { - if Inited == false { - panic("run gogame.DisplayInit first") - } -} - -func Init() bool { - sdl.Do(func() { - - if err := sdl.Init(sdl.INIT_EVERYTHING); err != nil { - panic(err) - } - - Inited = true - }) - - return Inited -} - - -func SetMode(w,h,flags,depth int32) *sdl.Surface { - var err error - var surface *sdl.Surface - AssertInited() - - sdl.Do(func() { - window, err = sdl.CreateWindow("gogame", sdl.WINDOWPOS_UNDEFINED, sdl.WINDOWPOS_UNDEFINED, - w, h, uint32( gogame.SHOWN | flags)) - - if err != nil { - panic(err) - } - - surface,err = window.GetSurface() - if err != nil { - panic(err) - } - }) - - return surface -} - -func Flip() { - sdl.Do(func() { - - if window != nil { - window.UpdateSurface() - } - }) -} - - - diff --git a/gogame/draw/consts.go b/gogame/draw/consts.go deleted file mode 100644 index e518398..0000000 --- a/gogame/draw/consts.go +++ /dev/null @@ -1,10 +0,0 @@ -package draw - - -const ( - LEFT_EDGE=0x1 - RIGHT_EDGE=0x2 - BOTTOM_EDGE=0x4 - TOP_EDGE=0x8 -) - diff --git a/gogame/draw/draw.go b/gogame/draw/draw.go deleted file mode 100644 index eaa65a7..0000000 --- a/gogame/draw/draw.go +++ /dev/null @@ -1,96 +0,0 @@ -package draw - -import ( -// "fmt" -// "math" - "github.com/veandco/go-sdl2/sdl" - "github.com/veandco/go-sdl2/gfx" - - "../color" - "../rect" -) - - -func _aa_render_region(image *sdl.Renderer, _rect *sdl.Rect, col color.Color, rad int) { - corners := rect.Inflate(_rect,-2*rad-1, -2*rad-1) - topleft := []int{ int(corners.X),int(corners.Y)} - topright := []int{int(corners.X+corners.W-1), int(corners.Y)} - bottomleft := []int{int(corners.X), int(corners.Y+corners.H-1)} - bottomright := []int{int(corners.X+corners.W -1), int(corners.Y+corners.H-1)} - - attributes :=[][]int{topleft, topright, bottomleft, bottomright } - - r,g,b,a := col.RGBA() - - image.SetDrawColor( uint8(r),uint8(g),uint8(b),uint8(a) ) - - - for i:=0; i< len(attributes);i++ { - x,y := attributes[i][0],attributes[i][1] - - gfx.AACircleRGBA(image,int32(x),int32(y),int32(rad),uint8(r),uint8(g),uint8(b),uint8(a)) - gfx.FilledCircleRGBA(image,int32(x),int32(y), int32(rad),uint8(r),uint8(g),uint8(b),uint8(a)) - } - - - r1 := rect.Inflate(_rect,-2*rad,0) - r2 := rect.Inflate(_rect,0,-2*rad) - - image.FillRect( &r1 ) // main body except four circles in corners - image.FillRect( &r2 ) // fix gap between circles of up and down vertical -} - -//alpha of color should be 255 -func AARoundRect(surf *sdl.Surface,_rect *sdl.Rect,col color.Color,rad,border int, inside color.Color) { - - image,_ := sdl.CreateSoftwareRenderer(surf) - - /* - image.SetDrawColor(233,100,200,0) - image.DrawLine(10,20,100,200) - */ - -// image.Clear() - _aa_render_region(image,_rect,col,rad) - if border > 0 { - rect.InflateIp(_rect,-2*border,-2*border) - _aa_render_region(image,_rect,inside,rad) - } - - //image.Present() -} - -func Point(surf *sdl.Surface, c color.Color, x,y int) { - pixels := surf.Pixels() - bytes_per_pixel := surf.BytesPerPixel() - - addr := y * int(surf.Pitch) + x*bytes_per_pixel // 1 2 3 4 - - color_bytes := c.ToBytes() - - surf.Lock() - - if bytes_per_pixel == 1 { - pixels[addr] = color_bytes[0] - } - - if bytes_per_pixel == 2 { - for i :=0; i < bytes_per_pixel; i++ { - pixels[addr+i] = color_bytes[i] - } - } - - if bytes_per_pixel == 3 { - for i :=0; i < bytes_per_pixel; i++ { - pixels[addr+i] = color_bytes[i] - } - } - - if bytes_per_pixel == 4 { - for i :=0; i < bytes_per_pixel; i++ { - pixels[addr+i] = color_bytes[i] - } - } - - surf.Unlock() -} diff --git a/gogame/draw/line.go b/gogame/draw/line.go deleted file mode 100644 index f57846c..0000000 --- a/gogame/draw/line.go +++ /dev/null @@ -1,542 +0,0 @@ -package draw - -import ( -// "fmt" - "github.com/veandco/go-sdl2/sdl" - "../color" - "../rect" -) - -//closed true => an additional line segment is drawn between the first and last points. -//pointlist should be [][2] -func Lines(surf *sdl.Surface, col color.Color,closed bool, pointlist [][]int,width int) sdl.Rect { - length := len(pointlist) - if length < 2 { - panic("draw lines at least contains more than 1 points pair") - } - pts := make([]int,4) - - if len(pointlist[0]) < 2 { - panic("start points should be more than 1 at least") - } - - x := pointlist[0][0] - y := pointlist[0][1] - - startx := x - pts[0] = x - left := x - right := x - - starty := y - pts[1] = y - top := y - bottom := y - - if width < 1 { - return rect.Rect(x,y,0,0) - } - - err := surf.Lock() - if err != nil { - return rect.Rect(0,0,0,0) - } - - drawn := 1 - for loop := 1; loop < length; loop++ { - item := pointlist[loop] - if len(item) < 2 { - continue - } - - x = item[0] - y = item[1] - drawn += 1 - pts[0] = startx - pts[1] = starty - startx = x - starty = y - pts[2] = x - pts[3] = y - if clip_and_draw_line_width(surf, &surf.ClipRect, col, width, pts) > 0 { - left = min(min(pts[0],pts[2]),left) - top = min(min(pts[1],pts[3]),top) - right = max(max(pts[0],pts[2]),right) - bottom = max(max(pts[1],pts[3]),bottom) - } - } - - if closed == true && drawn > 2 { - item := pointlist[0] - x = item[0] - y = item[1] - - pts[0] = startx - pts[1] = starty - pts[2] = x - pts[3] = y - clip_and_draw_line_width(surf, &surf.ClipRect, col, width, pts) - } - surf.Unlock() - - return rect.Rect(left,top,right-left+1, bottom-top+1) - -} - -func Line(surf *sdl.Surface, col color.Color,x1,y1,x2,y2 ,width int) sdl.Rect { - pts := make([]int,4) - pts[0] = x1 - pts[1] = y1 - pts[2] = x2 - pts[3] = y2 - - if width < 1 { - return rect.Rect(x1,y1,0,0) - } - - err := surf.Lock() - if err != nil { - return rect.Rect(0,0,0,0) - } - anydraw := clip_and_draw_line_width(surf,&surf.ClipRect, col, width,pts) - surf.Unlock() - if anydraw == 0 { - return rect.Rect(x1,y1,0,0) - } - rleft := 0 - rtop := 0 - - if x1 < x2 { - rleft = x1 - }else { - rleft = x2 - } - - if y1 < y2 { - rtop = y1 - }else { - rtop = y2 - } - - dx := abs(x1-x2) - dy := abs(y1-y2) - - rwidth := 0 - rheight := 0 - if dx > dy { - rwidth = dx +1 - rheight = dy + width - }else { - rwidth = dx + width - rheight = dy + 1 - } - - return rect.Rect(rleft,rtop,rwidth,rheight) -} - - -func clip_and_draw_line(surf *sdl.Surface, rect *sdl.Rect, col color.Color, pts []int) int { - - if clipline(pts, int(rect.X),int(rect.Y),int(rect.X+ rect.W-1), int(rect.Y+rect.H-1) ) == 0 { - return 0 - } - - if pts[1] == pts[3] { - drawhorzline(surf, col, pts[0],pts[1],pts[2]) - }else if pts[0] == pts[2] { - drawvertline(surf,col, pts[0],pts[1],pts[3]) - }else { - drawline(surf, col, pts[0],pts[1],pts[2],pts[3]) - } - - return 1 -} - - -func clip_and_draw_line_width(surf *sdl.Surface,rect *sdl.Rect,col color.Color, width int, pts []int) int { - loop := 0 - xinc :=0 - yinc :=0 - newpts :=make([]int,4) - range_ := make([]int,4) - anydraw := 0 - if abs(pts[0]-pts[2]) > abs(pts[1]-pts[3]) { - yinc = 1 - }else{ - xinc = 1 - } - copy(newpts, pts) - if clip_and_draw_line(surf,rect,col, newpts) > 0 { - anydraw = 1 - copy(range_,newpts) - }else { - range_[0] = 10000 - range_[1] = 10000 - range_[2] = -10000 - range_[3] = -10000 - } - - for loop = 1; loop < width; loop +=2 { - newpts[0] = pts[0] + xinc*(loop/2+1) - newpts[1] = pts[1] + yinc*(loop/2+1) - newpts[2] = pts[2] + xinc*(loop/2+1) - newpts[3] = pts[3] + yinc*(loop/2+1) - if clip_and_draw_line(surf,rect,col,newpts) > 0 { - anydraw = 1 - range_[0] = min(newpts[0],range_[0]) - range_[1] = min(newpts[1],range_[1]) - range_[2] = max(newpts[2],range_[2]) - range_[3] = max(newpts[3],range_[3]) - } - if (loop + 1) < width { - newpts[0] = pts[0] - xinc*(loop/2+1) - newpts[1] = pts[1] - yinc*(loop/2+1) - newpts[2] = pts[2] - xinc*(loop/2+1) - newpts[3] = pts[3] - yinc*(loop/2+1) - if clip_and_draw_line(surf,rect,col, newpts) > 0 { - anydraw = 1 - range_[0] = min(newpts[0],range_[0]) - range_[1] = min(newpts[1],range_[1]) - range_[2] = max(newpts[2],range_[2]) - range_[3] = max(newpts[3],range_[3]) - } - } - } - if anydraw > 0 { - copy(pts,range_) - } - return anydraw -} - - -func encode(x,y,left,top,right,bottom int) int { - code := 0 - if (x < left ) { - code |= LEFT_EDGE - } - if (x > right) { - code |= RIGHT_EDGE - } - if (y < top) { - code |= TOP_EDGE - } - if (y > bottom) { - code |= BOTTOM_EDGE - } - return code -} - -func inside(a int) bool { - if a > 0 { - return false - } - return true -} - -func accept(a,b int) bool { - ret := a | b - if ret > 0 { - return false - }else { - return true - } -} - -func reject(a,b int) bool { - ret := a & b - if ret > 0 { - return true - } - return false -} - -func clipline(pts []int, left,top,right,bottom int) int { - - x1 := pts[0] - y1 := pts[1] - x2 := pts[2] - y2 := pts[3] - - var code1 int - var code2 int - draw := 0 - var swaptmp int - var m float64 /*slope*/ - - for true { - code1 = encode(x1,y1,left,top,right,bottom) - code2 = encode(x2,y2,left,top,right,bottom) - if ( accept(code1,code2) ) { - draw = 1 - break - } else if ( reject(code1,code2 ) ) { - break - }else { - if inside(code1) { - swaptmp = x2 - x2 = x1 - x1 = swaptmp - swaptmp = y2 - y2 = y1 - y1 = swaptmp - swaptmp = code2 - code2 = code1 - code1 = swaptmp - } - if x2 != x1 { - m = float64(y2 - y1) / float64(x2-x1) - }else { - m = 1.0 - } - if (code1 & LEFT_EDGE) > 0 { - y1 += int(float64(left-x1)*m) - x1 = left - }else if (code1 & RIGHT_EDGE) > 0 { - y1 += int(float64(right-x1)*m) - x1 = right - }else if (code1 & BOTTOM_EDGE) > 0 { - if x2 != x1 { - x1 += int(float64(bottom-y1) / m) - } - y1 = bottom - }else if (code1 & TOP_EDGE) > 0 { - if x2 != x1 { - x1 += int( float64(top-y1) / m) - } - y1 = top - } - } - } - - if draw > 0 { - pts[0] = x1 - pts[1] = y1 - pts[2] = x2 - pts[3] = y2 - } - - return draw -} - -func drawline(surf *sdl.Surface, col color.Color, x1,y1,x2,y2 int) { - deltax := x2 - x1 - deltay := y2 - y1 - - signx := 0 - signy := 0 - - if deltax < 0 { - signx = -1 - }else { - signx = 1 - } - - if deltay < 0 { - signy = -1 - }else { - signy = 1 - } - - deltax = signx * deltax + 1 - deltay = signy * deltay + 1 - - bytes_per_pixel := surf.BytesPerPixel() - - pixx := int(bytes_per_pixel) - pixy := int(surf.Pitch) - - addr := pixy* y1 + x1 * bytes_per_pixel - - pixx *= int(signx) - pixy *= int(signy) - - swaptmp := 0 - if deltax < deltay { - swaptmp = deltax - deltax = deltay - deltay = swaptmp - swaptmp = pixx - pixx = pixy - pixy = swaptmp - } - - x := 0 - y := 0 - - color_bytes := col.ToBytes() - pixels := surf.Pixels() - - switch bytes_per_pixel { - case 1: - for ; x < deltax; x++ { - pixels[addr] = color_bytes[0] - y += deltay - if y >= deltax { - y -= deltax - addr += pixy - } - addr +=pixx - } - break - case 2: - for ; x < deltax;x++ { - pixels[addr] = color_bytes[0] - pixels[addr+1] = color_bytes[1] - y+= deltay - if y >= deltax { - y -= deltax - addr += pixy - } - - addr+=pixx - } - break - case 3: - for ; x < deltax; x++ { - pixels[addr] = color_bytes[0] - pixels[addr+1] = color_bytes[1] - pixels[addr+2] = color_bytes[2] - y+=deltay - if y >= deltax { - y-=deltax - addr += pixy - } - addr+=pixx - } - break - case 4: - for ; x < deltax; x++ { - pixels[addr] = color_bytes[0] - pixels[addr+1] = color_bytes[1] - pixels[addr+2] = color_bytes[2] - pixels[addr+3] = color_bytes[3] - y+=deltay - if y >= deltax { - y-=deltax - addr += pixy - } - addr+=pixx - } - break - } - -} - -func drawhorzline(surf *sdl.Surface, col color.Color, x1,y1,x2 int) { - if x1 == x2 { - pixel(surf,col,x1,y1) - return - } - - bytes_per_pixel := surf.BytesPerPixel() - color_bytes := col.ToBytes() - pixels := surf.Pixels() - - addr := int(surf.Pitch) * y1 - end := 0 - start := 0 - if x1 < x2 { - end = addr + x2*bytes_per_pixel - start = addr+x1 *bytes_per_pixel - }else { - end = addr + x1 *bytes_per_pixel - start = addr + x2 * bytes_per_pixel - } - - switch bytes_per_pixel { - case 1: - for ; start <=end; start++ { - pixels[start] = color_bytes[0] - } - case 2: - for ; start <= end; start+=2 { - pixels[start] = color_bytes[0] - pixels[start+1] = color_bytes[1] - } - case 3: - for ; start <= end; start+=3 { - pixels[start] = color_bytes[0] - pixels[start+1] = color_bytes[1] - pixels[start+2] = color_bytes[2] - } - case 4: - for ; start <= end; start +=4 { - pixels[start] = color_bytes[0] - pixels[start+1] = color_bytes[1] - pixels[start+2] = color_bytes[2] - pixels[start+3] = color_bytes[3] - } - } - -} - -func drawhorzlineclip(surf *sdl.Surface, col color.Color, x1 , y1, x2 int ) { - if y1 < int(surf.ClipRect.Y) || y1 >= int( surf.ClipRect.Y + surf.ClipRect.H) { - return - } - - if x2 < x1 { - temp := x1 - x1 = x2 - x2 = temp - } - x1 = max(x1,int(surf.ClipRect.X)) - x2 = min(x2,int(surf.ClipRect.X+surf.ClipRect.W-1)) - if x2 < int(surf.ClipRect.X) || x1 >= int( surf.ClipRect.X + surf.ClipRect.W) { - return - } - - if x1 == x2 { - pixel(surf,col, x1,y1) - }else { - drawhorzline(surf,col,x1,y1,x2) - } -} - -func drawvertline(surf *sdl.Surface, col color.Color, x1,y1,y2 int) { - if y1 == y2 { - pixel(surf,col, x1,y1) - } - bytes_per_pixel := surf.BytesPerPixel() - color_bytes := col.ToBytes() - pixels := surf.Pixels() - pitch := int(surf.Pitch) - - addr := x1 * bytes_per_pixel - end := 0 - start := 0 - if y1 < y2 { - end = addr + y2* pitch - start = addr + y1*pitch - }else { - end = addr + y1*pitch - start = addr + y2*pitch - } - - switch bytes_per_pixel { - case 1: - for ; start <=end; start+=pitch { - pixels[start] = color_bytes[0] - } - case 2: - for ; start <= end; start+=pitch { - pixels[start] = color_bytes[0] - pixels[start+1] = color_bytes[1] - } - case 3: - for ; start <= end; start+=pitch { - pixels[start] = color_bytes[0] - pixels[start+1] = color_bytes[1] - pixels[start+2] = color_bytes[2] - } - case 4: - for ; start <= end; start +=pitch { - pixels[start] = color_bytes[0] - pixels[start+1] = color_bytes[1] - pixels[start+2] = color_bytes[2] - pixels[start+3] = color_bytes[3] - } - } - -} - diff --git a/gogame/draw/polygon.go b/gogame/draw/polygon.go deleted file mode 100644 index ea818a9..0000000 --- a/gogame/draw/polygon.go +++ /dev/null @@ -1,164 +0,0 @@ -package draw - -import ( - "fmt" -// "math" - "github.com/veandco/go-sdl2/sdl" - "../color" - "../rect" - "../qsort" - -) - -func draw_fillpoly(surf *sdl.Surface, vx []int, vy []int, numpoints int, col color.Color) { - - miny:=0 - maxy:=0 - y:=0 - x1:=0 - y1:=0 - x2:=0 - y2:=0 - ints := 0 - ind1:=0 - ind2:=0 - - polyints := make([]int,numpoints) - - /* Determine Y maxima */ - miny = vy[0] - maxy = vy[0] - for i:=1; i < numpoints; i++ { - miny = min(miny,vy[i]) - maxy = max(maxy,vy[i]) - } - - /* Draw, scanning y */ - for y=miny;y<=maxy;y++ { - ints = 0 - for i:=0; i< numpoints;i++ { - if i == 0 { - ind1 = numpoints -1 - ind2 = 0 - }else { - ind1 = i-1 - ind2 = i - } - - y1 = vy[ind1] - y2 = vy[ind2] - if y1 < y2 { - x1 = vx[ind1] - x2 = vx[ind2] - }else if y1 > y2 { - y2 = vy[ind1] - y1 = vy[ind2] - x2 = vx[ind1] - x1 = vx[ind2] - }else if miny == maxy { - /* Special case: polygon only 1 pixel high. */ - minx:= vx[0] - maxx:= vx[0] - - for j:= 1; j < numpoints; j++ { - minx = min(minx,vx[j]) - maxx = max(maxx,vx[j]) - } - polyints[ints] = minx - ints+=1 - polyints[ints] = maxx - ints+=1 - break - }else { - continue - } - - if ( y >= y1) && (y < y2 ) { - fmt.Println("ints : ",ints) - polyints[ints] = (y-y1) * (x2-x1) / (y2-y1) + x1 - ints+=1 - - }else if (y == maxy) && (y > y1) && (y <= y2) { - polyints[ints] = (y-y1) * (x2-x1) / (y2-y1) + x1 - ints+=1 - } - } - - new_polyints := make([]int, ints) - copy(new_polyints,polyints) - new_polyints = qsort.QuickSort(new_polyints) - - for i:=0;i 0 { - ret := Lines(surf, color, true,points,border_width) - return ret - } - - bytes_per_pixel := surf.BytesPerPixel() - if bytes_per_pixel <= 0 || bytes_per_pixel > 4 { - panic("unsupport bit depth for line draw") - } - - length := len(points) - if length < 3 { - panic("points argument must contain more than 2 points") - } - - item := points[0] // Needs sequence_get_item to fetch from sorted points list - if len(item) < 2 { - panic("points should be a pair of coordinators") - } - - x := item[0] - y := item[1] - - left := x - right := x - top := y - bottom := y - - xlist := make([]int,length) - ylist := make([]int,length) - - numpoints := 0 - for loop := 0; loop < length; loop++ { - item = points[loop] - if len(item) < 2 { - panic("points should be a pair of coordinators") - } - x = item[0] - y = item[1] - - xlist[numpoints] = x - ylist[numpoints] = y - numpoints+=1 - - left = min(x,left) - top = min(y,top) - right = max(x,right) - bottom = max(y,bottom) - } - - err := surf.Lock() - if err != nil { - return rect.Rect(0,0,0,0) - } - - draw_fillpoly(surf,xlist,ylist,numpoints,color) - - surf.Unlock() - - left = max(left,int(surf.ClipRect.X)) - top = max(top, int(surf.ClipRect.Y)) - right = min(right,int(surf.ClipRect.X + surf.ClipRect.W)) - bottom = min(bottom, int(surf.ClipRect.Y + surf.ClipRect.H)) - return rect.Rect(left,top,right-left+1, bottom-top+1) - -} diff --git a/gogame/draw/rect.go b/gogame/draw/rect.go deleted file mode 100644 index cffbd87..0000000 --- a/gogame/draw/rect.go +++ /dev/null @@ -1,19 +0,0 @@ -package draw - -import ( -// "math" - "github.com/veandco/go-sdl2/sdl" - "../color" - -) - -func Rect(surf *sdl.Surface,color color.Color, _rect *sdl.Rect, border_width int) { - l := int(_rect.X) - r := int(_rect.X + _rect.W - 1) - t := int(_rect.Y) - b := int(_rect.Y + _rect.H - 1) - - points := [][]int{ []int{l,t}, []int{r,t}, []int{r,b},[]int{l,b} } - Polygon(surf, color, points, border_width) - -} diff --git a/gogame/draw/utils.go b/gogame/draw/utils.go deleted file mode 100644 index 5c98055..0000000 --- a/gogame/draw/utils.go +++ /dev/null @@ -1,64 +0,0 @@ -package draw - -import ( - "math" - - "github.com/veandco/go-sdl2/sdl" - "../color" -) - -func max(a, b int) int { - if a > b { - return a - } - return b -} - -func min(a, b int) int { - if a < b { - return a - } - return b -} - -func abs(n int) int { - return int(math.Abs(float64(n))) -} - -func pixel(surf *sdl.Surface, c color.Color, x,y int) int { - pixels := surf.Pixels() - bytes_per_pixel := surf.BytesPerPixel() - - addr := y * int(surf.Pitch) + x*bytes_per_pixel // 1 2 3 4 - - color_bytes := c.ToBytes() - - if x < int(surf.ClipRect.X) || x >= int(surf.ClipRect.X + surf.ClipRect.W) || - y < int(surf.ClipRect.Y) || y >= int(surf.ClipRect.Y + surf.ClipRect.H) { - return 0 - } - - if bytes_per_pixel == 1 { - pixels[addr] = color_bytes[0] - } - - if bytes_per_pixel == 2 { - for i :=0; i < bytes_per_pixel; i++ { - pixels[addr+i] = color_bytes[i] - } - } - - if bytes_per_pixel == 3 { - for i :=0; i < bytes_per_pixel; i++ { - pixels[addr+i] = color_bytes[i] - } - } - - if bytes_per_pixel == 4 { - for i :=0; i < bytes_per_pixel; i++ { - pixels[addr+i] = color_bytes[i] - } - } - - return 1 -} diff --git a/gogame/event/event.go b/gogame/event/event.go deleted file mode 100644 index d019bda..0000000 --- a/gogame/event/event.go +++ /dev/null @@ -1,313 +0,0 @@ -package event - -import ( -// "fmt" - - "strconv" - - "github.com/veandco/go-sdl2/sdl" - -) - -const ( - NOEVENT = iota - QUIT - KEYDOWN - KEYUP - USEREVENT - -) - -var sdlKeyDict = map[int]string{ -sdl.K_UNKNOWN:"", -sdl.K_RETURN:"Return", -sdl.K_ESCAPE:"Escape", -sdl.K_BACKSPACE:"Backspace", -sdl.K_TAB:"Tab", -sdl.K_SPACE:"Space", -sdl.K_EXCLAIM:"!", -sdl.K_QUOTEDBL:"\"", -sdl.K_HASH:"#", -sdl.K_PERCENT:"%", -sdl.K_DOLLAR:"$", -sdl.K_AMPERSAND:"&", -sdl.K_QUOTE:"'", -sdl.K_LEFTPAREN:"(", -sdl.K_RIGHTPAREN:")", -sdl.K_ASTERISK:"*", -sdl.K_PLUS:"+", -sdl.K_COMMA:",", -sdl.K_MINUS:"-", -sdl.K_PERIOD:".", -sdl.K_SLASH:"/", -sdl.K_0:"0", -sdl.K_1:"1", -sdl.K_2:"2", -sdl.K_3:"3", -sdl.K_4:"4", -sdl.K_5:"5", -sdl.K_6:"6", -sdl.K_7:"7", -sdl.K_8:"8", -sdl.K_9:"9", -sdl.K_COLON:":", -sdl.K_SEMICOLON:";", -sdl.K_LESS:"<", -sdl.K_EQUALS:"=", -sdl.K_GREATER:">", -sdl.K_QUESTION:"?", -sdl.K_AT:"@", -sdl.K_LEFTBRACKET:"[", -sdl.K_BACKSLASH:"\\", -sdl.K_RIGHTBRACKET:"]", -sdl.K_CARET:"^", -sdl.K_UNDERSCORE:"_", -sdl.K_BACKQUOTE:"`", -sdl.K_a:"A", -sdl.K_b:"B", -sdl.K_c:"C", -sdl.K_d:"D", -sdl.K_e:"E", -sdl.K_f:"F", -sdl.K_g:"G", -sdl.K_h:"H", -sdl.K_i:"I", -sdl.K_j:"J", -sdl.K_k:"K", -sdl.K_l:"L", -sdl.K_m:"M", -sdl.K_n:"N", -sdl.K_o:"O", -sdl.K_p:"P", -sdl.K_q:"Q", -sdl.K_r:"R", -sdl.K_s:"S", -sdl.K_t:"T", -sdl.K_u:"U", -sdl.K_v:"V", -sdl.K_w:"W", -sdl.K_x:"X", -sdl.K_y:"Y", -sdl.K_z:"Z", -sdl.K_CAPSLOCK:"CapsLock", -sdl.K_F1:"F1", -sdl.K_F2:"F2", -sdl.K_F3:"F3", -sdl.K_F4:"F4", -sdl.K_F5:"F5", -sdl.K_F6:"F6", -sdl.K_F7:"F7", -sdl.K_F8:"F8", -sdl.K_F9:"F9", -sdl.K_F10:"F10", -sdl.K_F11:"F11", -sdl.K_F12:"F12", -sdl.K_PRINTSCREEN:"PrintScreen", -sdl.K_SCROLLLOCK:"ScrollLock", -sdl.K_PAUSE:"Pause", -sdl.K_INSERT:"Insert", -sdl.K_HOME:"Home", -sdl.K_PAGEUP:"PageUp", -sdl.K_DELETE:"Delete", -sdl.K_END:"End", -sdl.K_PAGEDOWN:"PageDown", -sdl.K_RIGHT:"Right", -sdl.K_LEFT:"Left", -sdl.K_DOWN:"Down", -sdl.K_UP:"Up", -sdl.K_NUMLOCKCLEAR:"Numlock", -sdl.K_KP_DIVIDE:"Keypad /", -sdl.K_KP_MULTIPLY:"Keypad *", -sdl.K_KP_MINUS:"Keypad -", -sdl.K_KP_PLUS:"Keypad +", -sdl.K_KP_ENTER:"Keypad Enter", -sdl.K_KP_1:"Keypad 1", -sdl.K_KP_2:"Keypad 2", -sdl.K_KP_3:"Keypad 3", -sdl.K_KP_4:"Keypad 4", -sdl.K_KP_5:"Keypad 5", -sdl.K_KP_6:"Keypad 6", -sdl.K_KP_7:"Keypad 7", -sdl.K_KP_8:"Keypad 8", -sdl.K_KP_9:"Keypad 9", -sdl.K_KP_0:"Keypad 0", -sdl.K_KP_PERIOD:"Keypad .", -sdl.K_APPLICATION:"Application", -sdl.K_POWER:"Power", -sdl.K_KP_EQUALS:"Keypad =", -sdl.K_F13:"F13", -sdl.K_F14:"F14", -sdl.K_F15:"F15", -sdl.K_F16:"F16", -sdl.K_F17:"F17", -sdl.K_F18:"F18", -sdl.K_F19:"F19", -sdl.K_F20:"F20", -sdl.K_F21:"F21", -sdl.K_F22:"F22", -sdl.K_F23:"F23", -sdl.K_F24:"F24", -sdl.K_EXECUTE:"Execute", -sdl.K_HELP:"Help", -sdl.K_MENU:"Menu", -sdl.K_SELECT:"Select", -sdl.K_STOP:"Stop", -sdl.K_AGAIN:"Again", -sdl.K_UNDO:"Undo", -sdl.K_CUT:"Cut", -sdl.K_COPY:"Copy", -sdl.K_PASTE:"Paste", -sdl.K_FIND:"Find", -sdl.K_MUTE:"Mute", -sdl.K_VOLUMEUP:"VolumeUp", -sdl.K_VOLUMEDOWN:"VolumeDown", -sdl.K_KP_COMMA:"Keypad ,", -sdl.K_KP_EQUALSAS400:"Keypad = (AS400)", -sdl.K_ALTERASE:"AltErase", -sdl.K_SYSREQ:"SysReq", -sdl.K_CANCEL:"Cancel", -sdl.K_CLEAR:"Clear", -sdl.K_PRIOR:"Prior", -sdl.K_RETURN2:"Return", -sdl.K_SEPARATOR:"Separator", -sdl.K_OUT:"Out", -sdl.K_OPER:"Oper", -sdl.K_CLEARAGAIN:"Clear / Again", -sdl.K_CRSEL:"CrSel", -sdl.K_EXSEL:"ExSel", -sdl.K_KP_00:"Keypad 00", -sdl.K_KP_000:"Keypad 000", -sdl.K_THOUSANDSSEPARATOR:"ThousandsSeparator", -sdl.K_DECIMALSEPARATOR:"DecimalSeparator", -sdl.K_CURRENCYUNIT:"CurrencyUnit", -sdl.K_CURRENCYSUBUNIT:"CurrencySubUnit", -sdl.K_KP_LEFTPAREN:"Keypad (", -sdl.K_KP_RIGHTPAREN:"Keypad )", -sdl.K_KP_LEFTBRACE:"Keypad {", -sdl.K_KP_RIGHTBRACE:"Keypad }", -sdl.K_KP_TAB:"Keypad Tab", -sdl.K_KP_BACKSPACE:"Keypad Backspace", -sdl.K_KP_A:"Keypad A", -sdl.K_KP_B:"Keypad B", -sdl.K_KP_C:"Keypad C", -sdl.K_KP_D:"Keypad D", -sdl.K_KP_E:"Keypad E", -sdl.K_KP_F:"Keypad F", -sdl.K_KP_XOR:"Keypad XOR", -sdl.K_KP_POWER:"Keypad ^", -sdl.K_KP_PERCENT:"Keypad %", -sdl.K_KP_LESS:"Keypad <", -sdl.K_KP_GREATER:"Keypad >", -sdl.K_KP_AMPERSAND:"Keypad &", -sdl.K_KP_DBLAMPERSAND:"Keypad &&", -sdl.K_KP_VERTICALBAR:"Keypad |", -sdl.K_KP_DBLVERTICALBAR:"Keypad ||", -sdl.K_KP_COLON:"Keypad :", -sdl.K_KP_HASH:"Keypad #", -sdl.K_KP_SPACE:"Keypad Space", -sdl.K_KP_AT:"Keypad @", -sdl.K_KP_EXCLAM:"Keypad !", -sdl.K_KP_MEMSTORE:"Keypad MemStore", -sdl.K_KP_MEMRECALL:"Keypad MemRecall", -sdl.K_KP_MEMCLEAR:"Keypad MemClear", -sdl.K_KP_MEMADD:"Keypad MemAdd", -sdl.K_KP_MEMSUBTRACT:"Keypad MemSubtract", -sdl.K_KP_MEMMULTIPLY:"Keypad MemMultiply", -sdl.K_KP_MEMDIVIDE:"Keypad MemDivide", -sdl.K_KP_PLUSMINUS:"Keypad +/-", -sdl.K_KP_CLEAR:"Keypad Clear", -sdl.K_KP_CLEARENTRY:"Keypad ClearEntry", -sdl.K_KP_BINARY:"Keypad Binary", -sdl.K_KP_OCTAL:"Keypad Octal", -sdl.K_KP_DECIMAL:"Keypad Decimal", -sdl.K_KP_HEXADECIMAL:"Keypad Hexadecimal", -sdl.K_LCTRL:"Left Ctrl", -sdl.K_LSHIFT:"Left Shift", -sdl.K_LALT:"Left Alt", -sdl.K_LGUI:"Left GUI", -sdl.K_RCTRL:"Right Ctrl", -sdl.K_RSHIFT:"Right Shift", -sdl.K_RALT:"Right Alt", -sdl.K_RGUI:"Right GUI", -sdl.K_MODE:"ModeSwitch", -sdl.K_AUDIONEXT:"AudioNext", -sdl.K_AUDIOPREV:"AudioPrev", -sdl.K_AUDIOSTOP:"AudioStop", -sdl.K_AUDIOPLAY:"AudioPlay", -sdl.K_AUDIOMUTE:"AudioMute", -sdl.K_MEDIASELECT:"MediaSelect", -sdl.K_WWW:"WWW", -sdl.K_MAIL:"Mail", -sdl.K_CALCULATOR:"Calculator", -sdl.K_COMPUTER:"Computer", -sdl.K_AC_SEARCH:"AC Search", -sdl.K_AC_HOME:"AC Home", -sdl.K_AC_BACK:"AC Back", -sdl.K_AC_FORWARD:"AC Forward", -sdl.K_AC_STOP:"AC Stop", -sdl.K_AC_REFRESH:"AC Refresh", -sdl.K_AC_BOOKMARKS:"AC Bookmarks", -sdl.K_BRIGHTNESSDOWN:"BrightnessDown", -sdl.K_BRIGHTNESSUP:"BrightnessUp", -sdl.K_DISPLAYSWITCH:"DisplaySwitch", -sdl.K_KBDILLUMTOGGLE:"KBDIllumToggle", -sdl.K_KBDILLUMDOWN:"KBDIllumDown", -sdl.K_KBDILLUMUP:"KBDIllumUp", -sdl.K_EJECT:"Eject", -sdl.K_SLEEP:"Sleep", -} - - -type Event struct { - Type uint32 - Data map[string]string -} - -func map_events( event sdl.Event) Event { - var ret Event - if event != nil { - switch t := event.(type) { - case *sdl.QuitEvent: - ret.Type = QUIT - case *sdl.KeyboardEvent: - if t.Type == sdl.KEYDOWN { - ret.Type = KEYDOWN - } - - if t.Type == sdl.KEYUP { - ret.Type = KEYUP - } - - ret.Data = make(map[string]string) - ret.Data["Repeat"]= strconv.Itoa( int(t.Repeat) ) - ret.Data["Key"] = sdlKeyDict[ int(t.Keysym.Sym) ] - ret.Data["Mod"] = strconv.Itoa( int(t.Keysym.Mod) ) - - default: -// fmt.Printf("unknow type %T\n", t) - ret.Type = NOEVENT - } - } - - return ret -} - -func Poll() Event { - var ret Event - - sdl.Do(func() { - event := sdl.PollEvent() - ret = map_events(event) - }) - - return ret -} - -func Wait() Event { - var ret Event - - event := sdl.WaitEvent() - ret = map_events(event) - - return ret -} diff --git a/gogame/flags.go b/gogame/flags.go deleted file mode 100644 index ef139a0..0000000 --- a/gogame/flags.go +++ /dev/null @@ -1,13 +0,0 @@ -package gogame - -import "github.com/veandco/go-sdl2/sdl" - -const ( - - SHOWN = sdl.WINDOW_SHOWN - OPENGL = sdl.WINDOW_OPENGL - HIDDEN = sdl.WINDOW_HIDDEN - FULLSCREEN = sdl.WINDOW_FULLSCREEN - RESIZABLE = sdl.WINDOW_RESIZABLE - -) diff --git a/gogame/qsort/qsort.go b/gogame/qsort/qsort.go deleted file mode 100644 index 76b3269..0000000 --- a/gogame/qsort/qsort.go +++ /dev/null @@ -1,37 +0,0 @@ -package qsort - -import "math/rand" - -func QuickSort(slice []int) []int { - length := len(slice) - - if length <= 1 { - sliceCopy := make([]int, length) - copy(sliceCopy, slice) - return sliceCopy - } - - m := slice[rand.Intn(length)] - - less := make([]int, 0, length) - middle := make([]int, 0, length) - more := make([]int, 0, length) - - for _, item := range slice { - switch { - case item < m: - less = append(less, item) - case item == m: - middle = append(middle, item) - case item > m: - more = append(more, item) - } - } - - less, more = QuickSort(less), QuickSort(more) - - less = append(less, middle...) - less = append(less, more...) - - return less -} diff --git a/gogame/qsort/qsort_test.go b/gogame/qsort/qsort_test.go deleted file mode 100644 index 6e697e2..0000000 --- a/gogame/qsort/qsort_test.go +++ /dev/null @@ -1,27 +0,0 @@ -package qsort - -import ( - "reflect" - "testing" -) - -var testData = []struct { - input []int - expectedOutput []int -}{ - {[]int{}, []int{}}, - {[]int{42}, []int{42}}, - {[]int{42, 23}, []int{23, 42}}, - {[]int{23, 42, 32, 64, 12, 4}, []int{4, 12, 23, 32, 42, 64}}, -} - -func TestQuickSort(t *testing.T) { - for _, testCase := range testData { - actual := QuickSort(testCase.input) - expected := testCase.expectedOutput - - if !reflect.DeepEqual(actual, expected) { - t.Errorf("%v != %v\n", actual, expected) - } - } -} diff --git a/gogame/rect/rect.go b/gogame/rect/rect.go deleted file mode 100644 index 51fb6b8..0000000 --- a/gogame/rect/rect.go +++ /dev/null @@ -1,30 +0,0 @@ -package rect - -import ( - "github.com/veandco/go-sdl2/sdl" -) - -func Rect(top ,left, width,height int) sdl.Rect { - return sdl.Rect{int32(top),int32(left),int32(width),int32(height)} -} - -func InflateIp(rect *sdl.Rect, x,y int) { - - rect.X -= int32(x/2) - rect.Y -= int32(y/2) - rect.W += int32(x) - rect.H += int32(y) - -} - -func Inflate(rect *sdl.Rect, x,y int) sdl.Rect { - - r := sdl.Rect{0,0,0,0} - - r.X = rect.X - int32(x/2) - r.Y = rect.Y - int32(y/2) - r.W = rect.W + int32(x) - r.H = rect.H + int32(y) - - return r -} diff --git a/gogame/structs.go b/gogame/structs.go deleted file mode 100644 index a6bbcb4..0000000 --- a/gogame/structs.go +++ /dev/null @@ -1,4 +0,0 @@ -package gogame - -//import "github.com/veandco/go-sdl2/sdl" - diff --git a/gogame/surface/surface.go b/gogame/surface/surface.go deleted file mode 100644 index 1e13047..0000000 --- a/gogame/surface/surface.go +++ /dev/null @@ -1,46 +0,0 @@ -package surface - -import ( - "fmt" - "github.com/veandco/go-sdl2/sdl" - "../color" -) - - -func Fill(surface *sdl.Surface, col color.Color) { - - rect := sdl.Rect{0,0,0,0} - - rect.W = surface.W - rect.H = surface.H - - FillRect(surface, &rect, uint32(col.ToHex())) -} - -func FillRect(surface *sdl.Surface,rect *sdl.Rect, color uint32) { - - sdl.Do(func() { - surface.FillRect(rect,color) - }) - - return -} - -// Create a New Surface -func Surface(w,h int) *sdl.Surface { - //flags=0, depth=0, masks=None - Rmask := 0x000000ff - Gmask := 0x0000ff00 - Bmask := 0x00ff0000 - Amask := 0xff000000 - - flags := 0 - depth := 32 - - surf,err := sdl.CreateRGBSurface(uint32(flags),int32(w),int32(h), int32(depth), uint32(Rmask), uint32(Gmask), uint32(Bmask), uint32(Amask)) - if err != nil { - panic( fmt.Sprintf("sdl.CreateRGBSurface failed %s",sdl.GetError())) - } - - return surf -} diff --git a/skin/default/config.cfg b/skin/default/config.cfg new file mode 100644 index 0000000..2fe3f5a --- /dev/null +++ b/skin/default/config.cfg @@ -0,0 +1,3 @@ +[Colors] +High = #33a6ff +White = #ffffff diff --git a/skin/default/sys.go/gameshell/blank.png b/skin/default/sys.go/gameshell/blank.png new file mode 100644 index 0000000..077c8a6 Binary files /dev/null and b/skin/default/sys.go/gameshell/blank.png differ diff --git a/skin/default/sys.go/gameshell/footbar_icons/footbar.png b/skin/default/sys.go/gameshell/footbar_icons/footbar.png new file mode 100644 index 0000000..e58956c Binary files /dev/null and b/skin/default/sys.go/gameshell/footbar_icons/footbar.png differ diff --git a/skin/default/sys.go/gameshell/icons/_L.png b/skin/default/sys.go/gameshell/icons/_L.png new file mode 100644 index 0000000..58a2e95 Binary files /dev/null and b/skin/default/sys.go/gameshell/icons/_L.png differ diff --git a/skin/default/sys.go/gameshell/icons/_R.png b/skin/default/sys.go/gameshell/icons/_R.png new file mode 100644 index 0000000..d26a910 Binary files /dev/null and b/skin/default/sys.go/gameshell/icons/_R.png differ diff --git a/skin/default/sys.go/gameshell/icons/about_bg.png b/skin/default/sys.go/gameshell/icons/about_bg.png new file mode 100644 index 0000000..1fc0ee3 Binary files /dev/null and b/skin/default/sys.go/gameshell/icons/about_bg.png differ diff --git a/skin/default/sys.go/gameshell/icons/blueselector.png b/skin/default/sys.go/gameshell/icons/blueselector.png new file mode 100644 index 0000000..82e285b Binary files /dev/null and b/skin/default/sys.go/gameshell/icons/blueselector.png differ diff --git a/skin/default/sys.go/gameshell/icons/done.png b/skin/default/sys.go/gameshell/icons/done.png new file mode 100644 index 0000000..ceeadbf Binary files /dev/null and b/skin/default/sys.go/gameshell/icons/done.png differ diff --git a/skin/default/sys.go/gameshell/icons/empty.png b/skin/default/sys.go/gameshell/icons/empty.png new file mode 100644 index 0000000..7d8beb5 Binary files /dev/null and b/skin/default/sys.go/gameshell/icons/empty.png differ diff --git a/skin/default/sys.go/gameshell/icons/heart.png b/skin/default/sys.go/gameshell/icons/heart.png new file mode 100644 index 0000000..f9c6673 Binary files /dev/null and b/skin/default/sys.go/gameshell/icons/heart.png differ diff --git a/skin/default/sys.go/gameshell/icons/icon_sd.png b/skin/default/sys.go/gameshell/icons/icon_sd.png new file mode 100644 index 0000000..555d2d9 Binary files /dev/null and b/skin/default/sys.go/gameshell/icons/icon_sd.png differ diff --git a/skin/default/sys.go/gameshell/icons/light.png b/skin/default/sys.go/gameshell/icons/light.png new file mode 100644 index 0000000..f581a7b Binary files /dev/null and b/skin/default/sys.go/gameshell/icons/light.png differ diff --git a/skin/default/sys.go/gameshell/icons/lock.png b/skin/default/sys.go/gameshell/icons/lock.png new file mode 100644 index 0000000..1e9ac7a Binary files /dev/null and b/skin/default/sys.go/gameshell/icons/lock.png differ diff --git a/skin/default/sys.go/gameshell/icons/needwifi_bg.png b/skin/default/sys.go/gameshell/icons/needwifi_bg.png new file mode 100644 index 0000000..6b42ba9 Binary files /dev/null and b/skin/default/sys.go/gameshell/icons/needwifi_bg.png differ diff --git a/skin/default/sys.go/gameshell/icons/online.png b/skin/default/sys.go/gameshell/icons/online.png new file mode 100644 index 0000000..8be6bc4 Binary files /dev/null and b/skin/default/sys.go/gameshell/icons/online.png differ diff --git a/skin/default/sys.go/gameshell/icons/rom_download.png b/skin/default/sys.go/gameshell/icons/rom_download.png new file mode 100644 index 0000000..a704d0f Binary files /dev/null and b/skin/default/sys.go/gameshell/icons/rom_download.png differ diff --git a/skin/default/sys.go/gameshell/icons/roundcorners.png b/skin/default/sys.go/gameshell/icons/roundcorners.png new file mode 100644 index 0000000..cd8fce6 Binary files /dev/null and b/skin/default/sys.go/gameshell/icons/roundcorners.png differ diff --git a/skin/default/sys.go/gameshell/icons/scale.png b/skin/default/sys.go/gameshell/icons/scale.png new file mode 100644 index 0000000..f7e2dd4 Binary files /dev/null and b/skin/default/sys.go/gameshell/icons/scale.png differ diff --git a/skin/default/sys.go/gameshell/icons/star.png b/skin/default/sys.go/gameshell/icons/star.png new file mode 100644 index 0000000..7910226 Binary files /dev/null and b/skin/default/sys.go/gameshell/icons/star.png differ diff --git a/skin/default/sys.go/gameshell/icons/sys.png b/skin/default/sys.go/gameshell/icons/sys.png new file mode 100644 index 0000000..aac76d3 Binary files /dev/null and b/skin/default/sys.go/gameshell/icons/sys.png differ diff --git a/skin/default/sys.go/gameshell/icons/vol.png b/skin/default/sys.go/gameshell/icons/vol.png new file mode 100644 index 0000000..49b56fe Binary files /dev/null and b/skin/default/sys.go/gameshell/icons/vol.png differ diff --git a/skin/default/sys.go/gameshell/titlebar_icons/battery_unknown.png b/skin/default/sys.go/gameshell/titlebar_icons/battery_unknown.png new file mode 100644 index 0000000..24f681a Binary files /dev/null and b/skin/default/sys.go/gameshell/titlebar_icons/battery_unknown.png differ diff --git a/skin/default/sys.go/gameshell/titlebar_icons/soundvolume.png b/skin/default/sys.go/gameshell/titlebar_icons/soundvolume.png new file mode 100644 index 0000000..0d3229b Binary files /dev/null and b/skin/default/sys.go/gameshell/titlebar_icons/soundvolume.png differ diff --git a/skin/default/sys.go/gameshell/titlebar_icons/wifi.png b/skin/default/sys.go/gameshell/titlebar_icons/wifi.png new file mode 100644 index 0000000..7384a71 Binary files /dev/null and b/skin/default/sys.go/gameshell/titlebar_icons/wifi.png differ diff --git a/skin/default/sys.go/gameshell/titlebar_icons/withcharging.png b/skin/default/sys.go/gameshell/titlebar_icons/withcharging.png new file mode 100644 index 0000000..3b109a3 Binary files /dev/null and b/skin/default/sys.go/gameshell/titlebar_icons/withcharging.png differ diff --git a/skin/default/sys.go/gameshell/titlebar_icons/without_charging.png b/skin/default/sys.go/gameshell/titlebar_icons/without_charging.png new file mode 100644 index 0000000..ae46cd2 Binary files /dev/null and b/skin/default/sys.go/gameshell/titlebar_icons/without_charging.png differ diff --git a/skin/default/truetype/NotoSansCJK-Regular.ttf b/skin/default/truetype/NotoSansCJK-Regular.ttf new file mode 100644 index 0000000..271526f Binary files /dev/null and b/skin/default/truetype/NotoSansCJK-Regular.ttf differ diff --git a/skin/default/truetype/NotoSansMono-Regular.ttf b/skin/default/truetype/NotoSansMono-Regular.ttf new file mode 100644 index 0000000..fd2546d Binary files /dev/null and b/skin/default/truetype/NotoSansMono-Regular.ttf differ diff --git a/skin/default/truetype/VarelaRound-Regular.ttf b/skin/default/truetype/VarelaRound-Regular.ttf new file mode 100644 index 0000000..54fa9f9 Binary files /dev/null and b/skin/default/truetype/VarelaRound-Regular.ttf differ diff --git a/skin/default/truetype/VeraMono.ttf b/skin/default/truetype/VeraMono.ttf new file mode 100644 index 0000000..139f0b4 Binary files /dev/null and b/skin/default/truetype/VeraMono.ttf differ diff --git a/test b/test index b78ffda..a6e6296 100755 Binary files a/test and b/test differ diff --git a/test.go b/test.go index 8b2dd7a..642727a 100644 --- a/test.go +++ b/test.go @@ -6,33 +6,52 @@ import ( "github.com/veandco/go-sdl2/sdl" - //"./gogame" - "./gogame/color" - "./gogame/display" - "./gogame/surface" - "./gogame/event" - "./gogame/rect" - "./gogame/draw" + //"github.com/cuu/gogame" + "github.com/cuu/gogame/color" + "github.com/cuu/gogame/display" + "github.com/cuu/gogame/surface" + "github.com/cuu/gogame/event" + "github.com/cuu/gogame/rect" + "github.com/cuu/gogame/draw" + "github.com/cuu/gogame/image" ) func run() int { + + width := 320 + height := 240 display.Init() - screen := display.SetMode(320,240,0,32) + screen := display.SetMode(int32(width),int32(height),0,32) - surface.Fill(screen, color.Color{0,0,0,0} ) + surface.Fill(screen, color.Color{255,255,255,255} ) rect1 := rect.Rect(0,10, 12, 10) //surface.FillRect(screen,&rect, 0xffff0000) rect1.X = 12 - draw.Rect(screen,color.Color{129,235,234,0},&rect1,1) + draw.Rect(screen,color.Color{129,235,234,255},&rect1,1) fmt.Println(screen.Pitch) fmt.Println( screen.BytesPerPixel() ) + img_surf := image.Load("skin/default/sys.go/gameshell/icons/roundcorners.png") + + + fmt.Println("WxH: ", img_surf.W,img_surf.H) + + portion := rect.Rect(0,0,10,10) + surface.Blit(screen,img_surf, draw.MidRect(5,5,10,10,width,height), &portion) + portion.Y = 10 + surface.Blit(screen,img_surf, draw.MidRect(315,5,10,10,width,height), &portion) + portion.Y = 20 + surface.Blit(screen,img_surf, draw.MidRect(5,235,10,10,width,height), &portion) + portion.Y = 30 + surface.Blit(screen,img_surf, draw.MidRect(315,235,10,10,width,height), &portion) + + /* for i:=1; i<319;i++ { draw.Point(screen, color.Color{255,44,255,0}, i,20)