Hello! I know I'm new and have only a few posts, but I wanted to be more active and post more, so I think i'll post some of my beginner/nub code! I've been coding in Java(General) for ~2 Months, and only beginning to get into 2D stuff more recently (Past 2 weeks or so). I've been following some 2D animating/coding tutorials, but they just don't make sense until I find some way to simplify and understand them. I like my code for reflecting simplicity. This will probably change though. Without further ado, here it is!
Finding you Character (The most simple, focused AI I know of)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| public void findCharacter() { int xChar = 0; int yChar = 0;
int xZombie = 0; int yZombie = 0;
int moveSpeed = 1;
if (xZombie < xChar) { xZombie += moveSpeed; } if (xZombie > xChar) { xZombie -= moveSpeed; } if (yZombie < yChar) { yZombie += moveSpeed; } if (yZombie < yChar) { yZombie += moveSpeed; } } |
There's also my Tile-Setter system

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| public void TileSystem() {
int Width = 640; int Height = 480; int x = 0; int y = 0;
int tileSize = 32; int rowTiles = 25; int columnTiles = 20;
for (x = 0; x < Width; x += tileSize) { for (y = 0; y < Height; y += tileSize) { x = 0; } } System.out.println("X: " + x + "Y: " + y);
} |
//Note: I had to re-write this off the top of my head, since I didn't feel like going across the room to grab my flash-drive which I keep all of my good Java Tid-Bits on. I think I screwed up somewhere

After-Post #1 - Screwed up the tile-rendering thing. It's an infinity loop. I'll try to fix it while still working and then pastah back.
Just some beginner's code! Hope I can develop a better organizational skill and also the ability to actually write this stuff better. 2D Animation is fun until you actually try to make it
