So I made a thread asking if anyone was interested in MadTV, didn't get much response but I will start to report progress here anyway.
On Sunday (29/12) I made a little code to generate random maps and yesterday I added a code to transform the map into an image so the game can show the player just the image instead of having to build each element of the map when showing it.
The code is really simple, I just wanted to do something fast that could give a reasonable result.
Yesterday I made the qml part as to display the map on a window regardless of the map size, zoom in, zoom out and drag.
Some parameters you can enter when creating the map:
A 20x30 map, the value goes from 100 to 0, 100 being maximum population for a point (square) of the map.
Water is -1.
A bigger map without water, 60x90:
A map with zoom applied:
The american version of MadTV had a USA map while the original german version had a Germany map.
Since I want all aspects of the game to be randomized, I thought it would be great to start with random maps.
Now I will create random categories for the movies tweak the map to also tell how much each point likes each category.
So when you want to buy a new tower, you will not only want to maximize population but also to find an area where they like the categories that you use more often.
Feel free to talk about the game MadTV or give suggestion, critic to this project.
EDIT: Here is a great faq about MadTV http://www.gamefaqs.com/pc/581730-mad-tv/faqs/38558
EDIT2: Source code: http://git.purpleorangegames.com/purpleorangetv
On Sunday (29/12) I made a little code to generate random maps and yesterday I added a code to transform the map into an image so the game can show the player just the image instead of having to build each element of the map when showing it.
Code:
void PurpleOrangeTV::setWorld(int row, int col, bool waterOnLeftRight, bool waterOnTopBottom, double percertOfPopulation, double percentOfWater)
{
m_row=row;
emit rowChanged();
m_col=col;
emit colChanged();
for (int i=0;i<row;i++)
for (int j=0;j<col;j++)
if (waterOnLeftRight && j==0)
m_worldMap[i][j]=-1;
else if (waterOnLeftRight && j==col-1)
m_worldMap[i][j]=-1;
else if (waterOnTopBottom && i==0)
m_worldMap[i][j]=-1;
else if (waterOnTopBottom && i==row-1)
m_worldMap[i][j]=-1;
else
m_worldMap[i][j]=0;
qulonglong seedPoints=row*col*0.05;
qulonglong waterPoints = qFloor(randInt(seedPoints*3,seedPoints*5)*percentOfWater);
if (!waterOnLeftRight && !waterOnTopBottom) waterPoints=0;
while (waterPoints>0)
{
int x=randInt(0,row-1);
int y=randInt(0,col-1);
if ((m_worldMap.contains(x) && m_worldMap[x].contains(y) && m_worldMap[x][y]==0)
&& ((m_worldMap.contains(x-1) && m_worldMap[x-1].contains(y) && m_worldMap[x-1][y]==-1)
|| (m_worldMap.contains(x+1) && m_worldMap[x+1].contains(y) && m_worldMap[x+1][y]==-1)
|| (m_worldMap.contains(x) && m_worldMap[x].contains(y-1) && m_worldMap[x][y-1]==-1)
|| (m_worldMap.contains(x) && m_worldMap[x].contains(y+1) && m_worldMap[x][y+1]==-1) ))
{
m_worldMap[x][y]=-1;
waterPoints--;
}
}
while (seedPoints>0)
{
int x=randInt(0,row-1);
int y=randInt(0,col-1);
if (m_worldMap[x][y]==0)
{
m_worldMap[x][y]=100;
seedPoints--;
}
}
qulonglong popPoints=qFloor(row*col*20*percertOfPopulation);
while (popPoints>0)
{
int x=randInt(0,row-1);
int y=randInt(0,col-1);
if ((m_worldMap.contains(x) && m_worldMap[x].contains(y) && m_worldMap[x][y]==0)
&& ((m_worldMap.contains(x-1) && m_worldMap[x-1].contains(y) && m_worldMap[x-1][y]>0)
|| (m_worldMap.contains(x+1) && m_worldMap[x+1].contains(y) && m_worldMap[x+1][y]>0)
|| (m_worldMap.contains(x) && m_worldMap[x].contains(y-1) && m_worldMap[x][y-1]>0)
|| (m_worldMap.contains(x) && m_worldMap[x].contains(y+1) && m_worldMap[x][y+1]>0) ))
{
QList<int> aux;
if (m_worldMap.contains(x-1) && m_worldMap[x-1].contains(y) && m_worldMap[x-1][y]>0) aux<<m_worldMap[x-1][y];
if (m_worldMap.contains(x+1) && m_worldMap[x+1].contains(y) && m_worldMap[x+1][y]>0) aux<<m_worldMap[x+1][y];
if (m_worldMap.contains(x) && m_worldMap[x].contains(y-1) && m_worldMap[x][y-1]>0) aux<<m_worldMap[x][y-1];
if (m_worldMap.contains(x) && m_worldMap[x].contains(y+1) && m_worldMap[x][y+1]>0) aux<<m_worldMap[x][y+1];
double value=0;
for (int i=0;i<aux.count();i++)
value+=aux[i];
value/=aux.count();
m_worldMap[x][y]=qFloor(value)-randInt(5,25);
if (m_worldMap[x][y]<0) m_worldMap[x][y]=0;
if (m_worldMap[x][y]>popPoints)
popPoints=0;
else
popPoints-=m_worldMap[x][y];
}
}
for (int i=0;i<row;i++)
{
QStringList aux;
for (int j=0;j<col;j++)
aux<<QVariant(m_worldMap[i][j]).toString();
setNewWorldLine(aux);
}
m_worldMapImage=QPixmap(col*m_mapBlockSize,row*m_mapBlockSize);
m_worldMapImage.fill(QColor("#d3a665"));
QPainter painter(&m_worldMapImage);
for (int i=0;i<row;i++)
{
for (int j=0;j<col;j++)
{
painter.setOpacity(1);
painter.setPen(QColor("#2c3e8b"));
painter.setBrush(QColor("#2c3e8b"));
if (m_worldMap[i][j]>-1)
{
painter.setPen(QColor("#d20606"));
painter.setBrush(QColor("#d20606"));
painter.setOpacity((double)m_worldMap[i][j]/100.0);
}
painter.drawRect(j*m_mapBlockSize,i*m_mapBlockSize,m_mapBlockSize-1,m_mapBlockSize-1);
if (m_worldMap[i][j]==-1)
{
double opacity=(double)randInt(2,5)/10.0;
painter.setOpacity(opacity);
painter.setPen(QColor("#005952"));
painter.setBrush(QColor("#005952"));
painter.drawRect(j*m_mapBlockSize,i*m_mapBlockSize,m_mapBlockSize-1,m_mapBlockSize-1);
}
}
}
}
The code is really simple, I just wanted to do something fast that could give a reasonable result.
Yesterday I made the qml part as to display the map on a window regardless of the map size, zoom in, zoom out and drag.
Some parameters you can enter when creating the map:
A 20x30 map, the value goes from 100 to 0, 100 being maximum population for a point (square) of the map.
Water is -1.
A bigger map without water, 60x90:
A map with zoom applied:
The american version of MadTV had a USA map while the original german version had a Germany map.
Since I want all aspects of the game to be randomized, I thought it would be great to start with random maps.
Now I will create random categories for the movies tweak the map to also tell how much each point likes each category.
So when you want to buy a new tower, you will not only want to maximize population but also to find an area where they like the categories that you use more often.
Feel free to talk about the game MadTV or give suggestion, critic to this project.
EDIT: Here is a great faq about MadTV http://www.gamefaqs.com/pc/581730-mad-tv/faqs/38558
EDIT2: Source code: http://git.purpleorangegames.com/purpleorangetv
Last edited: