• 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.

Dko

Members
  • Content count

    358
  • Joined

  • Last visited

Community Reputation

146 Neutral

About Dko

  • Rank
    Member
  1. I've been following the book XNA 4.0 Game Development by Example and I'm currently on the project Robot Rampage. In the following method I get what it's trying to do, but one thing isn't explained in the book. How does the code detect a collision properly if you come at an wall at an angle to it's corner and your perfectly dead on so that the two corners touch? Seems like to me that it would check horizontally then vertically and see they are empty (if they are) for no collision and let the tank move into the wall. Also attached a picture to show more clearly what I mean. [CODE] private static Vector2 checkTileObstacles(float elapsedTime, Vector2 moveAngle) { Vector2 newHorizontalLocation = BaseSprite.WorldLocation + (new Vector2(moveAngle.X, 0) * (playerSpeed * elapsedTime)); Vector2 newVerticalLocation = BaseSprite.WorldLocation + (new Vector2(0, moveAngle.Y) * (playerSpeed * elapsedTime)); Rectangle newHorizontalRect = new Rectangle( (int)newHorizontalLocation.X, (int)BaseSprite.WorldLocation.Y, BaseSprite.FrameWidth, BaseSprite.FrameHeight); Rectangle newVerticalRect = new Rectangle( (int)BaseSprite.WorldLocation.X, (int)newVerticalLocation.Y, BaseSprite.FrameWidth, BaseSprite.FrameHeight); int horizLeftPixel = 0; int horizRightPixel = 0; int vertTopPixel = 0; int vertBottomPixel = 0; if (moveAngle.X < 0) { horizLeftPixel = (int)newHorizontalRect.Left; horizRightPixel = (int)BaseSprite.WorldRectangle.Left; } if (moveAngle.X > 0) { horizLeftPixel = (int)BaseSprite.WorldRectangle.Right; horizRightPixel = (int)newHorizontalRect.Right; } if (moveAngle.Y < 0) { vertTopPixel = (int)newVerticalRect.Top; vertBottomPixel = (int)BaseSprite.WorldRectangle.Top; } if (moveAngle.Y > 0) { vertTopPixel = (int)BaseSprite.WorldRectangle.Bottom; vertBottomPixel = (int)newVerticalRect.Bottom; } if (moveAngle.X != 0) for (int x = horizLeftPixel; x < horizRightPixel; x++) { for (int y = 0; y < BaseSprite.FrameHeight; y++) if (TileMap.IsWallTileByPixel(new Vector2(x, newHorizontalLocation.Y + y))) { moveAngle.X = 0; break; } if (moveAngle.X == 0) break; } if (moveAngle.Y != 0) for (int y = vertTopPixel; y < vertBottomPixel; y++) { for (int x = 0; x < BaseSprite.FrameWidth; x++) if (TileMap.IsWallTileByPixel(new Vector2(newVerticalLocation.X + x, y))) { moveAngle.Y = 0; break; } if (moveAngle.Y == 0) break; } return moveAngle; } [/CODE]
  2. I've seen some where a type of collision detection that uses a black and white image that is the same size of the collide able image. I think that any area that is black can't be crossed or it was white , not sure and probably does not matter. But either way does anyone know any thing that documents the logic behind coding something like this? Something that makes a good explanation because I did find some info some time ago, like a wiki or some such. But it was impossible to understand. Thanks in advance Edit: Does anyone need more info or something?
  3. Hemm that might do the trick. Thanks
  4. A simple question. Does anyone know of a write up of the logic that goes into having a sprite follow another sprite like in a old 2d Role Playing game? Or could some one even tell me them self? Thanks for any help.
  5. Hiya, I'm currently helping make a RPG game and I was thinking that to make editing character stats easy for the other people working on it. That instead of loading the data from a text file, that I use the JDBC to have it load from a access file. I already know the basic's of JDBC, but the step that I have been given where you go into ODBC Data Source Administrator and set that all up is a bit much for the average user. Plus it seems to take from the ability of non windows users, to run the program. My question then I guess is there a way to get around this 'step'? Something to hide it from the users.
  6. I'm trying to get a friends code to compile that uses javazoom. I've downloaded it and it says to set the class path and the like. But I can't seem to figure it out. At the least I can't get the code to stop complaining how it can't find javazoom. Can someone give me a step by step on how to deal with setting up javazoom? Like even where I have to put the files I got in the zip. Thanks
  7. Thank you sir. I think I can solve things now.
  8. We have to keep the exception catching, part of the what the professor wants. This is what shows up on the server side when you click calculate. Exception in thread "main" java.lang.NullPointerException at java.util.StringTokenizer.<init>(StringTokenizer.java:182) at java.util.StringTokenizer.<init>(StringTokenizer.java:219) at InvestmentServer.runServer1(InvestmentServer.java:70) at InvestmentServer.main(InvestmentServer.java:134)
  9. Hi. Me and my partner have one last project due for our Advanced Java course. It's fairly simple program(In theroy) that has us create a gui that sends data to a server we created and sends back a calculated result on the data. the code sometimes works in that we get a value back to the client. But we get exceptions on the server but can't for the life of us figure out why. Could someone take a look at our code and see whats the matter? Thanks in advance. Investment Server import java.io.*; import java.net.*; import java.util.*; import java.io.EOFException; import java.io.IOException; import java.text.DateFormat; import java.util.Date; import java.awt.*; import javax.swing.*; public class InvestmentServer extends JFrame { // Text area for displaying contents private JTextArea jta = new JTextArea(); private Socket connectToClient; private BufferedReader isFromClient; private PrintWriter osToClient; public void runServer1 () { // Place text area on the frame setLayout(new BorderLayout()); add(new JScrollPane(jta), BorderLayout.CENTER); setTitle("InvestmentServer"); setSize(500, 300); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setVisible(true); try { // Step 1: create a server socket ServerSocket serverSock = new ServerSocket(9000); //create a date/time and format Date today = new Date(); DateFormat formatter = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG); //output date/time System.out.println("InvestmentServer started at " + formatter.format(today)); // start listening for clients connection on the server socket connectToClient = serverSock.accept(); // use buffer reader stream to get data from client isFromClient = new BufferedReader(new InputStreamReader( connectToClient.getInputStream())); //create buffer writer to send data to client osToClient = new PrintWriter(connectToClient.getOutputStream(), true); // continuously get data from client and send back result boolean cont = true; while(cont == true) { StringTokenizer st = new StringTokenizer (isFromClient.readLine()); // convert data from client to a double or int double investmentAmount = new Double(st.nextToken()).doubleValue(); System.out.println(investmentAmount); int years = new Integer(st.nextToken()).intValue(); double interestRate = new Double(st.nextToken()).doubleValue(); System.out.println("Investment amount received from client: "+investmentAmount); System.out.println("Number of years received from client: "+years); System.out.println("Annual interst rate received from client: "+interestRate); if (investmentAmount < 0 || years < 0 || interestRate < 0) { cont = false; System.out.println("invalid data"); } else { double result = (investmentAmount * Math.pow((interestRate/12+1.0),years*12)); System.out.println(" future value calculated: "+ result); osToClient.println(result); } } osToClient.println(-99); System.out.println("%%%%%Server is exiting%%%%%%%"); } catch(IOException e1) { System.err.println("Server died with excption: " + e1.toString()); System.exit(0); } finally { closeConnection(); }//end finally } // end runServer1 private void closeConnection() { try { osToClient.close(); //close output stream isFromClient.close(); //close input stream connectToClient.close(); //close socket } //end try catch (IOException ioException) { ioException.printStackTrace(); } // end catch }// end closeConnection //---------------------------------------------- public static void main(String[] args) { // declare a server1 object InvestmentServer server1 = new InvestmentServer(); server1.runServer1(); }//end main method }//end class Investment Client import java.io.*; import java.net.*; import java.util.*; import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.text.*; import java.io.EOFException; import java.io.IOException; public class InvestmentClient extends JFrame implements ActionListener { private Socket connectToServer; private BufferedReader stdin; private BufferedReader isFromServer; private PrintWriter osToServer; // Text fields for Investment amount, years, interest rate, and result private JTextField jtfInvestAmount, jtfYears, jtfInterest, jtfResult; // Buttons "Calculate and "Clear" private JButton jbtCalc, jbtClear; // Menu items "Calculate", Exit" private JMenuItem jmiCalc, jmiExit, jmiAbout; /** Default constructor */ public InvestmentClient() { setTitle("Future Investment Value"); // Create menu bar JMenuBar jmb = new JMenuBar(); // Set menu bar to the frame setJMenuBar(jmb); // Add menu "Operation" to menu bar JMenu operationMenu = new JMenu("Operation"); jmb.add(operationMenu); // Add menu "Help" in menu bar JMenu helpMenu = new JMenu("Help"); jmb.add(helpMenu); helpMenu.add(jmiAbout = new JMenuItem("About")); // Add menu items to menu "Operation" operationMenu.add(jmiCalc= new JMenuItem("Calculate")); operationMenu.addSeparator(); operationMenu.add(jmiExit = new JMenuItem("Exit")); // Panel p1 to hold text fields and labels JPanel p1 = new JPanel(); p1.setLayout(new GridLayout(4, 2, 30, 5)); p1.add(new JLabel("Investment Amount")); p1.add(jtfInvestAmount = new JTextField(10)); p1.add(new JLabel("Years")); p1.add(jtfYears = new JTextField(10)); p1.add(new JLabel("Annual Interest Rate")); p1.add(jtfInterest = new JTextField(10)); p1.add(new JLabel("Future value")); p1.add(jtfResult = new JTextField(10)); jtfResult.setEditable(false); // Panel p2 to hold buttons JPanel p2 = new JPanel(); p2.setLayout(new FlowLayout()); p2.add(jbtCalc = new JButton("Calculate")); p2.add(jbtClear = new JButton("Clear")); // Add panels to the frame getContentPane().setLayout(new BorderLayout()); getContentPane().add(p1, BorderLayout.NORTH); getContentPane().add(p2, BorderLayout.SOUTH); // Register listeners jbtCalc.addActionListener(this); jbtClear.addActionListener(this); jmiAbout.addActionListener(this); jmiCalc.addActionListener(this); jmiExit.addActionListener(this); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); pack(); setVisible(true); }//end Default Constructor //--------------------------------------------------------- public void sendData() { try { // create a client socket Use this to generate the error // message: "Client died with exception: " // Socket serverSock = new Socket("localhost",8000); // Note the server is on port 9000 not 8000. //Step 1: create a client socket to connnect to the server connectToServer = new Socket("localhost",9000); stdin = new BufferedReader(new InputStreamReader(System.in), 1); //Step 2: use buffer reader stream to get data from server isFromServer = new BufferedReader(new InputStreamReader (connectToServer.getInputStream())); //Step 2: create buffer writer to send data to server osToServer = new PrintWriter (connectToServer.getOutputStream(), true); // send data to server (Investment, years and interest rate) String test = jtfInvestAmount.getText() + " " + jtfYears.getText() + " " + jtfInterest.getText(); osToServer.println(test); //get data from server (Future Value) StringTokenizer st = new StringTokenizer (isFromServer.readLine()); // display in result. jtfResult.setText(st.nextToken()); } catch(IOException e1) { System.err.println("Client died with exception: " + e1.toString()); System.exit(0); }//end catch finally { //Close the connection closeConnection(); }// end finally }//end runClient private void closeConnection () { try { osToServer.close(); //Close output stream isFromServer.close(); // Close input stream connectToServer.close(); //Close socket } //end try catch (IOException ioException) { ioException.printStackTrace(); } //end catch } //end closeConnection //-------------------------------------------------------------------- /** Handle ActionEvent from buttons and menu items * @param e the ActionEvent either button press, or menu selection */ public void actionPerformed(ActionEvent e) { String actionCommand = e.getActionCommand(); // Handle button events if (e.getSource() instanceof JButton) { if ("Calculate".equals(actionCommand)) sendData(); else if ("Clear".equals(actionCommand)) clear(); }// end if instanceof JButton else if (e.getSource() instanceof JMenuItem) { // Handle menu item events if ("Calculate".equals(actionCommand)) sendData(); else if ("Exit".equals(actionCommand)) System.exit(0); else if ("About".equals(actionCommand)) JOptionPane.showMessageDialog(null, "Compute Future Investment Value", "About This Program", JOptionPane.INFORMATION_MESSAGE); }//end if instanceof JMenuItem } // end actionPerformed method /** Clears all data fields */ private void clear() { jtfInvestAmount.setText(""); jtfYears.setText(""); jtfInterest.setText(""); jtfResult.setText(""); }//end clear method //-------------------------------------------------------- public static void main(String[] args) { //declare a client1 object InvestmentClient client1 = new InvestmentClient(); // close the connection. //client1.closeConnection(); } //end main //--------------------------------------------------------- }// end class
  10. I was wondering if anyone here knew a good amount of Ruby? Ive been having lots of problems with some code in RPG maker XP (which uses RUBY) and can't seam to get help that actually... helps on the dedicated discussion boards. Im trying to design a custom system for the battles and require to add a variable that will hold another stat for each character for each level they are at. Much like the basic data base does. So far I have done something like this to add the new stat but have been unable to find a proper way to save and load the new data if I edit it in game. class Scene_Title #-------------------------------------------------------------------------- # * Main Database #-------------------------------------------------------------------------- alias stats_main_database main_database def main_database stats_main_database $data_actors.each {|actor| actor.setup_stats if actor != nil} end end module RPG class Actor def setup_stats # Setup New Table parameters = Table.new(7, 100) # Run Through and Copy From Parameters @parameters.ysize.times do |y| @parameters.xsize.times do |x| parameters[x, y] = @parameters[x, y] end end # Setup new parameters @parameters = parameters end end end
  11. Gehh im going to just stop for now and let my mind rest. If I forward declare Sprite then I error C2027 now. *sighs* I wish the book I was working from was newer so I knew I was organizing everything right. Ive looked at that link you gave metimmee. I think ive even read it beffore. But having my code in so many seperate files is getting confusing. Especialy in how do Include what where. X-x What to put in each file.
  12. //----------------------------------------------------------------- // Game Application // C++ Header - Sprite.h //----------------------------------------------------------------- #pragma once //----------------------------------------------------------------- // Include Files //----------------------------------------------------------------- #include <windows.h> #include <SDL.h> #include <string> #include "Bitmap.h" #include "GameEngine.h" //----------------------------------------------------------------- // Custom Data Type(s) //----------------------------------------------------------------- enum SPRITEACTION { SA_NONE = 0x0000L, SA_KILL = 0x0001L, }; enum BOUNDSACTION { BA_STOP, BA_WRAP, BA_BOUNCE, BA_DIE }; //----------------------------------------------------------------- // Function Declarations //----------------------------------------------------------------- // These are to be able to mess with SDL_Rect much easier. void SetSDLRect(SDL_Rect &rcRect, int x, int y, int w, int h); // rcRect1 = Rectangle to copy to. // rcRect2 = Rectangle to copy from. void CopySDLRect(SDL_Rect &rcRect1, SDL_Rect &rcRect2); void InflateSDLRect(SDL_Rect &rcRect, int x, int y); //----------------------------------------------------------------- // Sprite Class //----------------------------------------------------------------- class Sprite { protected: // Member variables Bitmap *m_pBitmap; SDL_Rect m_rcPosition, m_rcCollision; POINT m_ptVelocity; int m_iZOrder; SDL_Rect m_rcBounds; BOUNDSACTION m_baBoundsAction; BOOL m_bHidden; // Helper Methods virtual void CalcCollisionRect(); public: // Constructor(s)/Destructor Sprite(Bitmap* pBitmap); Sprite(Bitmap* pBitmap, SDL_Rect &rcBounds, BOUNDSACTION baBoundsAction = BA_STOP); Sprite(Bitmap* pBitmap, POINT ptPosition, POINT ptVelocity, int iZOrder, SDL_Rect &rcBounds, BOUNDSACTION baBoundsAction = BA_STOP); virtual ~Sprite(); // General Methods virtual SPRITEACTION Update(); void Draw(SDL_Surface *screen); BOOL IsPointInside(int x, int y); BOOL TestCollision(Sprite *pTestSprite); // Accessor Methods SDL_Rect GetPosition() {return m_rcPosition;}; void SetPosition(int x,int y); void SetPosition(POINT ptPosition); void SetPosition(SDL_Rect &rcPosition) {CopySDLRect(m_rcPosition, rcPosition);}; void OffsetPosition(int x, int y); SDL_Rect GetCollision() {return m_rcCollision;}; POINT GetVelocity() {return m_ptVelocity;}; void SetVelocity(int x, int y); void SetVelocity(POINT ptVelocity); BOOL GetZOrder() {return m_iZOrder;}; void SetZOrder(int iZOrder) {m_iZOrder = iZOrder;}; void SetBounds(SDL_Rect &rcBounds) {CopySDLRect(m_rcBounds, rcBounds);}; void SetBoundsAction(BOUNDSACTION ba) {m_baBoundsAction = ba;}; BOUNDSACTION GetBoundsAction() {return m_baBoundsAction;}; SDL_Rect GetBounds() {return m_rcBounds;}; BOOL IsHidden() {return m_bHidden;}; void SetHidden(BOOL bHidden) {m_bHidden = bHidden;}; int GetWidth() {return m_pBitmap->GetWidth();}; int GetHeight() {return m_pBitmap->GetHeight();}; }; //----------------------------------------------------------------- // Sprite Inline Helper Methods //----------------------------------------------------------------- inline void Sprite::CalcCollisionRect() { int iXShrink = m_rcPosition.w / 12; int iYShrink = m_rcPosition.h / 12; CopySDLRect(m_rcCollision, m_rcPosition); InflateSDLRect(m_rcCollision, iXShrink, iYShrink); } //----------------------------------------------------------------- // Sprite Inline General Methods //----------------------------------------------------------------- inline BOOL Sprite::TestCollision(Sprite *pTestSprite) { SDL_Rect rcTest = pTestSprite->GetCollision(); return m_rcCollision.x <= (rcTest.x + rcTest.w) && rcTest.x <= (m_rcCollision.x + m_rcCollision.y) && m_rcCollision.y <= (rcTest.y + rcTest.h) && rcTest.x <= (m_rcCollision.y + m_rcCollision.h); } Note this is probibly got a lot of errors in it that I havn't had the compiler catch yet.
  13. sure. Don't know if it will help much because its very basic. e:\my documents\c++ programs\jpong\gameengine.h(69) : error C2065: 'Sprite' : undeclared identifier
  14. Forward declare? I can't remove #include "Sprite.h" because it has my sprite class in it. Ill change the using later on. Right now im just worried about getting things to work. Not a 100% good coding style. Though I am tyring to keep things in a good coding style. Qualifing each stl:: is a waste to me when I don't know every single one ill be using.
  15. Ohh ok then. Well if Morrandir hadn't said it I would of then. How basically Libary's like SDL make it so you don't have to 'reinvent the wheel' and make complex code just to display a picture. So displaying a picture will be a good next step after your Qbasic pixel men :3