Boulderdash mechanics

BlitzMax Forums/BlitzMax Programming/Boulderdash mechanics

Casaber(Posted 2016) [#1]
This is a Bulderdash mechanics which uses a small portion of a huge world to update itself on a regular basis.

You could use this to well I don't know really. Games or just having fun with tiles and explore.

' How to use
'
' Draw some boulders using the mouse
' Press 1, 2 or 3 to change tiles
'
' Move around inside the world using cursor keys


Global buffer:Int[256*256] ; Local img2:TPixmap=LoadPixmap(LoadBank("http::s9.postimg.org/rfaelk9m3/128x128.png"))  ' Load a 128x128 Atlas with 8x8 tiles
For yy=0 To 127 ; For xx=0 To 127 ; buffer(xx+yy*128) = ReadPixel(img2,xx,yy) ; Next ; Next
Global map[4096,4096] , wx:Int , wy:Int , c:Int = buffer[0] , s:Int = 2 , xres:Int = 1024 , yres:Int = 768 , pixels:Int[xres*yres]
Local a:Float = 0 , x:Float = 0 , y:Float = 0 , dx:Float = 0 , dy:Float = 0 , speed:Float = 0
Global space_z:Float = 50 , horizon:Int = 20, scale:Float = 1000 , obj_scale:Float = 50 , pmap:Int[1024*1024] 
Global cx

' Prepare something here, you can do alot here to improve it into a fun world, I think I will just put some text
For y=0 To 316 ; For x=0 To 475; map[x,y]=Rnd(127) ; Next ; Next ' This fills with garbage (uncomment line below if you want garbage)
For y=0 To 316 ; For x=0 To 475; map[x,y]=32 Next ; Next ' Clear the space

Global cmap[4096,4096] ; For y=0 To 316 ; For x=0 To 475; cmap[x,y]=Rnd(15) ; Next ; Next
Global worldx,worldy,currentx ; Global cols[16] 
RestoreData colors 
For temp=0 To 15 ; ReadData cols[temp] ; Next

writetomap "                                        ",0,0
writetomap "    **** COMMODORE 64 BASIC V2 ****     ",0,1
writetomap "                                        ",0,2
writetomap " 64K RAM SYSTEM  38911 BASIC BYTES FREE ",0,3
writetomap "                                        ",0,4
writetomap "READY.                                  ",0,5
writetomap "                                        ",0,4
writetomap "----------------------------------- ",0,20

GLGraphics(xres,yres,0,60,GRAPHICS_BACKBUFFER | GRAPHICS_DEPTHBUFFER) 
glViewport(0,0,xres,yres) ; glMatrixMode(GL_PROJECTION) ; glLoadIdentity() ; glOrtho(0,xres,yres,0,0,1) ; glPixelZoom(1,-1) ; glRasterPos2i(0,0)

s=2
Global Current=79, current2=7
Repeat
	For y=0 To yres-1 Step 1 ; For x=0 To xres-1 Step 1 ; pixels[(y*xres+x)] = 0 ; Next ; Next

	worldx=worldx-s*KeyDown(KEY_LEFT)+s*KeyDown(KEY_RIGHT) ; worldy=worldy-s*KeyDown(KEY_UP)+s*KeyDown(KEY_DOWN)
        worldx=Max(0,Min(10000,worldx)) ; worldy=Max(0,Min(10000,worldy))

	alive() ' This one makes things alive, comment it if you don´t want things changing in life. You bore.

	display(worldx,worldy,0,0,1024,768)
	glDrawPixels(xres,yres,GL_BGRA,GL_UNSIGNED_BYTE,Varptr(Pixels[0]))
	
	ddd=Ddd+1 ; If ddd = 4 Then boulders() ; ddd=0
	If KeyDown(49) Then Current=79 ; current2=7
    If KeyDown(50) Then Current=17 ; current2=8
    If KeyDown(51) Then Current=32 ; current2=7
    mx=MouseX()*6 ; my=MouseY()*6
	mx=mx/6 ; my=my/6 ; xxx=(worldx+mx) Sar 4 ; yyy=(worldy+my) Sar 4 
	If MouseDown(1) Then If map(xxx,yyy)<>79 And map(xxx,yyy)<>111 And map(xxx,yyy)<>112 Then map(xxx,yyy)=Current;cmap(xxx,yyy)=current2
	Delay 1 ; Flip 1
Until MouseDown(2)
End

Function alive()
For temp=1 To 16 ; buffer[Int(Rand(0,15))+Int((Rand(0,15))*128)]=$ffffffff * Int(Rand(0,1)) ; Next
currentx=(currentx+1) Mod 128 ; For tempy=0 To 15 ; For temp=0 To 15+32
buffer[16+temp+((0+tempy)*128)]=buffer[0+temp+currentx+((16+tempy)*128)] ; Next ; Next ; For temp=1 To 1600 ; cmap[Rnd(400),Rnd(250)]=Rnd(16) ; Next
End Function

Function display(worldx,worldy,ofx=0,ofy=0,sx=640,sy=400) 
scrx=worldx & 15 ; scry=worldy & 15 ; mapx=worldx Shr 4 ; mapy=worldy Shr 4
cnty = 0 ; For y=mapy To mapy+((sy Shr 4)+1)
cntx = 0 ; For x=mapx To mapx+((sx Shr 4)+1)
tilex=map(x,y) & 15 ; tiley=map(x,y) Shr 4
colour=cols(cmap(x,y))
xx=cntx - scrx + ofx ; yy=cnty - scry + ofy
For ty=0 To 7 ; For tx=0 To 7
If ((xx+tx+tx)=>ofx) And ((yy+ty+ty)=>ofy) And ((xx+tx+tx)<(ofx+sx)) And ((yy+ty+ty)<(ofy+sy))
If buffer[tilex Shl 3 + tx + (tiley Shl 3 + ty)*128] <> c Then pixels[xx+tx+tx + (yy+ty+ty)*xres] = colour 
EndIf
Next ; Next
cntx=cntx+16 ; Next
cnty=cnty+16 ; Next
End Function


Function boulders()
For y=100 To 0 Step -1 ; For x=0 To 100

If map(x,y)=79 ' BOULDER
     If map(x,y+1) = 32
        map(x,y) = 111
     ElseIf map(x,y+1) = 79 And map(x-1,y) = 32 And map(x-1,y+1) = 32
        map(x,y) = 32 ; map(x-1,y) = 111
     ElseIf map(x,y+1) = 79 And map(x+1,y) = 32 And map(x+1,y+1) = 32
        map(x,y) = 32 ; map(x+1,y) = 112 ' 111
    EndIf
EndIf

If map(x,y)=111 ' FALLINGBOULDER
     If map(x,y+1) = 32
        map(x,y)=32 ; map(x,y+1) = 111
     ElseIf map(x,y+1)=79 And map(x-1,y) = 32 And map(x-1,y+1) = 32
        map(x,y) = 32 ; map(x-1,y+0) = 111
     ElseIf map(x,y+1)=79 And map(x+1,y) = 32 And map(x+1,y+1) = 32
        map(x,y) = 32 ; map(x+1,y+0) = 112 ' 111
     Else
        map(x,y)=79
    EndIf
EndIf

If map(x,y)=112 Then map(x,y)=111 ' added

Next ; Next
End Function

Function writetomap(t$,x,y)
	For tempx=x To Len(t$)-1 ; temp=Asc(Mid$(t$,1+tempx,1)) ; map[tempx,y]=temp ; cmap[tempx,y]=14 ; Next 
End Function

#colors
DefData $000000, $FFFFFF,$68372B,$70A4B2,$6F3D86,$588D43,$352879,$B8C76F,$6F4F25,$433900,$9A6759,$444444,$6C6C6C,$9AD284,$6C5EB5,$959595



dw817(Posted 2016) [#2]
Hi Casaber. I'm trying it out. Maybe not getting the same effect as Boulderdash ?

In Boulderdash, you have a player tile that navigates around a map. There are boulders being supported by ledges. Now if the player walks through a ledge then the boulders can come crashing down.

The player is expected to retrieve jewels in the map and not get clobbered by the boulders. Additionally the player must be intelligent to know where the boulders will fall so they will not block his path from continuing through the map.

Here is a video to show the mechanics.

[a https://www.youtube.com/watch?v=FiEVfa1OK_ohttps://www.youtube.com/watch?v=FiEVfa1OK_o]VIDEO[/a].


Casaber(Posted 2016) [#3]
The left/right pushing crashing down I havn't implemented that part yet. Good point.

Let's call it. Boulder without the dash.


Casaber(Posted 2016) [#4]
My fingers are cold but it would be easy once you've got a man in the picture
The mechanics run magically in the background so if you do this

' if any boulder(O or o) where you push then if space on the boulderside = AIR then swap tiles and delay abit

If you look closely I missuse o and O to store information. I can't remember what I stored I think it has to do with the falling bit.
Ya one of those tiles are representing falling tiles and one of them represents tiles on steady ground.

You could easly use a flag for that but I used o and O to flag movement and stability.
This code has so many logical traps to get working equally on both sides. Boulders should be equally balanced
if you drop alot of them on a pointy pyramid for example. That was hard.


dw817(Posted 2016) [#5]
It's actually pretty neat what it does, Casaber. There was a series of games written for the Apple years ago that used this kind of object technology.

If you want to see a Golden Crown of this method, check out ZZT For the PC.

Every single character has an identity. Well worth investigating if you're interested in this method.

http://www.dosgamesarchive.com/download/zzt/

Many MANY games were written with it. If text characters are too primitive you can always try Megazeux. A considerably more powerful alternative w higher control over object elements.

http://vault.digitalmzx.net/index.php

One advantage of Megazeux is it runs just fine in Windows 8. ZZT, it's predecessor, however, does require DOS BOX to run best.


Casaber(Posted 2016) [#6]
Nice. Mind you though that here you have all that and also have pixel perfect position of everything .Without drawbacks, everything moved tile by tile I do on purpose (important detail).
I collected all the goodies from 1975-1995 (graphic modes I liked and features I was fond of and find useful in practice).

The rest I put in a graphic library I'm still working on called "Graphene".


Casaber(Posted 2016) [#7]
dw817 I tried to make one for you, but it's not finished lots of possible, not bugs but lots of undesisive options to make.

I wanted it to be not smooth but you know..as if the character pushed the a heavy stone and it suddenly gives away.
It didn't go all to well I think but it's a start. There's lots of questionmarks how to go about best to implement this.
Things like.. when he's inbetween 2 tiles, and both happen to be moveable stones, what to do? Anyway here it is, I wished it was abit more readable to toy around with.


But I wrote some dashes around the interesting area which controls the figure.

I forgot to say, now cursor moves man, lshift+cursor moves world.
Also I made him able to move in ONE direction at a time instead of being entirely free.
I don´t like the logic on the movement, the previous one was like a classic Pacman movement before (you know.. blockage does not hinder the free dimension). His not like that anymore. It's weird. But his not by any means finished. This is just the buggy beginning. You need to be spot on vertically to be able to move anything (which I don´t like)

I call him.. the buggy man. He's very very VERY buggy. It's sexy.




Casaber(Posted 2016) [#8]
I really did not enjoy the one direction so I got the original movement back, here, now total freedom again.



I also did something akin towards a little game
press 3 and then you can erase trash and free his way (boulders are not eraseable)




Casaber(Posted 2016) [#9]
I see there's still movement issues that are not restored. I'll check later how I solved them or I would have to use my brain right now, that will never work.
It's pixel exact collision though when hes about changing direction (as in changing from x to y or the other) e.g. if there's a wall and suddenly there is an
opening in the other dimensional direction. That's a classic detail to miss. I'll fix that.

The boulder is a bigger problem becuase I don´t see ONE way yet, I see too many possible solutions I need to try.


Wiebo(Posted 2016) [#10]
Here's a Boulderdash clone I've made some time ago. Maybe you can get some ideas from it's code: https://github.com/wiebow/boulderdash.game2d


Casaber(Posted 2016) [#11]
I got into this tile collsiion thing yesterday, it was quiet while since I did that. I takes me back.

I guess I´m intersting in perfect tile collsion with various speeds without looping everything.
I would like to do that before adding angels etc on the tiles. And then comes AA rectangles I guess. But I want to try this first - square simple tiles and square simple sprites.

I thought I solved this over 30 years ago but I have to resolve it, I would really want to do it more elegantly this time.

If you want pixel perfect collision with moving objects at any speed (upto the tilesize).
Doing it without looping each possible substep is tricky.



Say you moving an object 1 pixel to the left, while you move this direction you also want to go up in an upcoming tunnel.
That would work nicely, it would find its way. No problem. If we used tilesize (16) instead of 1 it would work equally nice,
if you started at offset of 0. Speeds of say 8, 4, or 2 Would work
equally nice for the same reasons and under the same circumstances.

But ither speeds (and offsets) would not. Say a speed of 5. That would miss that opportunity of this 1 tile wide tunnel if you had other
speed other than 1 or those special circumstances.

So, I set up 2 sensors one on each side of the object. If you're going up two upper sensors one at each corner and use them as a hotspot at a
predicted position (using +- current speed). So you're look ahead, where those two points will arrive. Air or Wall, and you do it on both sensors that's imporant.
All 4 directions works the same using 2 sensors laidout as you would expect.

If any sensor has wall then you have to tile-quantize the value (before any move has been applied using speed, we're just looking
ahead so that would be to quantized the current value) And the value would be either X or Y, depending on where you'trying to go. Up/Down or Left/right.

So that's good.

This would be like

So we could merge these into just two.

But one case is still needed and that's the one I mentioned and I tried to draw with my all too haky hands. Sorry about that. I tried me best.

To handle entering tile sized tunnels at speed greater than 1 you need to make something else aswell.

I got to this solution this time, and that is, using logic with the collision points. And to do logic I had to save the state of the
previous states aswell. Becuase the change is what is interesting. So we use the previous WALL/AIR state of those two, and logic between them.
Just as above but abit more complex.

I agree this seem overly complex, but I cannot seem to simplify this more and still have that exact detection. I really thought long about this.
I thought I´ve solved this long long time ago but I´m not sure, and if did I never did it this way but a simpler way.

But I don´t think I have those notes still with me, they are probably long gone. It´s an interesting problem though for me.
I´m not pleased with the complexity though. It's not too complex but still I feel there should be a better way I´m sure
I guess it's not that much when merge everything togerther and I will try that but that would get you a strange logic mess so
I better think well beforehand so it does not become more of a mess that it needs to be.

This is the logic that's needed
' aligning meaning tile-quantizing the value, and collisionspeed becomes the difference from that value and the original value.
' u1 and u2 are for instance the two sensores for going up, oldu1 and oldu2 are the previous states.

' It uses a clever logic of check and making sure we align the right dimension if the two are different. They can't be both AIR or both WALL then they
are uninteresting, and already taken cared of by the code above. We want to know when they are different, and when they are, we want to be sure that b
oth states where DIFFERENT inthemselves previously. Simply we're looking for AIR AND WALL (with previously WALL AND AIR)
or the other way around WALL AND AIR (with previosly AIR AND WALL).

If one those things happened then we know that we've passed a tile sized tunnel.
We only want to check this while actually moving in say x and want to go y direction. As the picture shows.

Imagine two points on that object at the top U1 (topleft) and U2 (topright). Think about the logic that happens (wall/air are true/false).
When you pass by that hole using different speeds.

Then you see why you want this AIR / WALL XOR pattern thing.

This is the code to do that (i can't find tilde right now, BMax I think uses tilde with 2 parameters as XOR) So I will try that later.



Casaber(Posted 2016) [#12]
My shaky hands, sorry about that.


Casaber(Posted 2016) [#13]
This is how I would do it normally, using looping. Speeds ill be 1 (well anything really, 00000.01 would work, to max speed being whatever size of tile you´ve using).


https://katyscode.wordpress.com/2013/01/18/2d-platform-games-collision-detection-for-dummies/


dw817(Posted 2016) [#14]
Casaber, you are welcome to make a Boulderdash classic design. You don't have to work with floating single pixels unless you want to. Instead make it on a grid and concentrate on how the objects would move on it.

Wiebo, thanks for the submit ! Hope this will help in the coding.


Casaber(Posted 2016) [#15]
Wiebo I couldn't not run that. I read the readme file and found it needs a .mod. I think that's the problem. I have not learned to install mod (I've tried few times and blew Bmax each time). Thanks though for trying and sharing.

Dw817 Maybe I'll try that sometime. I guess I just did this to learn how to use Bmax and tried to convert some old code. I think I leave both Boulderdash and subpixels for later. I would love to learn how to install a mod sometime, I really need to learn the tools.


Wiebo(Posted 2016) [#16]
You can look at the code, and see how it also can be done. You don't need to compile it.
But here is a Monkey version, up and running in the browser: http://members.home.nl/wdw/monkey/bdtest/MonkeyGame.html

Mods aren't that complicated. The only thing I can say is that you're really over complicating matters in getting some basic BD logic going. :)


Casaber(Posted 2016) [#17]
Wiebo haha I know, I just love weird problems and sometimes I take a too deep dive. Sometimes it's actually fruitful and sometimes it goes like this. Oh well.

I'll think I´ll try adding a mod again, I would love to be able to do that kind of magic.
If it doesn't work I still have your code to look into as you said, thanks again.

I've bought Monkey1 to support all upcoming projects so I might try that aswell.


dw817(Posted 2016) [#18]
Sometime tomorrow, Casaber. I'll point out an example of where every object on the screen has its own identity.

And perhaps someone can show me a smaller way to code it as the method I will be using is likely not the most efficient. :)


Casaber(Posted 2016) [#19]
Okay, I´m curious to see what's that will be. I´m still struggling with the bloody collision :( I skipped the hard way, I can't seem to be able to solve it this evening.
My brain hurts. I'm sure I´ve solved this before but I can't see what I´m doing wrong right now. I got one screen worth of code just for the collision and still doesn't work.

Try to make it go into that 1 tile sized pit. It just won´t go there.

Most tile collision routines have nasty bugs and that's what I'm trying to avoid, or they use expansive loops to manage things.

Global buffer:Int[256*256] ; Local img2:TPixmap=LoadPixmap(LoadBank("http::s9.postimg.org/rfaelk9m3/128x128.png"))
For yy=0 To 127 ; For xx=0 To 127 ; buffer(xx+yy*128) = ReadPixel(img2,xx,yy) ; Next ; Next
Global map[4096,4096] , wx:Int , wy:Int , c:Int = buffer[0] , s:Int = 2 , xres:Int = 640 , yres:Int = 480, pixels:Int[xres*yres]
Local a:Float = 0 , x:Float = 0 , y:Float = 0 , dx:Float = 0 , dy:Float = 0 , speed:Float = 0
Global space_z:Float = 50 , horizon:Int = 20, scale:Float = 1000 , obj_scale:Float = 50 , pmap:Int[1024*1024] 
Global cx ; For y=0 To 316 ; For x=0 To 475; map[x,y]=32 Next ; Next ' Clear the space

Global cmap[4096,4096] ; For y=0 To 316 ; For x=0 To 475; cmap[x,y]=5 ; Next ; Next
Global worldx,worldy,currentx ; Global cols[16] ; RestoreData colors ; For temp=0 To 15 ; ReadData cols[temp] ; Next
GLGraphics(xres,yres,0,60,GRAPHICS_BACKBUFFER | GRAPHICS_DEPTHBUFFER)
glViewport(0,0,xres,yres) ; glMatrixMode(GL_PROJECTION) ; glLoadIdentity() ; glOrtho(0,xres,yres,0,0,1) ; glPixelZoom(1,-1) ; glRasterPos2i(0,0)
s=2 ; Global Current=30, current2=7 ; Global speed2:Int=1 ; spritex = 128+8*16 ; spritey = 128+8*16

For x=13 To 25; map[x,13] = 30 ; Next ; For x=13 To 25; map[x,14]=30 ; Next ; map[20,14]=32
For y=0 To 24 ; map[0,y] = 30 ; map[39,y] = 30 ; Next ; For x=0 To 39; map[x,0]=30 ; map[x,24] = 30 ; Next
For temp = 0 To 30 ; map[Rand(0,39),Rand(0,24)] = 30 ; Next

Repeat
	For y=0 To yres-1 Step 1 ; For x=0 To xres-1 Step 1 ; pixels[(y*xres+x)] = 0 ; Next ; Next
	If KeyDown(KEY_LSHIFT) Then worldx=worldx-s*KeyDown(KEY_LEFT)+s*KeyDown(KEY_RIGHT) ; worldy=worldy-s*KeyDown(KEY_UP)+s*KeyDown(KEY_DOWN)
    worldx=Max(0,Min(10000,worldx)) ; worldy=Max(0,Min(10000,worldy))
	display(worldx,worldy,0,0,1024,768)
	drawsprite 30,spritex,spritey,worldx,worldy,0,0,16*80,16*50






' --------------------------------------------------------------------------------------------
' Collision

' Draw with mouse, change to eraser using 2 and back using 1
'
' Using 16 x 16 tiles and sprites

speed = 3
oldspritex = spritex ; oldspritey = spritey

' Read keys and create a mask for all 4 directions
wd = 0
If Not KeyDown(KEY_LSHIFT)
	If KeyDown(KEY_LEFT) Then wd = wd + 4
	If KeyDown(KEY_RIGHT) Then wd = wd + 8
	If KeyDown(KEY_UP) Then wd = wd + 1
	If KeyDown(KEY_DOWN) Then wd = wd + 2
EndIf

' For temptemp = 1 To speed
' oldspritex = spritex ; oldspritey = spritey

' Change X & Y as wanted
If wd & 4 Then spritex = spritex - speed ' 1
If wd & 8 Then spritex = spritex + speed ' 1
If wd & 1 Then spritey = spritey - speed ' 1
If wd & 2 Then spritey = spritey + speed ' 1 

' Now check for collision

' Horisontal
' oldpx1 = px1 ; oldpx1=px2 ; oldpx3 = px3 ; oldpx4 = px4
px1 = map((spritex+0)Shr 4,(oldspritey+0) Shr 4) = 30 ' check for left (30 = wall, 32 = air)
px2 = map((spritex+0)Shr 4,(oldspritey+15) Shr 4) = 30 ' check for left
px3 = map((spritex+15)Shr 4,(oldspritey+0) Shr 4) = 30 '  check for right
px4 = map((spritex+15)Shr 4,(oldspritey+15) Shr 4) = 30 ' check for right

' Vertical
' oldypy1 = py1 ; oldpy1=py2 ; oldpy3 = py3 ; oldpy4 = py4
py1 = map((oldspritex+0)Shr 4,(spritey+0) Shr 4) = 30 ' check for up
py2 = map((oldspritex+0)Shr 4,(spritey+15) Shr 4) = 30 ' check for down
py3 = map((oldspritex+15)Shr 4,(spritey+0) Shr 4) = 30 ' check for up
py4 = map((oldspritex+15)Shr 4,(spritey+15) Shr 4) = 30 ' check for down

' Horisontal
If wd & 4 Then If px1 Or px2 Then spritex = Int((spritex+0)/16)*16 + 16
If wd & 8 Then If px3 Or px4 Then spritex = Int((spritex+15)/16)*16 - 16
' If wd & 4 Or wd & 8 Then If (py1 ~ oldpy1 And py3 ~ oldpy3) Or (py2 ~ oldpy2 And py4 ~ oldpy4) Then spritey = Int((spritey+0)/16)*16

' Vertical
If wd & 1 Then If py1 Or py3 Then spritey = Int((spritey+0)/16)*16 + 16
If wd & 2 Then If py2 Or py4 Then spritey = Int((spritey+15)/16)*16 - 16
' If wd & 1 Or wd & 2 Then If (px1 ~ oldpx1 And px2 ~ oldpx2) Or (px3 ~ oldpx3 And px4 ~ oldpx4) Then spritex = Int((spritex+0)/16)*16

' Next
writenumber(spritex,0,1)

' --------------------------------------------------------------------------------------------










	glDrawPixels(xres,yres,GL_BGRA,GL_UNSIGNED_BYTE,Varptr(Pixels[0]))
	If KeyDown(49) Then Current=30
    If KeyDown(50) Then Current=32
    mx=MouseX()*6 ; my=MouseY()*6
	mx=mx/6 ; my=my/6 ; xxx=(worldx+mx) Sar 4 ; yyy=(worldy+my) Sar 4 
	If MouseDown(1) Then map(xxx,yyy)=Current ; cmap(xxx,yyy)=5
	Delay 1 ; Flip 1
Until MouseDown(2)
End

Function display(worldx,worldy,ofx=0,ofy=0,sx=640,sy=400) 
	scrx=worldx & 15 ; scry=worldy & 15 ; mapx=worldx Shr 4 ; mapy=worldy Shr 4
	cnty = 0 ; For y=mapy To mapy+((sy Shr 4)+1)
	cntx = 0 ; For x=mapx To mapx+((sx Shr 4)+1)
	tilex=map(x,y) & 15 ; tiley=map(x,y) Shr 4
	colour=cols(cmap(x,y))
	xx=cntx - scrx + ofx ; yy=cnty - scry + ofy
	For ty=0 To 7 ; For tx=0 To 7
		If ((xx+tx+tx)=>ofx) And ((yy+ty+ty)=>ofy) And ((xx+tx+tx)<(ofx+sx)) And ((yy+ty+ty)<(ofy+sy))
		If buffer[tilex Shl 3 + tx + (tiley Shl 3 + ty)*128] <> c Then pixels[xx+tx+tx + (yy+ty+ty)*xres] = colour 
	EndIf
	Next ; Next
	cntx=cntx+16 ; Next
	cnty=cnty+16 ; Next
End Function

Function drawsprite(sprite,xx,yy,worldx,worldy,ofx=0,ofy=0,sx=640,sy=400)
	xx=xx-worldx ; yy=yy-worldy ' xx,yy is now screen coordinates
	tilex=sprite & 15 ; tiley=sprite Shr 4 ; colour=cols(1)
	For ty=0 To 7 ; For tx=0 To 7
	    If ((xx+tx+tx)=>ofx) And ((yy+ty+ty)=>ofy) And ((xx+tx+tx)<(ofx+sx)) And ((yy+ty+ty)<(ofy+sy))
		If buffer[tilex Shl 3 + tx + (tiley Shl 3 + ty)*128] <> c Then pixels[xx+tx+tx + (yy+ty+ty)*xres] = buffer[tilex Shl 3 + tx + (tiley Shl 3 + ty)*128] ; pixels[xx+tx+tx + 1 + (yy+ty+ty)*xres] = buffer[tilex Shl 3 + tx + (tiley Shl 3 + ty)*128]
	EndIf
	Next ; Next
End Function

Function writenumber(v,x,y) ' handles -9999 to 9999
	If v < 0 Then sign = True ; x = x + 1 ; v = Abs(v) Else sign = False
	numbase = 48 ' ASCII for 0
	
	digits = 1
	thousands = Int ( v / 1000)
	hundreds = Int ((v - thousands * 1000) / 100) 
	tens = Int ((v - thousands * 1000 - hundreds * 100)  / 10)
	units = Int v - thousands * 1000 - hundreds * 100 - tens * 10

	If tens <> 0 Then digits = 2
	If hundreds <> 0 Then digits = 3
	If thousands <> 0 Then digits = 4

	x=x+digits-1
	map(x,y) = numbase + units ; ; cmap(x,y) = 1 ; x = x - 1 
	If digits >= 2 Then map(x,y) = numbase + tens ; ; cmap(x,y) = 1; x = x - 1
	If digits >= 3 Then map(x,y) = numbase + hundreds ; ; cmap(x,y) = 1 ; x = x - 1
    If digits >= 4 Then map(x,y) = numbase + thousands ; cmap(x,y) = 1 ; x = x - 1 
	If sign Then map(x,y) = 45 ; cmap(x,y) = 1
End Function

#colors
DefData $000000, $FFFFFF,$68372B,$70A4B2,$6F3D86,$588D43,$352879,$B8C76F,$6F4F25,$433900,$9A6759,$444444,$6C6C6C,$9AD284,$6C5EB5,$959595



dw817(Posted 2016) [#20]
Pretty nifty, Casaber. I noticed the player cannot slide diagonally (up and right arrow key) to fit into the reverse U opening you made in the map.

How would you change your code so it can do this ?

Sliding elsewhere (diagonal keys) against a solid object work great, however. It doesn't stop the player and the player keeps moving in the only direction it can until the map changes.


Casaber(Posted 2016) [#21]
Well that's my problem. I´m not sure if I should change the technique dramatically, but if I may solve this then this is a cheap collision for strict 90 degree tilemaps. Cheaper than pure vector collision when you add slopes and simplify it abit. When the bug is out of the way.

Horisontal collision works flawlessly on its own, and vertical aswell, As long as you do one way or the other there's no problem but when you combine them it breaks down.
I would like to keep out special cases of diagnoal movement..

So far I use the oldspritex & oldspritey variables To still keep the dimensions separate in the actual tests, but something's missing.
I´m not sure what direction to make but I think I'll stick to this and try solve this.. or I'll have nightmares becuase it bugs the hell out of me haha. Ya I know.. nerdy. I confess.


dw817(Posted 2016) [#22]
One easy result I am seeing of this diagonal collision, Casaber, is that the player bounces about a bit. If you think it's too much work to determine the diagonal, be aware of when the player gets caught in this bounce and then move towards the path of least resistance.

What you are doing here is a bit of work, granted. I know back in QBasic I was working on making a solid square navigate neatly and diagonally around other hollow squares on the screen. Lots of coding.

Remember - you also have the unique collision() function available in BlitzMAX if you don't mind collisions detected at a pixel level.


Casaber(Posted 2016) [#23]
You could do what NES Zelda did aswell, (it remembers the x direction and y direction, and when you move in x and the other say y is not perfectly aligned to the tiles, then for each move in x it actually also makes a move in y. Link sneaks into alignment.

This way you feel very free and never get stuck anywhere and helps to aim at enemeys and makes it very friendly. It's a nice solution.

It's pretty much as you said but it aims towards into a natural path. But I think randomised is a must at perfect 45 angles though.
Becuase when you have no 90 degrees walls but you do have a 45 degreee wall and just HAPPEN to go into that using a perfect diagonal then actually
you get a shaking player, as x and y alternates of being winning the path. I wouldn't call that a bug yet its related to this problem I think.


Casaber(Posted 2016) [#24]
But I really want to do this clinica collision, i know I've done it at least 2 times in my life, but I cannot remember what I did,

I'm not even sure if I've missed any details like this but I don´t think so, as it was a big deal back then aswell. I put lot of weeks on to solve it.
More than you should put into anything not important in life haha.
But seriously. It's so frustrating.

Coding.. you can't live with it you can't live without it.


Casaber(Posted 2016) [#25]
I reached this now, it has a few lines of code to diagonal special case and loop, not what I want but if anyone wants it. Be my guest :)
Hopefully soon I will have a more elegant code.

Mind that this is WIP and middle of everything. It's not finished polished code. But it is stable. Just sharing what I have that works.

Try build a diagonal without supporting 90 degrees walls and approach that tile perfectly diagnoally using a / b key and you see the "shakey bug"
where it cannot decide where to go, it alternates between x & y. Other than this it works (this wobblyness is replaced with
another nasty effect when you use full tile speed of 16)

EDIT
I have a vauge memory of solving this using few lines and MOD, but sadly I can't remember exactly how I did it,
It's always interesting trying new approaches I guess, but this is kind of clumpsy in all it's trickery glory.

' Stream some background music
Import MaxGui.Drivers
Local window:TGadget , mainview:tgadget , htmlview:tgadget

Global buffer:Int[256*256] ; Local img2:TPixmap=LoadPixmap(LoadBank("http::s9.postimg.org/rfaelk9m3/128x128.png"))
For yy=0 To 127 ; For xx=0 To 127 ; buffer(xx+yy*128) = ReadPixel(img2,xx,yy) ; Next ; Next
Global map[4096,4096] , wx:Int , wy:Int , c:Int = buffer[0] , s:Int = 2 , xres:Int = 640 , yres:Int = 480, pixels:Int[xres*yres]
Local a:Float = 0 , x:Float = 0 , y:Float = 0 , dx:Float = 0 , dy:Float = 0 , speed:Float = 0
Global space_z:Float = 50 , horizon:Int = 20, scale:Float = 1000 , obj_scale:Float = 50 , pmap:Int[1024*1024] 
Global cx ; For y=0 To 316 ; For x=0 To 475; map[x,y]=32 Next ; Next ' Clear the space

Global cmap[4096,4096] ; For y=0 To 316 ; For x=0 To 475; cmap[x,y]=5 ; Next ; Next
Global worldx,worldy,currentx ; Global cols[16] ; RestoreData colors ; For temp=0 To 15 ; ReadData cols[temp] ; Next
GLGraphics(xres,yres,0,60,GRAPHICS_BACKBUFFER | GRAPHICS_DEPTHBUFFER)
glViewport(0,0,xres,yres) ; glMatrixMode(GL_PROJECTION) ; glLoadIdentity() ; glOrtho(0,xres,yres,0,0,1) ; glPixelZoom(1,-1) ; glRasterPos2i(0,0)
s=2 ; Global Current=30, current2=7 ; Global speed2:Int=1 ; spritex = 128+8*16 ; spritey = 128+8*16

For x=13 To 25; map[x,13] = 30 ; Next ; For x=13 To 25; map[x,14]=30 ; Next ; map[20,14]=32
For y=0 To 24 ; map[0,y] = 30 ; map[39,y] = 30 ; Next ; For x=0 To 39; map[x,0]=30 ; map[x,24] = 30 ; Next
For temp = 0 To 30 ; map[Rand(0,39),Rand(0,24)] = 30 ; Next

intro = worldy+25*16
worldy = intro
Repeat
	For y=0 To yres-1 Step 1 ; For x=0 To xres-1 Step 1 ; pixels[(y*xres+x)] = 0 ; Next ; Next
	If KeyDown(KEY_LSHIFT) Then worldx=worldx-s*KeyDown(KEY_LEFT)+s*KeyDown(KEY_RIGHT) ; worldy=worldy-s*KeyDown(KEY_UP)+s*KeyDown(KEY_DOWN)
    worldx=Max(0,Min(10000,worldx)) ; worldy=Max(0,Min(10000,worldy))
	display(worldx,worldy,0,0,640,480)
	drawsprite 30,spritex,spritey,worldx,worldy,0,0,16*80,16*50


If intro > 0 intro = intro - 2 ; worldy = intro
If intro = 0 Then window=CreateWindow("",0,0,0,0,,0) ; htmlview=CreateHTMLView(0,0,0,0,window) ; HtmlViewGo htmlview,"http://bit.ly/22Cv21e" ; intro = -1 ' Dw817's nice stream music trick

writetomap("[Shift] to scroll inside world",8,0,1)
writetomap("1 and 2 - draw and erase using mouse",2,24,1)






' --------------------------------------------------------------------------------------------
' Collision

' Draw with mouse, change to eraser using 2 and back using 1
'
' Using 16 x 16 tiles and sprites

speed = 3
oldspritex = spritex ; oldspritey = spritey

' Read keys and create a mask for all 4 directions
wd = 0
If Not KeyDown(KEY_LSHIFT)
	If KeyDown(KEY_LEFT) Then wd = wd + 4
	If KeyDown(KEY_RIGHT) Then wd = wd + 8
	If KeyDown(KEY_UP) Then wd = wd + 1
	If KeyDown(KEY_DOWN) Then wd = wd + 2
EndIf

If KeyDown(KEY_A) Then wd = 8 + 1 ' test diagnally movement with a..
If KeyDown(KEY_B) Then wd = 4 + 2 ' ..and b

' Change X & Y as wanted
If wd & 4 Then spritex = spritex - speed
If wd & 8 Then spritex = spritex + speed
If wd & 1 Then spritey = spritey - speed
If wd & 2 Then spritey = spritey + speed 

' Now check for collision

' Horisontal
' oldpx1 = px1 ; oldpx2=px2 ; oldpx3 = px3 ; oldpx4 = px4
px1 = map((spritex+0)Shr 4,(oldspritey+0) Shr 4) = 30 ' check for left (30 = wall, 32 = air)
px2 = map((spritex+0)Shr 4,(oldspritey+15) Shr 4) = 30 ' check for left
px3 = map((spritex+15)Shr 4,(oldspritey+0) Shr 4) = 30 '  check for right
px4 = map((spritex+15)Shr 4,(oldspritey+15) Shr 4) = 30 ' check for right

' Vertical
' oldpy1 = py1 ; oldpy2=py2 ; oldpy3 = py3 ; oldpy4 = py4
py1 = map((oldspritex+0)Shr 4,(spritey+0) Shr 4) = 30 ' check for up
py2 = map((oldspritex+0)Shr 4,(spritey+15) Shr 4) = 30 ' check for down
py3 = map((oldspritex+15)Shr 4,(spritey+0) Shr 4) = 30 ' check for up
py4 = map((oldspritex+15)Shr 4,(spritey+15) Shr 4) = 30 ' check for down

orgspritex = spritex ; orgspritey = spritey
diagonal = False

For temptemp = speed To 1 Step -1

' Diagonal
pxy1 = map((spritex+0)Shr 4,(spritey+0) Shr 4) = 30
pxy2 = map((spritex+0)Shr 4,(spritey+15) Shr 4) = 30
pxy3 = map((spritex+15)Shr 4,(spritey+0) Shr 4) = 30
pxy4 = map((spritex+15)Shr 4,(spritey+15) Shr 4) = 30

' Diagonal (first thing that needs to be tried)
If wd = (4 + 1) Then If (pxy1 + pxy2 + pxy3 + pxy4) = 0 Then diagonal = True ' spritex = Int((spritex+0)/16)*16 + 16
If wd = (4 + 2) Then If (pxy1 + pxy2 + pxy3 + pxy4) = 0 Then diagonal = True ' spritex = Int((spritex+0)/16)*16 + 16
If wd = (8 + 1) Then If (pxy1 + pxy2 + pxy3 + pxy4) = 0 Then diagonal = True ' spritex = Int((spritex+0)/16)*16 + 16
If wd = (8 + 2) Then If (pxy1 + pxy2 + pxy3 + pxy4) = 0 Then diagonal = True ' spritex = Int((spritex+0)/16)*16 + 16

If diagonal = False
	If wd & 4 Then spritex = spritex + 1
	If wd & 8 Then spritex = spritex - 1
	If wd & 1 Then spritey = spritey + 1
	If wd & 2 Then spritey = spritey - 1
EndIf

Next

If diagonal = False

spritex = orgspritex ; spritey = orgspritey

' Horisontal
If wd & 4 Then If px1 Or px2 Then spritex = Int((spritex+0)/16)*16 + 16 ' spritex = spritex - spritex Mod 16
If wd & 8 Then If px3 Or px4 Then spritex = Int((spritex+15)/16)*16 - 16 ' spritex = spritex - spritex mod 16
' If wd & 4 Or wd & 8 Then If (py1 ~ oldpy1 And py3 ~ oldpy3) Or (py2 ~ oldpy2 And py4 ~ oldpy4) Then spritey = Int((spritey+0)/16)*16

' Vertical
If wd & 1 Then If py1 Or py3 Then spritey = Int((spritey+0)/16)*16 + 16 ' spritey = spritey mod 16
If wd & 2 Then If py2 Or py4 Then spritey = Int((spritey+15)/16)*16 - 16 ' spritey = spritey mod 16
' If wd & 1 Or wd & 2 Then If (px1 ~ oldpx1 And px2 ~ oldpx2) Or (px3 ~ oldpx3 And px4 ~ oldpx4) Then spritex = Int((spritex+0)/16)*16

EndIf

writenumber(spritex,0,1)

' --------------------------------------------------------------------------------------------















	glDrawPixels(xres,yres,GL_BGRA,GL_UNSIGNED_BYTE,Varptr(Pixels[0]))
	If KeyDown(49) Then Current=30
    If KeyDown(50) Then Current=32
    mx=MouseX()*6 ; my=MouseY()*6
	mx=mx/6 ; my=my/6 ; xxx=(worldx+mx) Sar 4 ; yyy=(worldy+my) Sar 4 
	If MouseDown(1) Then map(xxx,yyy)=Current ; cmap(xxx,yyy)=5
	Delay 1 ; Flip 1
Until False 'MouseDown(2)
End

Function display(worldx,worldy,ofx=0,ofy=0,sx=640,sy=400) 
	scrx=worldx & 15 ; scry=worldy & 15 ; mapx=worldx Shr 4 ; mapy=worldy Shr 4
	cnty = 0 ; For y=mapy To mapy+((sy Shr 4)+1)
	cntx = 0 ; For x=mapx To mapx+((sx Shr 4)+1)
	tilex=map(x,y) & 15 ; tiley=map(x,y) Shr 4
	colour=cols(cmap(x,y))
	xx=cntx - scrx + ofx ; yy=cnty - scry + ofy
	For ty=0 To 7 ; For tx=0 To 7
		If ((xx+tx+tx)=>ofx) And ((yy+ty+ty)=>ofy) And ((xx+tx+tx)<(ofx+sx)) And ((yy+ty+ty)<(ofy+sy))
		If buffer[tilex Shl 3 + tx + (tiley Shl 3 + ty)*128] <> c Then pixels[xx+tx+tx + (yy+ty+ty)*xres] = colour 
	EndIf
	Next ; Next
	cntx=cntx+16 ; Next
	cnty=cnty+16 ; Next
End Function

Function drawsprite(sprite,xx,yy,worldx,worldy,ofx=0,ofy=0,sx=640,sy=400)
	xx=xx-worldx ; yy=yy-worldy ' xx,yy is now screen coordinates
	tilex=sprite & 15 ; tiley=sprite Shr 4 ; colour=cols(1)
	For ty=0 To 7 ; For tx=0 To 7
	    If ((xx+tx+tx)=>ofx) And ((yy+ty+ty)=>ofy) And ((xx+tx+tx)<(ofx+sx)) And ((yy+ty+ty)<(ofy+sy))
		If buffer[tilex Shl 3 + tx + (tiley Shl 3 + ty)*128] <> c Then pixels[xx+tx+tx + (yy+ty+ty)*xres] = buffer[tilex Shl 3 + tx + (tiley Shl 3 + ty)*128] ; pixels[xx+tx+tx + 1 + (yy+ty+ty)*xres] = buffer[tilex Shl 3 + tx + (tiley Shl 3 + ty)*128]
	EndIf
	Next ; Next
End Function

Function writetomap(t$,x,y,c)
	For tempx = 0 To Len(t$)-1 ; temp = Asc(Mid$(t$,1+tempx,1)) ; map[tempx+x,y] = temp ; cmap[tempx+x,y] = c ; Next
End Function

Function writenumber(v,x,y) ' handles -9999 to 9999
	
	For digits = 5 To 1 Step -1 ; map(x+digits-1,y) = 32 ; Next ' erase area
	
	If v < 0 Then sign = True ; x = x + 1 ; v = Abs(v) Else sign = False
	numbase = 48 ' ASCII for 0
	
	digits = 1
	thousands = Int ( v / 1000)
	hundreds = Int ((v - thousands * 1000) / 100) 
	tens = Int ((v - thousands * 1000 - hundreds * 100)  / 10)
	units = Int v - thousands * 1000 - hundreds * 100 - tens * 10

	If tens <> 0 Then digits = 2
	If hundreds <> 0 Then digits = 3
	If thousands <> 0 Then digits = 4

	x=x+digits-1
	map(x,y) = numbase + units ; ; cmap(x,y) = 1 ; x = x - 1 
	If digits >= 2 Then map(x,y) = numbase + tens ; ; cmap(x,y) = 1; x = x - 1
	If digits >= 3 Then map(x,y) = numbase + hundreds ; ; cmap(x,y) = 1 ; x = x - 1
    If digits >= 4 Then map(x,y) = numbase + thousands ; cmap(x,y) = 1 ; x = x - 1 
	If sign Then map(x,y) = 45 ; cmap(x,y) = 1
End Function

#colors
DefData $000000, $FFFFFF,$68372B,$70A4B2,$6F3D86,$588D43,$352879,$B8C76F,$6F4F25,$433900,$9A6759,$444444,$6C6C6C,$9AD284,$6C5EB5,$959595



Casaber(Posted 2016) [#26]
Just toying around..
This is for the ones who like a small puzzle.

Welcome.. to messy world.

Try finding the easteregg without glancing at the code :)



I have decided to not yet make boulders pushing collsion, as I want to perfect the collision first. I got some ideas,
5 actually, some are overlapping so I want to explore that area. Abit exciting.I woke up and was all clear in my mind. How unusual.




dw817(Posted 2016) [#27]
POW ! Crashes out when you drag the mouse out of the graphics field when in DEBUG mode, Casaber.

I didn't hear any background music ?


Casaber(Posted 2016) [#28]
Ya the music makes it unstable, somehow, did I miss something GUIwise? I can tell you it gives silent errors on Mac but it won't crash.

I figured that on Bmax it's GUI and Mac there are issues so I left the music in.

You just have to wait for some sec and don't touch anything before its playing and then you need also to click the window to make it active as the music makes it unactive.
Do you know a way to make the windows automacally active after playing music?

Mac gets silent errors and also complains with beeps as the keyboard is not routed. So you need to click manually. I really wanted music though.
After that everything's fine and you can play the game, the game itself shouldn't crash after it have started.


Casaber(Posted 2016) [#29]
I'm glad that regarding collisions everything works perfect now except the diagonal problem, which you never get to see in practice. But I will fix it anyways. So I will try some of my newer solutions later and see which one that seem most elegant.

This is a good start though, It never gets stuck and it never misses a pixel. Supertight.


dw817(Posted 2016) [#30]
I see while I received no comments on my Kaleidoscope, the music player method I wrote for it apparently went to good use in your code, Casaber. :)

KALEIDOSCOPE SOURCE.

That's fine. And yes, run your program in DEBUG mode, click inside the window (where it is not full-screen), then holding down the left mouse button, drag to outside the window.

It's always a good idea to run your program in DEBUG mode. Now while you may be thinking turning off debug ignores errors, the answer to that is YES and NO.

YES, no error message appears, NO, you ARE doing damage, likely to memory pointers and around your array by forcing numbers to appear outside the designated space you allocated for it.

In time, your program will be worse than crashing, but overwriting bits of important data saved in the runtime, giving bizarre numeric results, and this will clearly show up with repeated use.


Bobysait(Posted 2016) [#31]
you should use superstrict mode, it will highlight all variables you failed to initialize, and the arrays are not supposed to be accessed with "( )", but with "[ ]"

I did it just to be able to understand your code, and I fixed some issues with "out of bound" exception ...
sorted stuff by relevance, so it's more clear what is where.

My apologize for the whole indentation and rebuild, I know some people don't like when we update their code ... so, no offense, it's just for others who might think it's not readable as you posted it.



ps : I replace the for/next to fill the map with some DefData.
It's not really nice to code with old basic things, but it's a bit less boring for me.


Casaber(Posted 2016) [#32]
About superstricmode I´m learning that. So.. it's coming up.

Will check that code later, thanks so very much.
I guess my working code is not much to share when it comes to comprehensio, It's just that.. I love to share.

You have a point though, what you cannot understand there is not point of sharing. It gives a sense of being social and sharing ideas. I love that. Still.. ya.

I guess it will be very lonesome to code from now on.


dw817(Posted 2016) [#33]
Well, if not SUPERSTRICT, use STRICT, Casaber. The main difference is you won't have to type out INTEGER for variables that are not defined via the standard $ and #.

local a,b,c ' Strict
local a:int,b:int,c:int ' Superstrict


Now if you plan to use more advanced variables than just INT, FLOAT (#), and STRING ($), then SUPERSTRICT just might be a good idea at that. But yes, please use one or the other.

And you should NEVER define any opening variables as GLOBAL unless you are absolutely certain you want to carry their results to your function() routines.

Some GOOD examples of global variables would be an array that carries the game map, loaded images saved as TIMAGE or TPIXMAP, audio as LOADSOUND, fonts as LOADIMAGEFONT, and music as TCHANNEL and LOADSOUND.

Perhaps a few dedicated variables that you want to be able to know the value in each and every function you write.

Some BAD examples of global would be throwaway variables needed for simple calculations and/or variables in use with FOR/NEXT loops.

For instance, if you defined variable i to be global and then in one of your functions you used a FOR/NEXT loop with it but did not earlier define it as LOCAL, while it would work, when you exit that function, the value of i would ALSO be changed back in your main code causing possible untold mayhem later.


Casaber(Posted 2016) [#34]
dw817 I did mention you? Did you not see that?

I've seen those error codes before in all kinds of scenarios though most of the time it was pure GUI related guff.
You think it does damage? Ya I think you're right. I never felt comfortable using those GUI commands. But I sortof panicced and used them
just to be able to get streaming music.


Casaber(Posted 2016) [#35]
I will go all the way, SUPERSTRICT or nothing haha :) I need to build a style that suits the tool. I need to get comfterable with BMax before I can tell you what I will settle for.

My hopes are, that SUPERSTRICT are well thought through and that I will like it.


Casaber(Posted 2016) [#36]
Anyways, hope you like it, and enjoy it.


Casaber(Posted 2016) [#37]
I feel that I should learn Bmax better before posting any more, that way I could write readable code for ppl. This could take quiet some time.

So you won´t see me for awhile I guess. I hate that as I love to be able to be social and share things inbetween work. But it won´t work I think. It just gets too cryptic for ppl I begin to reliase.


Bobysait(Posted 2016) [#38]
Yep, Superstrict is really a convenient way to code, it prevents many errors in the syntax ...

By the way, i don't know if you already know it, but the way you stream audio won't work on all OS.
Regarding the default internet browser that the window will get the htmlview embedded in, the javascript stuff may or not be available/activated, so, as youtube stuff is full of js and ajax or probably other advanced stuff, it won't stream anything and will just return an error that won't be displayed. You'll just get a black screen.

So, it's probably not a very good way to stream audio.
I've never tried to stream audio so I won't give you a better way, but I'm pretty sure there are plenty of solution that better fit the purpose.



So you won´t see me for awhile I guess. I hate that as I love to be able to be social and share things inbetween work. But it won´t work I think. It just gets too cryptic for ppl I begin to reliase.



Don't be afraid to post messy codes, we're used to that :)
Actually, I love this retro style you posted, that's the reason why I tried to make it more clean, but there is no reason you should stop here.
I think there is something interesting in your code, but probably not accessible to beginners. As I said, no offense, it's really just for people who "would'nt" understand your code that I updated it. And as you can see, I understood it, so it worth to be posted.


dw817(Posted 2016) [#39]
It's a good program, Casaber. Superstrict is too much for me. Reminds me of coding in C.

But no-one is going to discredit you for using Superstrict, and I suspect in time it will help you pin down difficult errors too.

And yes, I see dw817. Just a little miffed my Kaleidoscope fell into obscurity. But it's not the first nor likely the last. :)

As for your code being too cryptic. That's no reason to disappear. Just write code w comments.

Believe me, the more you do it the more it will help YOU, not just other people understand it.

And you should always deeply comment your code for major projects, including adding a bunch of comments before the code to remind you what you are doing and what you are trying to achieve.