Welcome, Guest

Author Topic: Map War 3 (WIP)  (Read 44865 times)

Bla

  • Global Moderator
  • *****
  • Posts: 1013
  • The stars died so you can live.
Map War 3 (WIP)
« on: October 28, 2011, 03:38:53 AM »
I see Nue began making a program he posted in the Map War 2 topic.
Well I also started one on Tuesday in NetBeans (Java), on that date I learned how to define my own classes.
I'll need to learn a lot of more things before I can make it even close to a game. We haven't learned anything about graphics yet.

Here's the code so far:

Main file (MapWar3.java):
Code: [Select]
// Made by Bla.
package map.war.pkg3;
public class MapWar3
{
    public static void main(String[] args)
    {
        // Make the user's nation, let the user give it a name, name the leader and give the nation 5 resources.
        java.util.Scanner tastatur = new java.util.Scanner(System.in);
        Nation Nat1;
        Nat1 = new Nation();
        System.out.print("Write the name of your nation and press enter: ");
        Nat1.Name = tastatur.next();
        System.out.print("What is your name, mighty ruler of "+Nat1.Name+"? ");
        Nat1.Ruler = tastatur.next();
        System.out.println("Your name is "+Nat1.Ruler+".");
        Nat1.Resources = 5;

        // Generate 7 to 16 other nations.
        int NationNumber;
        NationNumber = (int)(Math.round((Math.random())*9+7));
        System.out.println("Number of other nations: "+NationNumber);
    }
}

Nation class file (Nation.Java):
Code: [Select]
package map.war.pkg3;
public class Nation
{
    public String Ruler;
    public String Name;
    public double Zones;
    public double Resources;
    public double Technology;
    public double Trade;
    public double SeaBases;
    
    public double Production()
    {
        double Prod;
        Prod = ((Zones - SeaBases) + (Resources) + (Trade / 5) + (Math.pow(Technology,0.6)));
        return Prod;
    }  
}

So I'll update this post with progress.
Other attempts to make this game are also welcome in this thread.

atomic7732

  • Global Moderator
  • *****
  • Posts: 3848
  • caught in the river turning blue
    • Paladin of Storms
Re: Map War 3 (WIP)
« Reply #1 on: October 28, 2011, 06:24:35 AM »
So my further additions to "Map War 2: the Game" should be posted here?

Bla

  • Global Moderator
  • *****
  • Posts: 1013
  • The stars died so you can live.
Re: Map War 3 (WIP)
« Reply #2 on: October 28, 2011, 06:42:27 AM »
Yes, I think so, or in a seperate topic if you prefer that.

Darvince

  • *****
  • Posts: 1842
  • 差不多
Re: Map War 3 (WIP)
« Reply #3 on: October 28, 2011, 07:13:58 AM »
wtf i don't even

FiahOwl

  • *****
  • Posts: 1234
  • This is, to give a dog and in recompense desire my dog again.
Re: Map War 3 (WIP)
« Reply #4 on: October 28, 2011, 10:44:54 AM »

This message is only viewable with Universe Sandbox Galaxy Edition. Access it and much more with promo-code '45930'.

« Last Edit: March 22, 2021, 01:48:27 AM by FiahOwl »

Bla

  • Global Moderator
  • *****
  • Posts: 1013
  • The stars died so you can live.
Re: Map War 3 (WIP)
« Reply #5 on: October 28, 2011, 10:46:38 AM »
Thanks, right now I don't know anything about graphics, but I will probably read the chapters about interfaces and graphics some day.

FiahOwl

  • *****
  • Posts: 1234
  • This is, to give a dog and in recompense desire my dog again.
Re: Map War 3 (WIP)
« Reply #6 on: October 28, 2011, 10:47:11 AM »

This message is only viewable with Universe Sandbox Galaxy Edition. Access it and much more with promo-code '45933'.

« Last Edit: March 22, 2021, 01:48:22 AM by FiahOwl »

Bla

  • Global Moderator
  • *****
  • Posts: 1013
  • The stars died so you can live.
Re: Map War 3 (WIP)
« Reply #7 on: October 28, 2011, 12:53:59 PM »
I read a few things in the book

