yea well
hit iseus,
local r = {x=2,y=2,w=dungeon.w,h=dungeon.h} add (rooms,r)
these things dont translate well
theres allot of variables idk what you want to do with them
im sorry i cant convert this
yea well
hit iseus,
local r = {x=2,y=2,w=dungeon.w,h=dungeon.h} add (rooms,r)
these things dont translate well
theres allot of variables idk what you want to do with them
im sorry i cant convert this
This is the same as this from the code (with variables changed):
Beginning of code:
public Rooms(int xx, int yy, int rW, int rH){
x = xx;
y = yy;
w = rW;
h = rH;
The code you are looking at.
room[1] = new Rooms(2,2,dungeon.h,dungeon.w);
I had to change it because pico 8 does not use tables/arrays like c does.
Edit: you can actually change the room[1] to room[0], but anywhere later on when you start looking through the table of rooms you will need to change its beginning (from 1 to 0, 2 to 1 and so on).
i dont know where thats even from, i thought you where using my code
do you know c++?
anyway im just going to wait for @trelemar since i cant be botherd anymore on the level gen
Nope, I am using this thing you posted earlier today.
Never used c++ apart from trying to decipher the examples in past few days. I can try to port my code to pokitto, but it wonāt be fast, and I am pretty sure I wonāt have it ready for the jam deadline
I can ask around for someoneās help on twitter.
I should (hopefully) have progress to show tonight with my method. Weāre gonna miss the jam. Thatās a given. Now the question is, Are you guys still down? The jam was never motivation for me to begin with.
Its inspiring to watch all of you working on this. I hope you do not stop even if the CGAjam is missed.
And ahem ā¦ we have also been thinking about a pokittojam ā¦ with a real prize
the jam would have been some nice marketing to let people know we are around, better luck next jam.
do wanna keep the cga colors kinda got used to them with our first iteration of this, since im prety sure we will add more stuff then was planned for jam later on. do wanna have some scheduling and keep it progress up, cuz i also have a sidescroller that needs some love after this
Are you all sure you cant make a simple roguelike? There is 3 days left.
Whatās the biggest problem at the moment? The room generation ?
Edit: gamejams have some pretty unfinished / simple entries usually. I would not be so critical. it would be a great way to introduce Pokitto to people who have not heard about it.
This weekend I have been contacted by email by 5 people wanting to buy a Pokitto. The word is just starting to get out there.
we have been trying the map generation for like 3 days XD
And you need someone to turn a Lua routine to C++ ? I can help.
Yes we need translation from pico-8 lua to c++
This is the dungeon gen that seems to have best results so far, but I only know how to program on pico-8 so this is what I have.
It is based on the code from here.
As for the game. I would love to make an expanded post jam version, even if we donāt make it to the jamā¦ but I would not like to keep the cga palette. With 256 (man even with 32) color 1bit tiles we can make the game look amazing!
Translator activated ā¦
Awesome! Let me know if you have any questions, because my code is a newbie flavored mess I will keep on checking the thread every now and then.
The lua language reference is a PITA, because try searching for a keyword āaddā
What does this do:
local r = {x=2,y=2,w=dungeon.w,h=dungeon.h}
add (rooms,r)
edit: local is clear, but clarify āaddā for me
I think ADD is pico-8 specific.
Look here: Roguelike port?
I makes the first entry in the rooms array with the following vars: {x=2,y=2,w=dungeon.w,h=dungeon.h}
In the original code it was this (I changed the variables to reflect mine):
room[1] = new Rooms(2,2,dungeon.w,dungeon.h);
edit: fixed w and h placement in example!
Isnāt add the equivalent of table.insert?
Edit:
add == table.insert
add t v
Add value v to the end of table t.
Equivalent to t[#t+1] = v
FOO={} -- create empty table
ADD(FOO, 11)
ADD(FOO, 22)
PRINT(FOO[2]) -- 22
I need to head out, but I will be back in an hour or so and start working on item sprites.
I have worked a bit more on the dungeon gen (made the doors work and such), but I wonāt add to the translation effort.
Thanks for your help @jonne! We can do this guys!
I am 70% done. I need to step out for a while as well
edit: continuing now
#define MAX_ROOMS 100 // 100 rooms max, I don't want to get into dynamic memory allocation here
struct Dungeon {
uint8_t tiles[];
uint8_t w;
uint8_t h;
}; // Dungeon structure definition
Dungeon dungeon = {.w=48, .h=32, .tiles[48*32] = NULL}; // make a Dungeon instance called "dungeon"
uint8_t wall_h = 1; //global variable wall_h, type is unsigned char (8 bits) value 0..255
uint8_t grid_w=0, grid_h=0, room_size=4; // multiple variables of same type can be declare in 1 row
/* ---------------
mapgen starts here
----------------*/
/* this is one type of comment in C */
// this is 1 row comment in C++
// decide on max iterations
void mapgen(Dungeon& d) {
// void means function does not return anything, {} mark the beginning and end of function
// Dungeon& is a reference to a Dungeon instance
// blank the tile array
for (int i=0; i<dung.w; i++) {
for (int j=0; j<d.h; j++) {
d.tiles[i][j]=1; // all tiles set to 1 initially
}
}
}
// add outside walls
for (int i=0; i<d.w; i++) {d.tiles[i]=2;d.tiles[(d.h-1)*d.w+i]=2;} //horiz walls
for (int i=0; i<d.h; i++) {d.tiles[i*d.w]=2;d.tiles[i*(d.w)-1]=2;} //ver walls
}
void make_rooms(Dungeon& d) {
struct Room {
uint8_t w;
uint8_t h;
uint8_t x;
uint8_t y;
}; // define structure Room
Room rooms[MAX_ROOMS];
for (int i=0; i<MAX_ROOMS; i++) {
// not the cleanest way but ...
rooms[i].x=2; rooms[i].y=2; rooms[i].w=d.w; rooms[i].h=d.h;
}
int ii=1;
while (ii >= 1 ) {
uint8_t wall_orientation = 2;
// check room dimension and change wall orientation accordingly
if (rooms[ii].w < rooms[ii].h) {
if (rooms[ii].h >= 2*room_size+2) wall_orientation = 0;
} else if (rooms[ii].w > rooms[ii].h) {
if (rooms[ii].w >= 2*room_size+2) wall_orientation = 1;
} else {
if (rooms[ii].w >= 2*room_size+2) wall_orientation = random(0,2);
}
if (wall_orientation != 2) {
int wx;
if (wall_orientation == 1) wx=random(1+room_size, rooms[ii].w-room_size);
if (d.tiles[rooms[ii].x+wx-1][rooms[ii].y-1]==2 || d.tiles[rooms[ii].x+wx-1][rooms[ii].y+rooms[ii].h] == 2) {
if (random(1,3) == 1) wx++;
else wx--;
}
}
for (int yy=2 //** continuing from here **/
}
}
I read the discussion about the map generation a few hours ago and thought I would try to write a simple map generator in C as well. Iām not sure it will be needed if you manage to port the Lua map generator, but hereās what I have so far:
Iām still working on dealing with some of the rooms being too large, but it has 2-tile vertical doors and 1-tile horizontal doors.
Here is the source:
Itās still kind of messy since itās a WIP and I was trying to put it together as fast as possible.
Thats really good. Iām translating the lua to c++ on the fly and Iām not even sure it works.
Testingā¦
#define MAX_ROOMS 100 // 100 rooms max, I don't want to get into dynamic memory allocation here
struct Dungeon {
uint8_t tiles[];
uint8_t w;
uint8_t h;
}; // Dungeon structure definition
Dungeon d = {.w=48, .h=32, .tiles[48*32] = NULL}; // make a Dungeon instance called "d"
uint8_t wall_h = 1; //global variable wall_h, type is unsigned char (8 bits) value 0..255
uint8_t grid_w=0, grid_h=0, room_size=4; // multiple variables of same type can be declare in 1 row
/* ---------------
mapgen starts here
----------------*/
/* this is one type of comment in C */
// this is 1 row comment in C++
// decide on max iterations
void mapgen() {
// void means function does not return anything, {} mark the beginning and end of function
// Dungeon& is a reference to a Dungeon instance
// blank the tile array
for (int i=0; i<d.w; i++) {
for (int j=0; j<d.h; j++) {
d.tiles[i][j]=1; // all tiles set to 1 initially
}
}
}
// add outside walls
for (int i=0; i<d.w; i++) {d.tiles[i]=2;d.tiles[(d.h-1)*d.w+i]=2;} //horiz walls
for (int i=0; i<d.h; i++) {d.tiles[i*d.w]=2;d.tiles[i*(d.w)-1]=2;} //ver walls
}
void make_rooms() {
struct Room {
int8_t w;
int8_t h;
int8_t x;
int8_t y;
}; // define structure Room
Room rooms[MAX_ROOMS];
for (int i=0; i<MAX_ROOMS; i++) {
// not the cleanest way but ...
rooms[i].x=2; rooms[i].y=2; rooms[i].w=d.w; rooms[i].h=d.h;
}
int ii=1;
while (ii >= 1 ) {
uint8_t wall_orientation = 2;
// check room dimension and change wall orientation accordingly
if (rooms[ii].w < rooms[ii].h) {
if (rooms[ii].h >= 2*room_size+2) wall_orientation = 0;
} else if (rooms[ii].w > rooms[ii].h) {
if (rooms[ii].w >= 2*room_size+2) wall_orientation = 1;
} else {
if (rooms[ii].w >= 2*room_size+2) wall_orientation = random(0,2);
}
if (wall_orientation != 2)
{
if (wall_orientation == 1)
{
int wx=random(1+room_size, rooms[ii].w-room_size);
if (d.tiles[rooms[ii].x+wx-1][rooms[ii].y-1]==2 || d.tiles[rooms[ii].x+wx-1][rooms[ii].y+rooms[ii].h] == 2) {
if (random(1,3) == 1) wx++;
else wx--;
}
for (int yy=2, yy<rooms[ii].h, yy++) d.tiles[rooms[ii].x+wx-1][rooms[ii].y+yy]=2;
d.tiles[rooms[ii].x+wx-1][rooms[ii].y]=34; //door?
rooms[ii+1].x = rooms[ii].x+wx;
rooms[ii+1].y = rooms[ii].y;
rooms[ii+1].w = rooms[ii].w-wx;
rooms[ii+1].h = rooms[ii].h;
rooms[ii].w=wx-1;
} else {
int wy = random (1+room_size,rooms[ii].h-room_size);
if (d.tiles[rooms[ii].x-1][rooms[ii].y-1] == 18 || d.tiles[rooms[ii].x+rooms[ii].w][rooms[ii].y+wy-1] == 18) {
if (random(1,3)==1) wy++;
else wy--;
}
for (int xx = 2; xx < rooms[ii].w; xx++) d.tiles[rooms[ii].x+xx][rooms[ii].y+wy-1] = 2;
d.tiles[rooms[ii].x][rooms[ii].y+wy-1] = 18;
rooms[ii+1].x = rooms[ii].x;
rooms[ii+1].y = rooms[ii].y+wy;
rooms[ii+1].w = rooms[ii].w;
rooms[ii+1].h = rooms[ii].h-wy;
rooms[ii].h=wy-1;
}
ii++;
} else {
ii--;
}
} // while ii
} // makerooms