About Monkey 2 › Forums › Monkey 2 Projects › Asteroids remake
Tagged: game2d
This topic contains 41 replies, has 7 voices, and was last updated by
AdamStrange
2 years, 6 months ago.
-
AuthorPosts
-
September 30, 2016 at 6:27 am #4169
I used a simple radius check for broad sweeps and line collisions for close checks. I was able to mark lines as “detail” meaning they did not participate in the checks. Fast and easy, no need for anything else from a line vector object point of view.
October 1, 2016 at 2:14 pm #4198Here’s a quick look at things with new images and left list operational.
You can see I’ve got for clarity and simplicity. in essence you just create a whole block of ‘vector’ objects that can simply be rendered onto the screen. use multiples for different versions, use other as poly collision, etc. All wrapped up in a single unified UI.
Still doing debugging and finalising, but coming along
Attachments:
October 1, 2016 at 3:49 pm #4201nice… and this should integrate with your bitmap editor to create collision polys for bitmap objects as well.
then of course since you seem to be flying through this stuff… build a scene graph bitmap animation editor on top of both of these!
October 1, 2016 at 3:57 pm #4202also… in these editors you should allow a workflow that can see external changes and update… so those app seem integrated as well in you ide. for instance, I like Aseprite for bitmap editing so if I have a bitmap ‘object’ in your ide and I make a change using aseprite, it would be nice to have your app recognize and automatically update all the assets.
I’m making the assumption here that the primary purpose of your editors are for creation and assembly of game objects with creation and modification of the base assets being secondary? (since there are really awesome apps out there like Aseprite)
October 2, 2016 at 5:39 am #4221good points
October 3, 2016 at 11:04 am #4239ok. All working and operational now.
I’ve added list reordering, just drag and drop for new order
Added stuff like undo, select all, etc
undo just really undoes the lat dropped point, but it will work with pre loaded vectors too!
the eyes now function, so if you click an eye, it will show the ghosted version in the drawing area
Here’s the last shot of this in stand alone app form. next up will be to integrate it directly into ted21
P.S. fast loading and saving of binary format too.
As Dmaz said above. any opened vector objects automatically save as they are documents
Attachments:
October 7, 2016 at 2:26 pm #4308Hi Matthew
Heres a couple of shots for you showing vector editing built directly into ted21 (which isn’t quite as dead as I would have thought)
Also basic app showing loading of the single vector asset (packs the vector shapes into a single file).
full rotation/scaling of vectors fully supported.
automatic bounds update and basic entity system complete
I’ve got boundsPoint and polyPoint collision implemented as well as bullets. No need for particles as I found a sneakier way of doing them…
Just writing a quick vector font system – using the same vector library
October 8, 2016 at 12:52 pm #4340(not)particles complete, stars complete, vector text complete,
Starting to look not too bad….
Attachments:
October 8, 2016 at 10:41 pm #4356looking great Adam! How is the data being stored and loaded?
October 9, 2016 at 5:42 am #4360nice and simple:
here’s the individual routines
Monkey12345678910111213141516171819202122232425262728293031323334353637383940414243method Load( file:Stream )If not file then returnlocal filled:byte = file.ReadByte()If filled = 1 Then_filled = TrueElse_filled = FalseEnd Iflocal count:int = file.ReadInt()_points = New Float[ count ]Local k:intLocal pos:int = 0For k = 1 To count_points[ pos ] = file.ReadFloat()pos += 1Next_count = count_lineCount = (count * .5)-1End methodmethod Save( file:Stream )If not file then ReturnIf _filled Thenfile.WriteByte( 1 )Elsefile.WriteByte( 0 )End Iffile.WriteInt( _count )Local k:intLocal pos:int = 0For k = 1 To _countfile.WriteFloat( _points[ pos ] )pos += 1NextEnd methodand the packed ones:
Monkey123456789101112131415161718192021222324252627282930313233343536373839404142434445464748method Load( filePath:string )Local file:FileStream = FileStream.Open( filePath, "r" )If file Thenlocal Count:int = file.ReadInt()Local pos:int = 0While Not file.EofPrint "vector "+pos_vector[ pos ] = New Vector2d()_vector[ pos ].Load( file )pos += 1WendCount = pos-1_count = pos-1file.Close()App.RequestRender()ElsePrint "file not opened"End ifEnd methodmethod Save( filePath:string )If Count < 0 Then ReturnPrint filePathLocal file:FileStream = FileStream.Open( filePath, "w" )If file Thenfile.WriteInt( Count+1 )Local k:intFor k = 0 To CountIf _vector[ k ] Then_vector[ k ].Save( file )End ifNextfile.Close()ElsePrint "file not opened"End ifEnd methodOctober 10, 2016 at 12:16 am #4380Thanks!
October 10, 2016 at 5:20 am #4381Here’s the complete vevtor2d class
This has all the code for loading saving and drawing a single object
Monkey123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129Class Vector2dmethod New()End methodmethod New( shape:Vector2d )_points = New float[ shape._count ]If shape._count > 0 ThenLocal k:intFor k = 0 Until shape._count_points[k] = shape._points[k]Next' _points = shape._pointsEnd if_count = shape._count_lineCount = shape._lineCount_filled = shape._filledEnd methodmethod New( points:float[], count:int, filled:bool )Local lines:int = (count - 2 ) * .5_points = New float[ count ]If count > 0 ThenLocal k:intFor k = 0 Until count_points[k] = points[k]NextEnd If' _points = points_count = count_lineCount = lines_filled = filledEnd methodmethod Load( file:Stream )If not file then returnlocal filled:byte = file.ReadByte()If filled = 1 Then_filled = TrueElse_filled = FalseEnd Iflocal count:int = file.ReadInt()_points = New Float[ count ]Local k:intLocal pos:int = 0For k = 1 To count_points[ pos ] = file.ReadFloat()pos += 1Next_count = count_lineCount = (count * .5)-1End methodmethod Save( file:Stream )If not file then ReturnIf _filled Thenfile.WriteByte( 1 )Elsefile.WriteByte( 0 )End Iffile.WriteInt( _count )Local k:intLocal pos:int = 0For k = 1 To _countfile.WriteFloat( _points[ pos ] )pos += 1NextEnd methodmethod Draw( canvas:Canvas, x:int, y:int, x1:int, y1:int )Local xx:float = (x1 - x) * .5Local yy:float = (y1 - y) * .5Local zoom:float = xxIf yy < xx Then zoom = yyDraw( canvas, x + xx, y + yy, zoom )End methodmethod Draw( canvas:Canvas, x:int, y:int, zoom:float )If _lineCount < 1 Then Returnlocal k:intLocal px:int = 0Local py:int = 1Local px1:int = 2Local py1:int = 3Local x1:float = x + _points[px] * zoomLocal y1:float = y + _points[py] * zoomLocal x2:float = x + _points[px1] * zoomLocal y2:float = y + _points[py1] * zoomfor k = 1 To _lineCountcanvas.DrawLine( x1, y1, x2, y2 )px = px1py = py1px1 += 2py1 += 2x1 = x2y1 = y2If px1 < _count Thenx2 = x + _points[px1] * zoomy2 = y + _points[py1] * zoomEnd IfNextEnd methodField _points:Float[]field _count:int = 0field _lineCount:int = 0field _filled:boolEndinternally it is a single float array so that it can be passed directly to mojo.canvas
it also supports filled polygons, but not proper ones with concave parts – just the default mojo.poly
-
AuthorPosts
You must be logged in to reply to this topic.




