dungeons of mysteria code
👉 BlitzCoder will be building a new platform and other plans to preserve and continue the Blitz legacy.
To be able to achieve this goal, we need your support by becoming a Patreon Paid Member 👈
Tweet
so I decided to release a small chunk of the Code for dungeons of mysteria.
It shows dungeon generation, one type of enemy, melee weapon, long range weapon ect
https://grindalf.itch.io/dungeons-of-mysteria-code
Its not great but it might be useful to somebody
This is nice! while you're at it.. perhaps you can add the Doom-like angle based sprite change.
I have a code on that, but on javascript and somehow lost it.
Aside from the left to right hand coordinate conversion, it should be straightforward and you are not using 2D commands for this demo which makes it more easier.
+Y is still up, +X is still right but counter clockwise rotation, and +Z is now pointing towards the screen.
I'd null or dummy out the Sound commands in the meantime for later addition when it becomes available.
btw, why gosub instead of function for the createmaze?
would also take a shot on this when I get a chance.
when I was learning programming I taught myself from reading examples and just reading the command reference And Gosub was the command I found and used. Later I was told that I should never use Gosub and that Function was better(I was also told never to use Goto)
And for years I followed this advice until one day I thought why? Function is great in some places but more often than not I am just doing extra work trying to pass variables into and out of a function(I think gosub just works better with my brain)
fair point.. as long as it runs smoothly and without problems.
when I was learning programming I taught myself from reading examples
same here, learn by example.. but I did move pass gosubs and gotos
Best use of Function is it breaks down tasks and also makes code components portable.. along with having globals and locals so your code is more optimized.
I see you have used 3D arrays there, so in CBase/C this is like BlitzMax arrays
int grid[2][2][3]; //Dim grid(2,2,3)
// then assigning a specific value
grid[1][1][1] = 10;
did some initial porting with the dungeon generator part on Blast3D CBase, so far it falls into place..
Nothing much was changed, just the optional and default parameters needs to be filled-out to a few commands Rand(3)
should be Rand(1,3)
.
A bit of the tedious part is the syntax and case sensitivity but once you get a handle of it, it will be easy. Of course, C semicolons are a must.. 😄
snippet..
//place initial room
int tmpx2,tmpz2;
for tmpx2 in tmpx to tmpx+sizex do
for tmpz2 in tmpz to tmpz+sizez do
//place floors
if grid[tmpx2][tmpz2][1]==0 do;
grid[tmpx2][tmpz2][1]=1;grid[tmpx2][tmpz2][3]=1;
end
//-place walls
if grid[tmpx2][tmpz][2]==0 then grid[tmpx2][tmpz][2]=1;
if grid[tmpx2][tmpz+sizez][2]==0 then grid[tmpx2][tmpz+sizez][2]=1;
if grid[tmpx][tmpz2][2]==0 then grid[tmpx][tmpz2][2]=1;
if grid[tmpx+sizex][tmpz2][2]==0 then grid[tmpx+sizex][tmpz2][2]=1;
end
end
also found walltex2
is undeclared ✌🏻
and there's always this room full of pillars..? 😄
Oooh this is nice to see, It may help me make the switch to Blast3D(for my next project, which was going to use parts of this code ;) )
If you finish it and get it working I can add it to the itch download and link here to blast3D if you want(not that it gets many downloads, aprox 1 download every 10days )
Sure thing Grindalf, that sounds good.
..and btw this port now uses functions 😉
function preload as () of void do;
walltex1=LoadBrush("files/textures/brick1.png",1,1,1);
walltex2=LoadBrush("files/textures/brick1.png",1,1,1);
floortex1=LoadBrush("files/textures/tile2.png",1,1,1);
rooftex1=LoadBrush("files/textures/tile1.png",1,1,1);
enemy1_1=LoadTexture("files/enemies/rat1.png",4);
enemy1_2=LoadTexture("files/enemies/rat2.png",4);
enemy1_3=LoadTexture("files/enemies/rat3.png",4);
fireballanim=LoadAnimTexture("files/attacks/fireanim.png",4,16,16,0,3);
firesound=LoadSound("files/sounds/burn.wav");
hitsound=LoadSound("files/sounds/hit.wav");
explosionsound=LoadSound("files/sounds/explosion.wav");
slashsound=LoadSound("files/sounds/swordslash.wav");
end
Grindalf, somehow the current setup does not work with Pivot (campiv/player) to Pivot (enemy) collisions.
So the solution would be to simulate with a mesh/sprite as the collision and child it to the player. What would be the setup for this demo?
Update: It seems the player to enemy collision is no longer needed since it only checks for distance.
I was told that I should never use Gosub and that Function was better(I was also told never to use Goto)
@Grindalf>> there is no reason to not use Goto, this is repeated bullshit that it leads to spaghetti code...
i myself use Goto inside a function when i need to build a structure procedurally (and go back to a previous line in the same function).
i have never had a single problem because of that and i have coded some pretty complex stuff...
just make sure to write descriptive labels (same remark for functions names), so that it is easier to debug...
not sure why you would use Gosub however...
@RemiD Yes it took me many years to learn that, I was peer pressured into not using goto but now I am free :P
I find that Gosub and function for the most part work the same but in the case of Function if I want to use variables inside it they have to be declared when the function is called or declared global at the begining of the code. With Gosub this is not the case and it tends to just work easier for me the way I code(I could probably do with using function more than I do though)
@Grindalf btw, Blast3D will also support Goto and Label statements and Gosub is almost like Goto just by adding a return label.. 😊
Reply To Topic (minimum 10 characters)
Please log in to reply