digibutter.nerr Forum Index
Hey [you]! If you haven't noticed, this is now the old digibutter forums. Go over to the new site!
digibutter.nerr
It's Hi-Technicaaal!

Game Development blog: Entry 1
 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    digibutter.nerr Forum Index -> digiblogger
Author Message
Bananatank
Vampire


Joined: 14 May 2008
Posts: 465

HP: 5 MP: 0 Lives: 0



PostPosted: Sat Nov 22, 2008 5:42 pm   Reply with quote

http://digibutter.nerr.biz/viewtopic.php?t=121172

The Goal: A turn based RPG using java
Stages
1-Design
2-Coding
3-Graphics
4-More Coding
5-Make it html friendly

as for code I've begun a little bit of every part of the game in the code.
Here's the main part of the code I will be working on
Code:
import java.awt.Rectangle;

public class World_engine
{
   public boolean iscolliding(Rectangle playerbounds,Rectangle objbounds)
   {
      boolean collision;
      if ( playerbounds.intersects(objbounds))
         collision = true;
      else
         collision = false;
      return collision;
   }
   public int[] movement(int keycode,int[] coords)
   {
      int x=coords[0],y=coords[1];
         if( keycode == 39)
            coords[0]=x+5;
         else if( keycode == 37)
            coords[0]=x-5;
         else if( keycode == 40)
            coords[1]=y+5;
         else if( keycode == 38)
            coords[1]=y-5;
         return coords;
   }
}


This is the basic code to create any type of PC or NPC in game
Code:

import java.awt.Image;

public class Playerobj
{
   protected int[] stats;
   protected Image appearance;
   public Playerobj(int[] stats, Image appearance)
   {
      this.stats = stats;
      this.appearance = appearance;
   }
   public Image updateImage(Image img)
   {
      appearance=img;
      return appearance;
   }
   public int[] setStats(int hp,int ap, int str, int def, int mag)
   {
      int [] newstats={hp,ap,str,def,mag};
      stats = newstats;
      return stats;
   }
   public int[] storeStats(int[] newstats)
   {
      stats = newstats;
      return stats;
   }
   public int getHp()
   {
      return stats[1];
   }
   public int getAp()
   {
      return stats[2];
   }
   public int getStr()
   {
      return stats[3];
   }
   public int getDef()
   {
      return stats[4];
   }
   public int getMag()
   {
      return stats[5];
   }
   public Image getImage()
   {
      return appearance;
   }
}

So I could do Playerobj enemy = new Playerobj({5,5,5,5,5},enemyimg) to create a new enemy.

I am having trouble with my test of the future World Map code
Code:

import java.applet.Applet;
import java.awt.Graphics;
import java.awt.Rectangle;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;

public class MovementExample extends Applet implements KeyListener
{
   int x=40,y=40,key = 0;
   boolean collide;
   char reset,direction;
   Rectangle object,player,collision;
   public void init()
   {
      addKeyListener(this);
      setFocusable(true);
   }
   public void paint(Graphics draw)
   {
      setSize(500,500);
      player = new Rectangle(x,y,20,20);
      object = new Rectangle(100,100,100,100);
      draw.fillOval(player.x,player.y,player.width,player.height);
      draw.fillRect(object.x,object.y,object.width,object.height);
      collide = player.intersects(object);
      if(x == 500 || y == 500)
      {
         x=40;
          y=40;
      }
      else if( x == 0 || y ==0)
      {
         x=40;
         y=40;
      }
      else if(collide == true)
      {
         /* This is where the problem is.
          * I need the circle to not go in the square.
          * The collision detection works.
          * I just don't know what to do next.
          */
         draw.drawString("Press r to restart", 300, 10);
      }
   }
   @Override
   public void keyPressed(KeyEvent keys) {
      key=keys.getKeyCode();
      if(collide == false)
      {
      if( key == 39)
         x=x+5;
      else if( key == 37)
         x=x-5;
      else if( key == 40)
         y=y+5;
      else if( key == 38)
         y=y-5;
      }
      repaint();
   }
   public void keyReleased(KeyEvent keys)
   {
   }
   public void keyTyped(KeyEvent keys)
   {
      if (collide == true)
      {
         reset = keys.getKeyChar();
         if(reset == 'r')
         {
            x = 40;
            y = 40;
            collide = false;
         }
      }
   }
}


I will be posting more when I get farther along. btw I still need sprite artists and a soundtrack.
Back to top
Sovietkip shop    
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    digibutter.nerr Forum Index -> digiblogger
All times are GMT - 5 Hours
Page 1 of 1

 


Powered by phpBB © 2001, 2005 phpBB Group