Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (498)
Games in Android Showcase (117)
games submitted by our members
Games in WIP (563)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
   Home   Help   Search   Login   Register   
  Show Posts
Pages: [1]
1  Game Development / Artificial Intelligence / Re: collidesWith() method on: 2010-04-10 03:35:38
my codes for the game is like this

1  
2  
3  
4  
if(spriteA.collidesWith(bulletImage, 18,18, true))
      {
          spriteA=null;
          bulletImage=null;


the bulletImage just overlaps the sprite image
the 18 is the pixel size of the bulletImage.
Did i use this right?
2  Game Development / Artificial Intelligence / collidesWith() method on: 2010-04-09 03:11:11
can anyone explain to me further about this method
1  
2  
boolean collidesWith
(Image, int, int, boolean)


i cant understand much of the two ints in the parameter.
can anyone help me?
3  Game Development / Newbie & Debugging Questions / Re: help with scrolling terrain on: 2010-03-26 00:10:24
I assume vertical  scrolling is working correctly already, all you have to do is change the scrolling Y to scrolling X and there's your horizontal scrolling. You probably also want to change your maps to fit horizontal scrolling.

Your current map:
________
|              |
|              |
|              |
|              |
|              |
|              |
|_______|


Change to:

__________________
|                                  |
|                                  |
|                                  |
|_________________|


Hope that helps, if you still don't get it try this site, its written in flash, but the concept is the same.
http://www.tonypa.pri.ee/tbw/start.html
thank you very much i'll try this
4  Game Development / Newbie & Debugging Questions / Re: help with scrolling terrain on: 2010-03-22 10:48:18
This smells like homework assignment...

If you have successfully written the program to be vertically scrolling then it should be a relatively trivial matter to make it horizontally scrolling.

well this is actually a project and we just study programming by our selves
we don't have a formal lecture about this kind of stuff.
our school only teaches the very basic programming that's why i'm asking for help
5  Game Development / Newbie & Debugging Questions / help with scrolling terrain on: 2010-03-22 04:48:03
i have this class that runs the game in a vertical scrolling
i need help, what do i need to change in the codes below to make it a side-scroller(horizontal scrolling)?
and if you can tell me the exact code that needed to replace the codes below
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  
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  
108  
109  
110  
111  
112  
113  
114  
115  
116  
117  
118  
119  
120  
121  
122  
123  
124  
125  
126  
127  
128  
129  
130  
131  
132  
133  
134  
135  
136  
137  
138  
139  
140  
141  
142  
143  
144  
145  
146  
147  
148  
149  
150  
151  
152  
153  
154  
155  
156  
157  
158  
159  
160  
161  
162  
163  
164  
165  
166  
167  
168  
169  
170  
171  
172  
173  
174  
175  
176  
177  
178  
179  
180  
181  
182  
183  
184  
185  
186  
187  
188  
189  
190  
191  
192  
193  
194  
195  
196  
197  
198  
199  
200  
201  
202  
203  
204  
205  
206  
207  
208  
209  
210  
211  
212  
213  
214  
215  
216  
217  
218  
219  
220  
221  
222  
223  
224  
225  
226  
227  
228  
229  
230  
231  
232  
233  
234  
235  
236  
237  
238  
239  
240  
241  
242  
243  
244  
245  
246  
247  
248  
249  
250  
251  
252  
253  
254  
255  
256  
257  
258  
import javax.microedition.lcdui.*;
import javax.microedition.lcdui.game.*;
 
public class GameMap {
 
// Terrain 1
private static final int[][] map1 = {
{10,10,10,10,10,10,10,10},
{10,10,10,10,10,10,10,10},
{10,10,10,10,10,10,10,10},
{10,10,10,10,10,10,10,10},
{10,10,12,10,1,2,3,4},
{10,10,10,10,4,5,6,7},
{3,10,10,10,7,8,9,10},
{6,10,10,10,10,10,10,10},
{9,10,1,2,3,10,10,10},
{10,10,4,5,6,12,12,12},
{10,10,7,8,9,10,11,12},
{10,10,10,10,10,10,10,10},
{10,10,10,10,10,10,10,10},
{10,10,10,12,10,10,10,10},
{10,10,10,10,10,1,2,3},
{10,10,10,10,10,4,5,6},
{10,10,10,10,10,4,5,6},
{10,10,10,10,10,4,5,6},
{10,10,10,10,10,4,5,6},
{10,11,10,10,10,7,8,9},
{10,10,10,10,10,10,10,10},
{10,10,10,12,10,10,10,10},
{10,12,10,10,10,10,10,10},
{10,10,10,10,10,10,10,10},
{10,10,10,10,10,10,10,10},
{10,10,10,10,10,10,10,10},
{3,10,10,10,10,10,10,10},
{6,10,10,10,10,10,10,10},
{6,10,11,10,1,2,3,4},
{6,12,10,10,4,5,6,7},
{6,10,10,10,7,8,9,10},
{6,10,10,10,10,10,10,10},
{9,10,1,2,3,10,10,10},
{10,10,4,5,6,10,10,10},
{10,10,7,8,9,10,10,10},
{10,10,10,10,10,10,10,10},
{12,10,10,10,12,10,10,10},
{10,10,10,10,10,10,10,10},
{2,3,10,11,10,10,10,10},
{5,6,10,10,10,10,10,10},
{5,6,11,10,1,2,3,4},
{5,6,10,10,4,5,6,7},
{5,6,10,10,7,8,9,10},
{5,6,10,10,10,10,10,10},
{8,9,10,10,10,10,10,10},
{10,10,10,12,10,10,12,12},
{10,10,10,10,10,10,10,10},
{11,10,10,10,10,10,10,10},
{10,10,10,10,10,10,10,10}
};
 
// Terrain 2
private static final int[][] map2 = {
{10,10,10,10,10,10,10,10},
{10,10,10,10,10,10,10,10},
{10,10,12,12,10,10,10,10},
{10,10,12,12,10,10,10,10},
{10,10,10,10,10,10,10,10},
{10,10,10,10,10,10,10,10},
{10,10,10,10,10,10,10,10},
{10,10,10,10,10,10,10,10},
{10,10,10,10,10,10,10,10},
{10,10,10,10,10,10,10,10},
{10,10,10,10,10,10,10,10},
{10,10,10,10,10,10,10,10},
{10,10,10,10,10,10,10,10},
{10,10,10,10,10,10,10,10},
{10,10,10,10,10,10,10,10},
{ 3,10,10,10,10,10,10,10},
{ 6,10,10,10,10,10,10,10},
{ 6,10,12,10, 1, 2,3,4},
{ 6,10,10,10, 4, 5,6,7},
{ 6,10,10,10, 7, 8,9,10},
{ 6,10,10,10,10,10,10,10},
{ 9,10, 1, 2, 3,10,10,10},
{10,10, 4, 5, 6,12,12,12},
{10,10, 7, 8, 9,10,10,10},
{10,10,10,10,10,10,10,10},
{10,10,10,10,10,10,10,10},
{10,12,10,10,10,10,10,10},
{ 2, 3,10,10,10,10,10,10},
{ 5, 6,10,10,10,10,10,10},
{ 5, 6,11,10, 1, 2,3,4},
{ 5, 6,10,10, 4, 5,6,7},
{ 8, 9,10,10, 7, 8,9,10},
{10,10,10,10,10,10,10,10},
{10,10, 1, 2, 3,10,10,10},
{10,10, 4, 5, 6,10,10,10},
{10,10, 7, 8, 9,10,10,10},
{10,10,10,10,10,10,10,10},
{12,10,10,10,12,10,10,10},
{10,10,10,10,10,10,10,10},
{ 2, 3,10,11,10,10,10,10},
{ 5, 6,10,10,10,10,10,10},
{ 5, 6,11,10, 1, 2,3,4},
{ 5, 6,10,10, 4, 5,6,7},
{ 5, 6,10,10, 7, 8,9,10},
{ 5, 6,10,10,10,10,10,10},
{ 5, 6,10,10,10,10,10,10},
{ 5, 6,10,11,10,10,10,10},
{ 5, 6,10,10,10,10,10,10},
{ 5, 6,10,10,10,10,10,10},
{ 8, 9,10,10,10,10,10,10},
{10,10,10,12,10,10,10,10}
};
 
private static final int[][] map3 = {
{10,10,10,10,10,10},
{10,10,10,10,10,10},
{ 3,10,10,10,10, 1},
{ 6,10,10,10,10, 4},
{ 6,10,10,10,10, 4},
{ 6,10,10,10,10, 4},
{ 6,10,10,10,10, 4},
{ 6,10,10,10,10, 4},
{ 6,10,10,10,10, 4},
{ 6,10,10,10,10, 4},
{ 6,10,10,10,10, 4},
{ 9,10,10,10,10, 7},
{10,10,10,10,10,10},
{10,10,10,10,10,10},
{10,10,10,10,10,10},
{10,10,10, 1, 2, 3},
{10,10,10, 4, 5, 5},
{10,10,10, 4, 5, 5},
{10,10,10, 4, 5, 5},
{10,10,10, 7, 8, 8},
{10,10,10,10,10,10},
{10,10,10,10,11,10},
{10,10,10,10,10,10},
{10,12,10,10,10,10},
{10,10,10,10,10,10},
{ 2, 2, 3,10,10,10},
{ 5, 5, 6,10,11,10},
{ 5, 5, 6,10,10,10},
{ 5, 5, 6,10,10,10},
{ 5, 5, 6,10,10,10},
{ 5, 5, 6,10,10,10},
{ 5, 5, 6,10,10,10},
{ 5, 5, 6,10,10,12},
{ 5, 5, 6,10,10,10},
{ 8, 8, 9,10,10,10},
{10,10,10,10,10,10}
};
 
// Set Constant values, the values are direct
// relation to the actually tile sizes
// defined for the terrain graphics
static final int TILE_WIDTH = 32;
static final int TILE_HEIGHT = 32;
static final int TILE_NUM_COL = 8;
int TILE_NUM_ROW;
 
static final int MAP_MOVEMENT = 2; // the rate which the map scrolls, 2 pixels per cycle

// To hold the current map
private int[][] currentMap;
 
// To hold the current terrain
private TiledLayer terrain;
 
// To hold the current background/floor color
private int groundColor;
 
// To hold the current screen, value neeeded for scrolling calculation
private int screenHeight;
 
// To hold Y position for scrolling
private int terrainScroll;
 
public GameMap(int screenHeight) throws Exception {
this.screenHeight = screenHeight;
setMap(1); // default to set to terrain 1
}
 
private int[][] mergeMaps(int[][] map1, int[][] map2) {
int[][] xMap = new int[map1.length+map2.length][8];
System.arraycopy(map1,0,xMap,0,map1.length);
System.arraycopy(map2,0,xMap,map1.length - 1, map2.length);
return xMap;
}
 
// Set Appropriate Terrain and Map
public void setMap(int level) throws Exception {
Image tileImages = null;
 
switch (level) {
case 1: tileImages = Image.createImage("/pic/terrain1.png");
currentMap = mergeMaps(map1,map2);
break;
 
case 2: tileImages = Image.createImage("/pic/terrain2.png");
currentMap = mergeMaps(map2,map3);
groundColor = 0x00DECE6B;
 
break;
 
case 3: tileImages = Image.createImage("/pic/terrain3.png");
currentMap = mergeMaps(map3,map1);
groundColor = 0x0024B400;
break;
 
case 4: tileImages = Image.createImage("/pic/terrain4.png");
currentMap = mergeMaps(map2,map1);
groundColor = 0x0024B400;
break;
}
TILE_NUM_ROW = currentMap.length;
terrain = new TiledLayer(TILE_NUM_COL,TILE_NUM_ROW,tileImages,TILE_WIDTH,TILE_HEIGHT);
 
// Map Terrain Map with actual graphic from terrain.png
for (int row=0; row<TILE_NUM_ROW; row++) {
for (int col=0; col<TILE_NUM_COL; col++) {
terrain.setCell(col,row,currentMap[row][col]);
}
}
 
terrainScroll = 1 - (terrain.getCellHeight() * terrain.getRows()) + screenHeight;
terrain.setPosition(0,terrainScroll);
}
 
public int getMapLength() {
return this.currentMap.length;
}
 
public int getMapType(int x, int y) {
return this.currentMap[x][y];
}
 
public void scrollTerrain() {
if (terrainScroll < 0) {
terrainScroll += MAP_MOVEMENT;
terrain.setPosition(0,terrainScroll);
}
}
 
// Terrain Getter
public TiledLayer getTerrain() {
return terrain;
}
 
// Ground/Floor color Getter
public int getGroundColor() {
return groundColor;
}
 
// Map Movement Getter
public int getMapScrollAmount() {
return MAP_MOVEMENT;
}
}
Pages: [1]
 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

radar3301 (12 views)
2014-09-21 23:33:17

BurntPizza (30 views)
2014-09-21 02:42:18

BurntPizza (22 views)
2014-09-21 01:30:30

moogie (20 views)
2014-09-21 00:26:15

UprightPath (28 views)
2014-09-20 20:14:06

BurntPizza (33 views)
2014-09-19 03:14:18

Dwinin (48 views)
2014-09-12 09:08:26

Norakomi (74 views)
2014-09-10 13:57:51

TehJavaDev (103 views)
2014-09-10 06:39:09

Tekkerue (50 views)
2014-09-09 02:24:56
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!