Check-in [f00c1a685e]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Add base initialization of the tilemap.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: f00c1a685e29d4470e8ebbebb4b80a3ef53b23e9
User & Date: stephanie.gawroriski 2019-07-01 20:27:19
Context
2019-07-01
20:36
Very basic tilemap init (all zeros). check-in: 34d6277973 user: stephanie.gawroriski tags: trunk
20:27
Add base initialization of the tilemap. check-in: f00c1a685e user: stephanie.gawroriski tags: trunk
19:58
Describe the SQ package. check-in: 26faee6f15 user: stephanie.gawroriski tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to runt/mids/squirrel-quarrel/dev/shadowtail/squirrelquarrel/Game.java.

18
19
20
21
22
23
24



25
26
27
28


29
30
31
32
33

34






35
36
37
 * @since 2019/07/01
 */
public final class Game
{
	/** The random number generator. */
	public final Random random;
	



	/**
	 * Initializes the game.
	 *
	 * @param __seed The seed to use.


	 * @since 2019/07/01
	 */
	public Game(long __seed)
	{
		// Initialize RNG

		this.random = new Random(__seed);






	}
}








>
>
>




>
>


|


>
|
>
>
>
>
>
>



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
 * @since 2019/07/01
 */
public final class Game
{
	/** The random number generator. */
	public final Random random;
	
	/** The world map. */
	public final TileMap tilemap;
	
	/**
	 * Initializes the game.
	 *
	 * @param __seed The seed to use.
	 * @param __mapsize The size of the map.
	 * @param __numpl The number of players to use.
	 * @since 2019/07/01
	 */
	public Game(long __seed, MapSize __mapsize, int __numpl)
	{
		// Initialize RNG
		Random random;
		this.random = (random = new Random(__seed));
		
		// Initialize random map
		TileMap tilemap;
		this.tilemap = (tilemap = new TileMap(random, __mapsize, __numpl));
		
		throw new todo.TODO();
	}
}

Changes to runt/mids/squirrel-quarrel/dev/shadowtail/squirrelquarrel/GameBuilder.java.

19
20
21
22
23
24
25






26
27
28
29
30
31
32
33
34
35
36




37
38
39
40
41
42
43
44
45
46


47
48
























49
50
51
52
53
54
55
56
57
58
59


60
61

62
63
64
65
66
67
68
 * @since 2019/07/01
 */
public final class GameBuilder
{
	/** The game seed. */
	private volatile long _seed;
	






	/**
	 * Initializes a base game builder.
	 *
	 * @since 2019/07/01
	 */
	public GameBuilder()
	{
		// Instead of using the time directly, derive it from a seed
		Random initseed = new Random((System.currentTimeMillis() * 37L) +
			System.nanoTime());
		this._seed = ((long)initseed.nextInt() << 32) ^ initseed.nextInt();




	}
	
	/**
	 * Builds the actual game.
	 *
	 * @return The resulting game.
	 * @since 2019/07/01
	 */
	public final Game build()
	{


		return new Game(
			this._seed);
























	}
	
	/**
	 * Sets the seed to use for the game.
	 *
	 * @param __v The seed to use.
	 * @return {@code this}.
	 * @since 2019/07/01
	 */
	public final GameBuilder seed(long __v)
	{


		this._seed = __v;
		return this;

	}
	
	/**
	 * Builds and plays back a game from a replay.
	 *
	 * @param __in The input stream.
	 * @return The resulting game.







>
>
>
>
>
>











>
>
>
>










>
>
|
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>











>
>
|
|
>







19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
 * @since 2019/07/01
 */
public final class GameBuilder
{
	/** The game seed. */
	private volatile long _seed;
	
	/** The map size. */
	private volatile MapSize _mapsize;
	
	/** The number of players used. */
	private volatile int _numplayers;
	
	/**
	 * Initializes a base game builder.
	 *
	 * @since 2019/07/01
	 */
	public GameBuilder()
	{
		// Instead of using the time directly, derive it from a seed
		Random initseed = new Random((System.currentTimeMillis() * 37L) +
			System.nanoTime());
		this._seed = ((long)initseed.nextInt() << 32) ^ initseed.nextInt();
		
		// Set default parameters
		this._mapsize = MapSize.DEFAULT;
		this._numplayers = 2;
	}
	
	/**
	 * Builds the actual game.
	 *
	 * @return The resulting game.
	 * @since 2019/07/01
	 */
	public final Game build()
	{
		synchronized (this)
		{
			return new Game(this._seed,
				this._mapsize,
				this._numplayers);
		}
	}
	
