• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.

Archived

This topic is now archived and is closed to further replies.

Arch@on

[java] Map isn't drawing properly.

4 posts in this topic

My map is not drawing properly. You can add yuor own pics to it because I don''t have web page where I could put it up =( So I have to copy all here... Moving doesn''t work and it''s not needed import java.awt.*; import java.awt.event.*; import java.awt.datatransfer.*; public class rpg { public static void main(String args[]) { smallwindow editor = new smallwindow(); editor.requestFocus(); editor.addWindowListener(new close()); } } class smallwindow extends Frame { Engine engine= new Engine(); public smallwindow() { super("Pieni Editori"); setSize(800, 600); addKeyListener(new KeyEventHandler()); add(engine); show(); } class KeyEventHandler extends KeyAdapter { public void keyPressed(KeyEvent ke) { switch(ke.getKeyCode()) { case KeyEvent.VK_NUMPAD1: PC.moveSouthWest(); break; case KeyEvent.VK_NUMPAD2: PC.moveSouth(); break; case KeyEvent.VK_NUMPAD3: PC.moveSouthEast(); break; case KeyEvent.VK_NUMPAD4: PC.moveWest(); break; case KeyEvent.VK_NUMPAD5: PC.moveHold(); break; case KeyEvent.VK_NUMPAD6: PC.moveEast(); break; case KeyEvent.VK_NUMPAD7: PC.moveNorthWest(); break; case KeyEvent.VK_NUMPAD8: PC.moveNorth(); break; case KeyEvent.VK_NUMPAD9: PC.moveNorthEast(); break; case KeyEvent.VK_ESCAPE: System.exit(0); break; } // check bounds if(PC.focusX < 0) PC.focusX = 0; if(PC.focusY < 0) PC.focusY = 0; if(PC.collisionbox().intersects(engine.westEdge)) PC.focusX = PC.focusX + 1; if(PC.collisionbox().intersects(engine.northEdge)) PC.focusY = PC.focusY + 1; if(PC.collisionbox().intersects(engine.eastEdge)) PC.focusX = PC.focusX - 1; if(PC.collisionbox().intersects(engine.southEdge)) PC.focusY = PC.focusY -1; engine.repaint(0,0,608,544); } } } // smallwindow ends class close extends WindowAdapter { public void windowClosing(WindowEvent event) { System.exit( 0 ); } } import java.awt.*; import java.awt.event.*; import java.awt.image.*; public class Engine extends Canvas { public int viewX, viewY; //ImageManager ImageManager imgMgr; //Declaration of images Image grassImages; Image grassTiles[] = new Image[40]; Image PCImages; Image PCTiles[]=new Image[8]; //Declaration of offscreen buffer Graphics offScreen; Image buffer; //Test map MapData map[][] = new MapData[32][32]; //Scroll borders public final static Rectangle eastEdge = new Rectangle(512,0,94,544); public final static Rectangle southEdge = new Rectangle(0,448,608,94); public final static Rectangle westEdge = new Rectangle(0,0,94,544); public final static Rectangle northEdge = new Rectangle(0,0,608,94); //Map border protected final static Rectangle mapBorder = new Rectangle(96,96,1076,916); //Personal Character PC pc; //Loaded private boolean loaded; //Movement area Dimension Area = new Dimension(13,11); public Engine() { System.out.println("GoDEngine intialized"); viewX = 0; viewY =0; } protected void loadMap() { int i,j; int transform_map[][] = { //Map {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,1,1,1,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,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0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,0,0,0,0,0,0,0,0,0,0}}; //Transform the map into map structure for(i=0;i<32;i++) { for(j=0;j<32;j++) { map[j] = new MapData(); switch(transform_map[i][j]) { case 0: map[i][j].num = 1; //map[i][j].tile[0] = 0; break; case 1: map[i][j].num = 1; map[i][j].tile[0] = 1; break; case 2: map[i][j].num = 1; map[i][j].tile[0] = 2; break; case 3: map[i][j].num = 3; map[i][j].tile[0] = 3; break; case 4: map[i][j].num = 2; map[i][j].tile[0] = 3; break; case 5: map[i][j].num = 2; map[i][j].tile[0] = 4; break; case 6: map[i][j].num = 1; map[i][j].tile[0] = 5; break; case 7: map[i][j].num = 4; map[i][j].tile[0] = 5; break; case 8: map[i][j].num = 3; map[i][j].tile[0] = 4; break; } } } } public void init() { imgMgr = new ImageManager(this); grassImages = getToolkit().getImage(getClass().getResource("images/tiles.gif")); PCImages = getToolkit().getImage(getClass().getResource("images/pc.gif")); //Loading graphics loadImages(); //Intialization of Personal Character pc = new PC(PCTiles, offScreen,this); //Map loadMap(); //Intialization of double buffering buffer= createImage(608,544); offScreen = buffer.getGraphics(); loaded = true; } public void update(Graphics g) { if (loaded == false) { init(); } drawMap(viewX, viewY); pc.paint(offScreen); g.drawImage(buffer,0,0,this); } final public void paint(Graphics g) { update(g); } protected void loadImages() { int num=0; for(int i=0; i<4; i++) { for(int j=0;j<10;j++) { grassTiles[num++] = imgMgr.getCroppedImage(grassImages, j*32,i*32,32,32); } } num=0; for(int i=0; i<4; i++) { for(int j=0;j<2;j++) { PCTiles[num++] = imgMgr.getCroppedImage(PCImages, j*32,i*32,32,32); } } for(int i= 0; i <39; i++) { imgMgr.trackImage(grassTiles[i], this); } for(int i= 0; i <7; i++) { imgMgr.trackImage(PCTiles[i], this); } System.out.println("Images are loaded"); } protected void drawMap(int x, int y) { int i,j,k; int mapx,mapy,mx,my,tx,ty,xo,yo,xa,ya,screenx,screeny; int length; int tile_to_draw,height_to_draw; int sprite_mx,sprite_my,spritex,spritey,xx,yy; mapx = x; xo = x; mapy = y; yo = y; while(true) { mx = mapx; my = mapy; screeny = 32; //for each row for(i=0;i<38;i++) { tx = mx; ty = my; screenx = 32; length = 19; //Check to see if this is an odd row if((i & 0) == 0) { screenx-=32; } if((i & 1) == 0) { screeny-=32; } //For each tile in row for(j=0;j 31) tx = 0; if((ty-=1) < 0) ty = 31; }//for each tile in row screeny+=32; if((i & 1) == 1) { if((mx+=1) > 31) mx = 32; } else { if((my+=1) > 31) my = 32; } }//for each row break; }//while repaint(); }//drawMap } import java.awt.*; import java.awt.image.*; import java.net.URL; /***************************************************************** Handles opening / retrieving of images from disk *****************************************************************/ public class ImageManager { Canvas canvas; public ImageManager(Canvas c) { this.canvas = c; } public Image getCroppedImage(Image img, int x, int y, int width, int height) { ImageProducer cropped = new FilteredImageSource(img.getSource(), new CropImageFilter(x,y,width,height)); return canvas.createImage(cropped); } public void trackImage(Image img, Component cmp) { MediaTracker tracker = new MediaTracker(cmp); tracker.addImage(img, 0); try { tracker.waitForID(0); if(tracker.isErrorAny()) { System.out.println("Error loading image"); } } catch (Exception ex) { ex.printStackTrace(); } } } public class MapData { public int num; public int tile[]; public int height[]; public int layer[]; public MapData(){ tile = new int[10]; height = new int[10]; layer = new int[10]; } } import java.awt.*; import java.awt.Image.*; public class PC { static Image faceUP, faceDOWN, faceLEFT, faceRIGHT, faceUP2, faceDOWN2, faceLEFT2, faceRIGHT2; static Image PC; Canvas canvas; public static int focusX = 9; // which tile gets the hilite public static int focusY = 8; public PC(Image PCImages[], Graphics offScrn, Canvas c) { faceUP = PCImages[0]; faceUP2 = PCImages[1]; faceDOWN = PCImages[4]; faceDOWN2 = PCImages[5]; faceLEFT = PCImages[6]; faceLEFT2 = PCImages[7]; faceRIGHT = PCImages[2]; faceRIGHT2 = PCImages[3]; PC=faceDOWN; canvas = c; System.out.println("GoDPC intialized"); } final public static void moveNorthWest() { focusX--; focusY--; if(PC==faceUP){ PC=faceUP2; } else{ PC=faceUP; } } final public static void moveNorth() { focusY--; if(PC==faceUP){ PC=faceUP2; } else{ PC=faceUP; } } final public static void moveNorthEast() { focusX++; focusY--; if(PC==faceUP){ PC=faceUP2; } else{ PC=faceUP; } } final public static void moveEast() { focusX++; if(PC==faceRIGHT){ PC=faceRIGHT2; } else{ PC=faceRIGHT; } } final public static void moveSouthEast() { focusY++; focusX++; if(PC==faceDOWN){ PC=faceDOWN2; } else{ PC=faceDOWN; } } final public static void moveSouth() { focusY++; if(PC==faceDOWN){ PC=faceDOWN2; } else{ PC=faceDOWN; } } final public static void moveSouthWest() { focusY++; focusX--; if(PC==faceDOWN){ PC=faceDOWN2; } else{ PC=faceDOWN; } } final public static void moveWest() { focusX--; if(PC==faceLEFT){ PC=faceLEFT2; } else{ PC=faceLEFT; } } final public static void moveHold() { PC=faceDOWN; } public void update(Graphics offScreen) { offScreen.setClip(0, 0, 608, 544); offScreen.drawImage(PC ,focusX * 32, focusY * 32, canvas); } public final void paint(Graphics offScreen) { update(offScreen); } public final static Rectangle collisionbox() { return new Rectangle((int)(focusX * 32 ), (int)(focusY * 32 ), 32, 32 ); } } It should draw in line but now it draws - 45 degrees to wrong way =(...
0

Share this post


Link to post
Share on other sites
That''s way too much code to look at on a web page. Howsabout you get a free web acount, put up a screenshot, and just the code that you feel is problematic...?
0

Share this post


Link to post
Share on other sites
Yeah, maybe, but I don''t know where are these free web accounts?

Time comes, time goes and I only am.
0

Share this post


Link to post
Share on other sites
xoom.com, 50megs.com, homestead.com, yahoo.com the list could go on forever
0

Share this post


Link to post
Share on other sites
Now I have it it''s all in here

http://www.geocities.com/opv99/


Time comes, time goes and I only am.
0

Share this post


Link to post
Share on other sites