Main
Code: [Select]
// Made by Bla.
package map.war.pkg3;
public class MapWar3
{
    public static void main(String[] args)
    {
        // Make the user's nation, let the user give it a name, name the leader and give the nation 5 resources.
        java.util.Scanner tastatur = new java.util.Scanner(System.in);
        Nation Nat1;
        Nat1 = new Nation();
        System.out.print("Write the name of your nation and press enter: ");
        Nat1.Name = tastatur.next();
        System.out.print("What is your name, mighty ruler of "+Nat1.Name+"? ");
        Nat1.Ruler = tastatur.next();
        System.out.println("Your name is "+Nat1.Ruler+".");
        Nat1.Resources = 5;

        // Generate 7 to 16 other nations.
        int NationNumber;
        NationNumber = (int)(Math.round((Math.random())*9+7));
        System.out.println("Number of other nations: "+NationNumber);
        Nation[] Nat = new Nation[NationNumber];
       
        //Choose a random, premade map.
        Map WorldMap;
        WorldMap = new Map();
    }
}

Nation class - same as before, just removed "public" before the variables, because they are public by default.

Map class
Code: [Select]
package map.war.pkg3;
import java.awt.*;
public class Map extends Frame
{
    String MapName;
}
Not much yet...

And I just made an interface, but Idk what to do at all.
Code: [Select]
package map.war.pkg3;
public interface Interface
{
    //public void setPosition(0,0);
   
    //public void draw(Graphics g);
}

deoxy99

  • Universe Sandbox 1 Beta Team
  • *****
  • Posts: 872
  • ✨ the name's verb ✨
Re: Map War 3 (WIP)
« Reply #8 on: October 28, 2011, 02:37:10 PM »
Okay, a generator in Dwarf Fortress for names goes like this. It takes a dictionary of words, with their translations into Dwarven language, and combines these words (like Dakri Bowapple) and translates them into it...

You could probably try to find that dictionary, and use it for your own purposes. :P

atomic7732

  • Global Moderator
  • *****
  • Posts: 3848
  • caught in the river turning blue
    • Paladin of Storms
Re: Map War 3 (WIP)
« Reply #9 on: October 28, 2011, 02:46:36 PM »
Yes, I think so, or in a seperate topic if you prefer that.
I don't think we really need separate topics, although what if your game or mine finishes first? The "(WIP)" or the lack thereof would not count for mine :P

matty406

  • *****
  • Posts: 82
Re: Map War 3 (WIP)
« Reply #10 on: October 28, 2011, 02:59:12 PM »
Okay, a generator in Dwarf Fortress for names goes like this. It takes a dictionary of words, with their translations into Dwarven language, and combines these words (like Dakri Bowapple) and translates them into it...

You could probably try to find that dictionary, and use it for your own purposes. :P
Pretty much, and, as it happens, I have a copy here.
There's also Elf, Human and Goblin name banks. They're phenomenally in depth. (So much so I can even generate rude names in the languages :P)
« Last Edit: October 28, 2011, 03:06:08 PM by matty406 »

atomic7732

  • Global Moderator
  • *****
  • Posts: 3848
  • caught in the river turning blue
    • Paladin of Storms
Re: Map War 3 (WIP)
« Reply #11 on: October 28, 2011, 08:26:52 PM »
Bla, if you were to describe your flag (your avatar one) and how it describes your nation, how would you do so? I'd like to put that in the game on the selection screen even though it has little relevance to the game itself.

Also, if anyone else would like to describe theirs it'd be useful to me as well.

The screen below is probably the starting screen as it will be when released... Unless someone decides to change their flag...  :-\

And also the .exe for today... which I'll probably stop uploading because... idk exactly.
« Last Edit: October 28, 2011, 09:29:54 PM by NeutronStar »

Bla

  • Global Moderator
  • *****
  • Posts: 1013
  • The stars died so you can live.
