albert albert
posted
151 posts
since
Dec 02, 2008
from
|
|
Re: picking up the sword
|
|
|
|
|
|
|
|
|
|
|
I have an update:
[code]
public Point Move(Direction direction) { string weapon; base.location = Move(direction, game.Boundaries,location); if (!game.weaponInRoom.PickedUp) { //rest of the logic. if (game.weaponInRoom.Nearby(this.Location, this.distance) == true) { equippedweapon.PickedUP(); inventory.Add(equippedweapon); } //if (this.game.weaponInRoom.Nearby(location,distance) == true) // { // } } return location; }//end method [/code]
|
|
|
|
|
|
Frogleg
posted
831 posts
since
Aug 13, 2010
from
Australia
|
|
Re: picking up the sword
|
|
|
|
|
|
|
|
|
|
|
I loaded your project and am getting errors Check your code and upload project again
|
|
|
|
|
|
albert albert
posted
151 posts
since
Dec 02, 2008
from
|
|
Re: picking up the sword
|
|
|
|
|
|
|
|
|
|
|
here is the project so far.
|
|
|
|
|
|
Frogleg
posted
831 posts
since
Aug 13, 2010
from
Australia
|
|
|
albert albert
posted
151 posts
since
Dec 02, 2008
from
|
|
Re: picking up the sword
|
|
|
|
|
|
|
|
|
|
|
this method:
[code]
public Point Move(Direction direction) { string weapon; base.location = Move(direction, game.Boundaries,location); if (!game.weaponInRoom.PickedUp) { //rest of the logic. if (game.weaponInRoom.Nearby(this.Location, this.distance) == true) { equippedweapon.PickedUP(); inventory.Add(equippedweapon); } } return location; }//end method
[/code]
in the Player class.
The player moves to the weapon(sword) and the the sword will dissapear in the dungeon, where the player moves and appears in the inventory and also the player with the sword will appear. But now the situation is if u press on a move button the action is already done before the player pickedup the weapon.
|
|
|
|
|
|
Frogleg
posted
831 posts
since
Aug 13, 2010
from
Australia
|
|
Re: picking up the sword
|
|
|
|
|
|
|
|
|
|
|
You will have to check if player picbox intersects with sword picbox before picking up the sword
|
|
|
|
|
|
albert albert
posted
151 posts
since
Dec 02, 2008
from
|
|
Re: picking up the sword
|
|
|
|
|
|
|
|
|
|
|
yes . But how to do that in the Player class?
I think in the form class it is already done, isnt?
|
|
|
|
|
|
albert albert
posted
151 posts
since
Dec 02, 2008
from
|
|
Re: picking up the sword
|
|
|
|
|
|
|
|
|
|
|
I pputted this in the from class:
[code] public void intersects() { Rectangle p1 = this.pcPlayer.ClientRectangle; p1.Offset(this.pcPlayer.Location);
Rectangle p2 = this.pcSword.ClientRectangle; p2.Offset(this.pcSword.Location);
bool overlapped = p1.IntersectsWith(p2); [/code]
|
|
|
|
|
|
albert albert
posted
151 posts
since
Dec 02, 2008
from
|
|
Re: Picking up the sword
|
|
|
|
|
|
|
|
|
|
|
Iv made an update. But still the Player and the Weapon intersects with eatch other before they realy intersects with eatch other
And I dont understand why the pcSword not dissapear from the Dungeon, because I set the property vissible to false.
|
|
|
|
|
|
Frogleg
posted
831 posts
since
Aug 13, 2010
from
Australia
|
|
|
albert albert
posted
151 posts
since
Dec 02, 2008
from
|
|
Re: Picking up the sword
|
|
|
|
|
|
|
|
|
|
|
Eh, u have sent me the same version Iv sent u
|
|
|
|
|
|
Frogleg
posted
831 posts
since
Aug 13, 2010
from
Australia
|
|
|
albert albert
posted
151 posts
since
Dec 02, 2008
from
|
|
Re: Picking up the sword
|
|
|
|
|
|
|
|
|
|
|
I am sorry.
u changed this method: And the Form class. [code] public Point Move(Direction direction) { //Rectangle r1 = new Rectangle(new Point(this.Location.X, this.location.Y),this.width,this,heigt);
//Point target = equippedweapon.Location; string weapon; base.location = Move(direction, game.Boundaries,location); return location; }//end method [/code]
But If u put a breakpoint on this line in the form Class:
weaponControl.Location = game.weaponInRoom.Location; if (game.weaponInRoom.PickedUp) --- u can put a breakpoint on this line, then it will be executed befor the player actually hit with the sword. weaponControl.Visible = false;
That I dont understand. Because only when the player hits with the the sword then the weapon in the dungeon will be removed and the sword in the inventory will be showed. That is how it has to be.
|
|
|
|
|
|
albert albert
posted
151 posts
since
Dec 02, 2008
from
|
|
Re: Picking up the sword
|
|
|
|
|
|
|
|
|
|
|
Iv made an update, but still the sword stays visible in the Dungeon, when the player picks up the sword.
And still the form doesnt communicate with the player method
And when I put a breakpoint on this lines:
Form class: [code] weaponControl.Location = game.weaponInRoom.Location; if (game.weaponInRoom.PickedUp) weaponControl.Visible = false; [/code]
the code is executed before the player picked up the sword.
this function: [code] weaponControl.Location = game.weaponInRoom.Location; if (game.weaponInRoom.PickedUp) weaponControl.Visible = false; else weaponControl.Visible = true; [/code] is necessary because this doesnt working ofcourse: [code] case "Sword": weaponControl = pcSword; locationWeapon.Text = weaponControl.Location.ToString(); if (intersects() == true) { //weaponControl.Visible = false; pcSword.Visible = false; inventorySword.Visible = true; inventorySword.BorderStyle = BorderStyle.FixedSingle; pcPlayerSword.Location = weaponControl.Location;//That the new image is show on the place where the player pickedup his weapon!! pcPlayerSword.Visible = true; pcPlayer.Visible = false; //if (inventorySword.Visible = true) // weaponControl.Visible = false; } break; [/code]
because then only the sword is !visible when the player intersects with the sword. but after the interseciton the sword is still visible.
|
|
|
|
|
|
albert albert
posted
151 posts
since
Dec 02, 2008
from
|
|
Re: Picking up the sword
|
|
|
|
|
|
|
|
|
|
|
And there is also something strange:
[code] public bool checkForWeapon(Rectangle playRect, Rectangle weaponRect) { bool isPickup = false; if (playRect.IntersectsWith(weaponRect)) { isPickup = true; } return isPickup; } [/code]
I putted an breakpoint on this line: isPickup = true;
but when the player intersects with the sword the variable isPickup says: false. strange
|
|
|
|
|
|
albert albert
posted
151 posts
since
Dec 02, 2008
from
|
|
Re: Picking up the sword
|
|
|
|
|
|
|
|
|
|
|
I have it now likes this:
[code] class Weapon public bool PickedUP(bool pickedUp) { if (pickedUp == true) return true; //I putted here an breakpoint and it gives true when the player intersects with the sword. So that is good else return false; //pickedUp = true; return pickedUp; } [/code]
but if I put here an breakpoint:
[code] class Form weaponControl.Visible = true;
weaponControl.Location = game.weaponInRoom.Location; if (pickUpWeapon = game.weaponInRoom.PickedUp) //if(( pickUpWeapon = game.checkForWeapon(pcPlayer.Bounds, pcSword.Bounds)) == true) //if( game.weaponInRoom.PickedUP(pickUpWeapon) == true) { //game.MovePlayer(direction, boundaries, location); // pickUpWeapon = game.checkForWeapon(pcPlayer.Bounds, pcSword.Bounds); lb_pickedupSword.Text = game.weaponInRoom.PickedUP(pickUpWeapon).ToString(); ---> weaponControl.Visible = false;// here I putted an breakpoint , but nothing happens //so u have to guess where the sword is and the the sword will be shown in the //inventory } else { weaponControl.Visible = true; } [/code]
|
|
|
|
|
|
Frogleg
posted
831 posts
since
Aug 13, 2010
from
Australia
|
|
Re: Picking up the sword
|
|
|
|
|
|
|
|
|
|
|
When i ran your code - right move - I put a breakpoint on the first item in MoveRight_Click Pressing F11, I did a count of code lines - I stopped at 300 and it still had not finished the method You move from class to class like a bouncing bullet - and all the methods do is transfer to another class - virtually popping to say hello and doing nothing constructive
My advice- Restart the project and make it simple Form1 handles imputs and graphics Game class is the game engine weapon class holds only info on weapons enemy class holds only info on enemies
|
|
|
|
|
|
albert albert
posted
151 posts
since
Dec 02, 2008
from
|
|
Re: Picking up the sword
|
|
|
|
|
|
|
|
|
|
|
I think u are right. But it is logical that there is a Abstract class Enemy, because u have several enemies and an abstract class: Weapon, because u have several weapons,isnt?
|
|
|
|
|
|
Frogleg
posted
831 posts
since
Aug 13, 2010
from
Australia
|
|
Re: Picking up the sword
|
|
|
|
|
|
|
|
|
|
|
The weapon abstract class is a base class - and as the weapons -sword mace etc have same methods it is a good idea to use abstract class. You have a mover abstact class which may be ok for enemies, but not in my opinion for the player.
When you create a project (after you have outlined what your program will do), do one thing at a time ie create player and movement. When you add enemies or weapons further down the track- keep testing to ensure your later code has not interfered with your player
|
|
|
|
|
|
Frogleg
posted
831 posts
since
Aug 13, 2010
from
Australia
|
|
|
|
|