	/**
	 * Sets the number of players in the game.
	 *
	 * @param __n The number of players to have.
	 * @return {@code this}.
	 * @throws IllegalArgumentException If the player count is out of range.
	 * @since 2019/07/01
	 */
	public final GameBuilder players(int __n)
		throws IllegalArgumentException
	{
		// {@squirreljme.error BE0s Out of range player count. (The count)}
		if (__n < 1 || __n > Players.MAX_PLAYERS)
			throw new IllegalArgumentException("BE0s " + __n);
		
		synchronized (this)
		{
			this._numplayers = __n;
			return this;
		}
	}
	
	/**
	 * Sets the seed to use for the game.
	 *
	 * @param __v The seed to use.
	 * @return {@code this}.
	 * @since 2019/07/01
	 */
	public final GameBuilder seed(long __v)
	{
		synchronized (this)
		{
			this._seed = __v;
			return this;
		}
	}
	
	/**
	 * Builds and plays back a game from a replay.
	 *
	 * @param __in The input stream.
	 * @return The resulting game.

Added runt/mids/squirrel-quarrel/dev/shadowtail/squirrelquarrel/MapSize.java.































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package dev.shadowtail.squirrelquarrel;

/**
 * DESCRIBE THIS.
 *
 * @since 2019/07/01
 */
public enum MapSize
{
	/** Compact. */
	RIDICULOUSLY_TINY(10, 10),
	
	/** Tiny map size. */
	TINY(20, 20),
	
	/** Small. */
	SMALL(25, 25),
	
	/** Medium. */
	MEDIUM(30, 30),
	
	/** Large. */
	LARGE(40, 40),
	
	/** Ridiculous. */
	RIDICULOUSLY_LARGE(80, 80),
	
	/** End. */
	;
	
	/** The default map size to use. */
	public static final MapSize DEFAULT =
		TINY;
	
	/** The map width. */
	public final int width;
	
	/** The map height. */
	public final int height;
	
	/**
	 * Initializes the map size.
	 *
	 * @param __w The width.
	 * @param __h The height.
	 * @since 2019/07/01
	 */
	private MapSize(int __w, int __h)
	{
		this.width = __w;
		this.height = __h;
	}
}

Changes to runt/mids/squirrel-quarrel/dev/shadowtail/squirrelquarrel/Players.java.

13
14
15
16
17
18
19



20
21
 * This manages all of the players which are in the game and with their
 * associated state.
 *
 * @since 2019/07/01
 */
public final class Players
{



}








>
>
>

<
13
14
15
16
17
18
19
20
21
22
23

 * This manages all of the players which are in the game and with their
 * associated state.
 *
 * @since 2019/07/01
 */
public final class Players
{
	/** Maximum number of supported players. */
	public static final int MAX_PLAYERS =
		4;
}

Changes to runt/mids/squirrel-quarrel/dev/shadowtail/squirrelquarrel/TileMap.java.

5
6
7
8
9
10
11


12
13
14
15
16
17
18
19
20
21
22


23







































// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package dev.shadowtail.squirrelquarrel;



/**
 * This manages the world map which consists of tiles.
 *
 * @since 2019/07/01
 */
public final class TileMap
{
	/** Each tile is 16x16 pixels. */
	public static final int TILE_PIXELS =
		16;
}

















































>
>










|
>
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package dev.shadowtail.squirrelquarrel;

import java.util.Random;

/**
 * This manages the world map which consists of tiles.
 *
 * @since 2019/07/01
 */
public final class TileMap
{
	/** Each tile is 16x16 pixels. */
	public static final int TILE_PIXELS =
		16;
	
	/** The size of the map. */
	public final MapSize size;
	
	/** The width of the map in tiles. */
	public final int tilewidth;
	
	/** The height of the map in tiles. */
	public final int tileheight;
	
	/**
	 * Initializes the tile map.
	 *
	 * @param __rand The random level generator.
	 * @param __size The map size to use.
	 * @param __numpl The number of players to make room for.
	 * @throws IllegalArgumentException If the player count is zero or
	 * negative.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/07/01
	 */
	public TileMap(Random __rand, MapSize __size, int __numpl)
		throws IllegalArgumentException, NullPointerException
	{
		if (__rand == null || __size == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error BE0r Negative or zero players, there must be
		// at least one player. (The player count)}
		if (__numpl < 1)
			throw new IllegalArgumentException("BE0r " + __numpl);
		
		// Get and store size of the level
		int tilewidth = __size.width,
			tileheight = __size.height;
		this.size = __size;
		this.tilewidth = tilewidth;
		this.tileheight = tileheight;
		
		throw new todo.TODO();
	}
}