Re: Map War 3 (WIP)
« Reply #12 on: October 29, 2011, 12:32:59 AM »
Nice.
(Btw, it's the Blaxian Space State, but just use "Blaland" instead).

Flag: The green color represents the enlightment our people gains from Science, the cyan color represents the Technology it gives our people and the blue color represents the bright Future of our state.

FiahOwl

  • *****
  • Posts: 1234
  • This is, to give a dog and in recompense desire my dog again.
Re: Map War 3 (WIP)
« Reply #13 on: October 29, 2011, 02:47:15 PM »

This message is only viewable with Universe Sandbox Galaxy Edition. Access it and much more with promo-code '46003'.

« Last Edit: March 22, 2021, 01:47:59 AM by FiahOwl »

atomic7732

  • Global Moderator
  • *****
  • Posts: 3848
  • caught in the river turning blue
    • Paladin of Storms
Re: Map War 3 (WIP)
« Reply #14 on: October 29, 2011, 03:47:30 PM »
I realized that last night. You'll be added when I get around to working on the game for today.

FiahOwl

  • *****
  • Posts: 1234
  • This is, to give a dog and in recompense desire my dog again.
Re: Map War 3 (WIP)
« Reply #15 on: December 24, 2011, 06:35:13 PM »

This message is only viewable with Universe Sandbox Galaxy Edition. Access it and much more with promo-code '50666'.

« Last Edit: March 22, 2021, 01:42:55 AM by FiahOwl »

Bla

  • Global Moderator
  • *****
  • Posts: 1013
  • The stars died so you can live.
Re: Map War 3 (WIP)
« Reply #16 on: January 12, 2012, 11:37:18 AM »
So we have to make a graphics journal/report, so I chose Map War 2 as the project I wanted to make for it (considered a galaxy image generator, but I have more of an itch to make progress on Map War 2, I've worked on it during most of the breaks since I chose it as my project :P).

Right now, the map is a square divided into smaller squares... It has to be either 1x1, 2x2, 3x3, 4x4, 5x5, 6x6 and so on... So far, all you can do is setting the name of your nation and your leader (which doesn't affect gameplay anyway :P) and choose which zone you want to start on. Then the game will paint that zone red. Which I just chose to be the national color of nation 1. Then it makes 3-5 other nations which don't do anything yet anyway. But I set up the turn and round structure which automagically adapts to the number of nations. And each second, it tells me what round and turn it is, which is very relaxing.

I bet I'll have to make the zones a two-dimensional array *rageragerage*.

Here's the code and a skreenshawt:

Code: (Main class) [Select]
package mapwar2;
import java.awt.Color;
public class MapWar2
{
    public static void main(String[] args)
    {
        //Make the user's nation, let the user give it a name, name the leader and give the nation 5 resources.
        java.util.Scanner tastatur = new java.util.Scanner(System.in);
        Nation Nat1;
        Nat1 = new Nation();
        Nat1.NatColor = Color.red;
        System.out.print("Write the name of your nation and press enter: ");
        Nat1.Name = tastatur.next();
        System.out.print("What is your name, mighty leader of "+Nat1.Name+"? ");
        Nat1.Leader = tastatur.next();
        Nat1.Resources = 5;

        //Generate 2 to 5 other nations.
        int NationNumber;
        NationNumber = (int)(Math.round((Math.random())*4+2));
        System.out.println("Number of other nations: "+NationNumber);
        Nation[] Nat = new Nation[NationNumber-1];
        
        //Create the map.
        Map Map = new Map();
        Map.addZones();
        
        Map.zRepaint = false;
        GraphicsWindow window = new GraphicsWindow(); //Creates the graphics window.
        window.setSize(Map.sqrtZoneNumber*101+19,Map.sqrtZoneNumber*101+39); //Sets the size of the window.
        window.setTitle("Map War 2"); //Sets the title of the window.
        window.setVisible(true); //Shows the window.
        
        for (int Round=1;;Round++) //Rounds loop
        {
            for (int Turn=1;Turn<NationNumber+1;Turn++) //Turns loop
            {
                System.out.println("It is now round "+Round+", turn "+Turn); //Shows the current round and turn.
                if (Round == 1 && Turn == 1) //The first turn in the game...
                {
                    System.out.println("Type the x coordinate of the zone you want to start on (starts at 0) and press Enter. Then type the y coordinate and press Enter.");
                    Map.xstart = tastatur.nextInt();
                    Map.ystart = tastatur.nextInt();
                    Map.zRepaint = true;
                }
                try {Thread.sleep(1000);} catch (Exception e) {}
            }
        }
    }
}

Code: (Graphics window class) [Select]
package mapwar2;
import java.awt.*;
public class GraphicsWindow extends Frame
{
    public void paint(Graphics g)
    {
        //Draw background.
        g.fillRect(8, 28, Map.sqrtZoneNumber*101+3, Map.sqrtZoneNumber*101+3);
        
        //Draw initial zones on map.
        g.setColor(Color.WHITE);
        for (int i=0; i<Map.ZoneNumber; i++)
        {
            g.fillPolygon(Map.z[i].Shape);
        }
        
        for(;;)
        {
            if (Map.zRepaint == true)
            {
                g.setColor(Color.red);
                g.fillPolygon(Map.z[(Map.sqrtZoneNumber*Map.ystart+Map.xstart)].Shape);
                Map.zRepaint = false;
            }
        }
    }
}

Code: (Nation class) [Select]
package mapwar2;
import java.awt.*;
public class Nation
{
    String Leader;
    String Name;
    Color NatColor; //National color
    double Zones;
    double Production;
    double Resources;
    double Technology;
    double Trade;
    
    double CityLvl1; //Costs 4 resources, gives 1 production.
    double CityLvl2; //Costs 7 resources, gives 2 production.
    double CityLvl3; //Costs 13 resources, gives 4 production.
    double CityLvl4; //Costs 25 resources, gives 8 production.
    double CityLvl5; //Costs 50 resources, gives 20 production.
    
//Calculates the production of a nation.
    double Production()
    {
        double Prod;
        Prod = Zones + CityLvl1 + (2 * CityLvl2) + (4 * CityLvl3) + (8 * CityLvl4) + (20 * CityLvl5);
        return Prod;
    }
    
//Calculates the resources of a nation, should be done once a turn.
    double Resources()
    {
        double Res;
        Res = Production + Resources + (Trade / 5) + (Technology / 10) - (Resources * Resources / 1000);
        return Res;
    }

Code: (Map class) [Select]
package mapwar2;
public class Map
{
    public static int ZoneNumber = 25; //Number of zones on the map. Must be the result of squaring an integer.
    public static int sqrtZoneNumber = (int)Math.round(Math.sqrt(ZoneNumber)); //Used for determining zones pr. map height/width.
    public static int ZoneReference = 0; //References which zone in the zone array methods should be called on.
    public static Zone[] z = new Zone[ZoneNumber]; //Creates the array of zones.
    public static boolean zRepaint;
    public static int xstart;
    public static int ystart;
    
    //Adds zones to the map:
    public static void addZones()
    {
        for (int i=0; i<sqrtZoneNumber; i++)
        {
            for (int k=0; k<sqrtZoneNumber; k++)
            {
                z[ZoneReference] = new Zone();
                z[ZoneReference].setShape();
                z[ZoneReference].Shape.translate(101*i, 101*k);
                ZoneReference++;
            }
        }
    }
}[/quote]

[quote=Zone class]package mapwar2;
import java.awt.*;
public class Zone extends Polygon
{  
    public String Owner;
    public Polygon Shape;
    
    public Polygon setShape()
    {
        Polygon s = new Polygon();
        s.addPoint(10, 30);
        s.addPoint(110, 30);
        s.addPoint(110, 130);
        s.addPoint(10, 130);
        Shape = s;
        return s;
    }
    
    public void claim(String claimer, Nation Nat)
    {
        Owner = claimer;
        Nat.Resources = Nat.Resources - 5;
        Nat.Production ++;
    }
}

Oh and also, teachers can scan our documents for being similar to content on the internet, so I guess I'll be convicted and eternally banned from educat-ions for plagiarizing from myself now. Kol.
« Last Edit: January 12, 2012, 12:30:18 PM by Bla »

Bla

  • Global Moderator
  • *****
  • Posts: 1013
  • The stars died so you can live.
Re: Map War 3 (WIP)
« Reply #17 on: April 24, 2012, 12:27:24 PM »
A snall smapshot of the progress, I'll make the code public when summer vakashunz because skool is skary and I'm afraid of blagiarizing from myshelf.
(The production in the bottom is not correct on the snapshot, because I didn't set the program to calculate the production during turns. I have fixed this now.)

Enemies do claim zones, conquer zones and build infrastructure. So far I haven't tried losing, though, they're pretty random.

The nation and leader names are randomly taken from two .txt files. In the first line, they contain a number of how many names they contain (one pr. line). If you just write the correct number of names, you can basically enter as many custom names as you want in the files and the program will pick and combine them randomly for the AI nations.
« Last Edit: April 24, 2012, 12:39:02 PM by Bla »

atomic7732

  • Global Moderator
  • *****
  • Posts: 3848
  • caught in the river turning blue
    • Paladin of Storms
Re: Map War 3 (WIP)
« Reply #18 on: April 24, 2012, 03:49:35 PM »
Awesome. I should maybe attempt Project Geodash again...

blotz

  • Formerly 'bong'
  • *****
  • Posts: 813
  • op pls
Re: Map War 3 (WIP)
« Reply #19 on: April 24, 2012, 04:22:51 PM »
uh, i hope that that is just a behind-the-scene thingy.
« Last Edit: April 24, 2012, 04:28:20 PM by bong »

Darvince

  • *****
  • Posts: 1842
  • 差不多
Re: Map War 3 (WIP)
« Reply #20 on: September 14, 2012, 09:00:00 PM »
plagarizing yourself? what is this i don't even

deoxy99

  • Universe Sandbox 1 Beta Team
  • *****
  • Posts: 872
  • ✨ the name's verb ✨
Re: Map War 3 (WIP)
« Reply #21 on: September 14, 2012, 09:33:39 PM »
This don't I even what is.

Bla

  • Global Moderator
  • *****
  • Posts: 1013
  • The stars died so you can live.
Re: Map War 3 (WIP)
« Reply #22 on: September 15, 2012, 02:14:29 AM »
plagarizing yourself? what is this i don't even
My teachers wouldn't know if I was Bla on this forum. They'd scan the report to see if something like that is on the internet. If they found all the code on the internet I don't think they would be amused. They might not even check this forum but just see that x% of the report matched internet stuff.

Hellpotatoe

  • *****
  • Posts: 230
  • JooJ
Re: Map War 3 (WIP)
« Reply #23 on: September 15, 2012, 03:22:15 AM »
Hey, were's Iz-Lato Flags? :P
Oh, i don't make any flags to them...
Okay  :(

Darvince

  • *****
  • Posts: 1842
  • 差不多
Re: Map War 3 (WIP)
« Reply #24 on: October 27, 2012, 08:02:05 PM »
sugg

Darvince

  • *****
  • Posts: 1842
  • 差不多
Re: Map War 3 (WIP)
« Reply #25 on: August 11, 2013, 08:08:37 PM »

Bla

  • Global Moderator
  • *****
  • Posts: 1013
  • The stars died so you can live.
Re: Map War 3 (WIP)
« Reply #26 on: November 09, 2013, 01:29:03 PM »
Vh seems good at Python, would he be interested in a collaborative Map War 3 Python development possibly? Anyone else maybe?

My other question would be, would Python be a good language to write the game in? (Otherwise we should find the language that would be best to use, I have most experience with Java)

Some of the biggest problems I had with the Java thing was that I had no clue how I could ever make it generate anything like the complex zone shapes we have on our maps, but that would be a nice thing to do.
Hexagonal zones could be an improvement over the square ones if we couldn't figure out a way to build the complex ones. Ideally I would want the game to randomly generate complex maps similar to the ones we use, but that would probably require a lot of programming skills.

With square or hexagonal it could at least assign random features to the zones, like mountains or water.

And I never got around to try making an interface in Java, but it seems possible. Idk if Python is good for that.

atomic7732

  • Global Moderator
  • *****
  • Posts: 3848
  • caught in the river turning blue
    • Paladin of Storms
Re: Map War 3 (WIP)
« Reply #27 on: November 09, 2013, 02:29:22 PM »
python is possible but i've heard from kip tkinter is impossible and idk about pygame but that might be possible

(protip: i have and have used pygame, but only a little bit)
« Last Edit: November 09, 2013, 03:13:05 PM by atomic7732 »

FiahOwl

  • *****
  • Posts: 1234
  • This is, to give a dog and in recompense desire my dog again.
Re: Map War 3 (WIP)
« Reply #28 on: November 09, 2013, 02:49:24 PM »

This message is only viewable with Universe Sandbox Galaxy Edition. Access it and much more with promo-code '112648'.

« Last Edit: March 22, 2021, 01:28:23 AM by FiahOwl »

vh

  • formerly mudkipz
  • *****
  • Posts: 1140
  • "giving heat meaning"
Re: Map War 3 (WIP)
« Reply #29 on: November 09, 2013, 03:23:26 PM »
python is possible but i've heard from kip tkinter is impossible and idk about pygame but that might be possible

(protip: i have and have used pygame, but only a little bit)

tkinter isn't too bad actually. just need to organize code well and understand it

Vh seems good at Python, would he be interested in a collaborative Map War 3 Python development possibly? Anyone else maybe?

My other question would be, would Python be a good language to write the game in? (Otherwise we should find the language that would be best to use, I have most experience with Java)

Some of the biggest problems I had with the Java thing was that I had no clue how I could ever make it generate anything like the complex zone shapes we have on our maps, but that would be a nice thing to do.
Hexagonal zones could be an improvement over the square ones if we couldn't figure out a way to build the complex ones. Ideally I would want the game to randomly generate complex maps similar to the ones we use, but that would probably require a lot of programming skills.

With square or hexagonal it could at least assign random features to the zones, like mountains or water.

And I never got around to try making an interface in Java, but it seems possible. Idk if Python is good for that.

tkinter (a python gui thingy), allows images polygons, and getting the clicked shape

about generating maps, it could be done with voronoi cells

anyways if you're interested sure why not. we should find a good online code editor with maybe syntax highlighting, non-laggyness, and search/replace.

also an outline of the structure of the program would be good.

since the game is now processing all the turns, the players will probably be less inclined to check the map. there should be a way to prevent modifications to the game save or whatever.

there could be a server that computes the resources and everything. manipulating sockets in python is relatively pain-free.
or maybe the map is sort of savefile, and an interface allows each player to issue orders, saved as another turnfile. then a public piece of code modifies the savefile according to each turnfile in the player order.



« Last Edit: November 09, 2013, 03:35:46 PM by vh »