Forum Replies Created
-
AuthorPosts
-
For 2D I just use Bresenham Line on an array.
This is MX1 code but you should be able to convert it, it will return an int of a map array (eg the tile):
Monkey123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172Method CheckCollision:Int(startX:Float, startY:Float, endX:Float, endY:Float)' use Bresenham LineLocal x1:Int = startXLocal y1:Int = startYLocal x2:Int = endXLocal y2:Int = endYLocal deltax:Int = Abs(x2 - x1)Local deltay:Int = Abs(y2 - y1)Local numpixels:Int, d:Int, dinc1:Int, dinc2:Int, xinc1:Int, xinc2:Int, yinc1:Int, yinc2:Int, x:Int, y:Int, i:IntLocal xx:Int, cx:IntLocal yy:Int, cy:IntLocal tile:IntIf deltax >= deltaynumpixels = deltax + 1d = (2 * deltay) - deltaxdinc1 = deltay Shl 1dinc2 = (deltay - deltax) Shl 1xinc1 = 1xinc2 = 1yinc1 = 0yinc2 = 1Elsenumpixels = deltay + 1d = (2 * deltax) - deltaydinc1 = deltax Shl 1dinc2 = (deltax - deltay) Shl 1xinc1 = 0xinc2 = 1yinc1 = 1yinc2 = 1EndIf x1 > x2xinc1 = -xinc1xinc2 = -xinc2EndIf y1 > y2yinc1 = -yinc1yinc2 = -yinc2Endx = x1y = y1For i = 1 To numpixelsxx = Floor(x / TILE_WIDTH)yy = Floor(y / TILE_HEIGHT)tile = map[yy][xx]' exit when we have a collisionIf tile <> 0 Thencx = xcy = yExitEndIf d < 0d = d + dinc1x = x + xinc1y = y + yinc1Elsed = d + dinc2x = x + xinc2y = y + yinc2EndNextReturn tileEndG’day! Welcome aboard!
Nice game Adam!
How do you kill the monsters?
Great little demo! I said to Mark (via Twitter) that the little monkey should become Monkey2’s mascot!
Looking on the wiki and checking supported lifespans the iPhone6S would be the minimum you would want to get:
https://en.wikipedia.org/wiki/IPhone#History_and_availability
An iPhone SE or a iPhone 7 would last a bit longer…
Congrats Adam for winning the FFSJam!
https://itch.io/jam/finally-finish-something-2018/results
GTDC came 12th
Either rewrite or step back for a day and relax…
I’ve been eating better too since November, lost around 10kg but not really tracking it. Just eating less junk and overall eating less, also doing a bit more exercise… but still enjoying food now and again (eg the curry last night, KFC zinger burger last Saturday).
I did something like this when I was trying Pyro:
Monkey12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152Class MyScreen Extends ScreenConst NOT_FADING:Int = 0Const FADE_IN:Int = 1Const FADE_OUT:Int = 2Const FADE_SPEED:Float = 0.05Field fadeValue:Float = 0Field fading:Int = NOT_FADINGField nextScreen:MyScreenMethod SetScreen()self.Set()Self.fading = MyScreen.FADE_INSelf.fadeValue = 0EndMethod OnPostRender( canvas:Canvas ) OverrideIf fading > NOT_FADINGDrawFader( canvas, fadeValue )EndEndMethod FadeToScreen(screen:MyScreen)nextScreen = screenfading = FADE_OUTEndMethod UpdateScreenFade()If fading > NOT_FADINGIf fading = FADE_INIf fadeValue < 1fadeValue += FADE_SPEEDElsefadeValue = 1.0fading = NOT_FADINGEndifElseIf fadeValue > 0fadeValue -= FADE_SPEEDElsefadeValue = 0nextScreen.SetScreen()fading = NOT_FADINGEndEndEndEndMethod OnUpdate() OverrideUpdateScreenFade()EndEndThe using Pyro’s screenmanager:
Monkey1234567891011121314151617181920Class NightOfTheUnfed Extends ScreenManagerMethod New(title:String, width:Int, height:Int, flags:WindowFlags = WindowFlags.Resizable)Super.New(title, width, height, flags)ClearColor=Color.BlackLayout = "letterbox"gameScreen = New GameScreentitleScreen = New TitleScreen' titleScreen.SetScreen()loader=New Loaderloader.Set()loader.FollowUpScreen=titleScreenEndMethod OnMeasure:Vec2i() OverrideReturn virtualResolutionEndEndMonkey1234567891011121314151617181920212223242526272829Class GameScreen Extends MyScreenField camera:CameraField scene:SceneField light:LayerSpriteField atlas:ImageField player:PlayerField layer:Layer'Field maze:MazeField mymap:themapMethod New()EndMethod OnStart() Overridescene = New Scene(ScreenManager)...Method OnUpdate() OverrideSuper.OnUpdate()If Keyboard.KeyHit(Key.Escape)FadeToScreen(titleScreen)EndThats nice of him (or her).. but it would be more professional to have them hosted under monkeycoder.co.nz (or monkeycoder.com in the future, maybe hint hint)…
What about trying AssetDir?
http://turdus.be/monkey2docs/docs/modules/std/module/std-filesystem-AssetsDir.html
Monkey12345std:std.filesystem.AssetsDirFunction AssetsDir:String( )Gets the filesystem directory of the app's assets directory.Note that only the desktop and web targets have an assets directory. Other targets will return an empty string.Our Mac Mini is still running OS X Mavericks (10.9.5)… as for some game portals I needed to compile for that platform!!
I do the following in Diddy2:
Monkey1234567Local image:Image = Image.Load(path)If Not imagePrint("Error: Can not load image: " + path)App.Terminate()End@pakz I cheat, put everything in an assests folder and just use:
Monkey1#Import "assets/"Which will copy over all the assets
-
AuthorPosts