Need help/hints/tips with a method for connect 4 game.
Hi!
I'm currently trying to get my "movepiece"-method to make it so that players can only drag a piece into the empty square at the bottom row, and if the square is not empty the method will move up one row and check if it's empty if not, repeat until
6 are checked if no one is empty then move is invalid.
I've been trying out while loops and for loops but i think i might set the wrong conditions for exiting the loop...
Here the code for the method without any loops simply adds pieces.
/// <summary>
/// Method that performs the actual move.
/// The old piece gets overrun by the attacking piece.
/// The attacking piece's position becomes null.
/// </summary>public Piece[,] MoveAttackpiece(int[,] changearray)
int origX = changearray[0, 0];
int origY = changearray[0, 1];
int targetX = changearray[1, 0];
int targetY = changearray[1, 1];
pieceArray[targetX, targetY] = pieceArray[origX, origY]; //swap
return pieceArray;
The game is using winforms and a 2D array(pieceArray)to draw the game board
I'm using a Constants class for declaring the height and width of the board, which the pieceArray is based on, Namely const int BOARDESIZEx and BOARDERSIZEy.
And while i'm at it when i did different loops for tryng to make the piece move down/up (based on if a square in bottom row was empty or not) the program crashes and i get the "Null Reference Exception unhandled"
at this part in the game.CS (the earlier code reside in a class named Squares.cs)
if (changearray != null)
//Building string to print (split over several rows for readability but also to avoid calculations)
Piece attackpiece = pieceArray[changearray[1, 0], changearray[1, 1]];
string message = "";
if (move % 2 == 1) message += "TURN " + move / 2 + ":\r\n"; //integer division, as there are two draws per turn
message += attackpiece.Name + ": "; //Walker:
message += IntegerToChar(changearray[0, 1]); //Walker: A
message += (changearray[0, 0] + 1) + " - "; //Walker A1 -
message += IntegerToChar(changearray[1, 1]); //Walker A1 - B
message += (changearray[1, 0] + 1); //Walker A1 - B2
if (move % 2 == 0) message += "\r\n"; //blank row inserted after each completed turn
Board.PrintMove(message);
I've tried making
While(piecearray[targetX, targetY]!=null)
pieceArray[targetX, targetY]==pieceArray[targetX, targetY +1];
return array;
but that didn't work and i don't really know how to make the game start at bottom row.
I appreciate any help or tips on how to get this to work since it's the only thing left for making the game work as intended.
Cheers and thanks for reading.
PS: if there's anything you wonder just ask and i'll explain as much as i can.
Regards Gabbelino
Student at the University of Borås, Sweden
Let's look at what's wrong with the following code.
While(piecearray[targetX, targetY]!=null)
pieceArray[targetX, targetY]=pieceArray[targetX, targetY +1]; // I assume the "==" in your post above was a typo.
Suppose, for the sake of argument, that targetX is 2 and targetY is 3, and that pieceArray[2,3] is not null. The line inside the loop will then become...
pieceArray[2,3] = pieceArray[2, 4];
...and this line will keep being executed as long as pieceArray[2,3] is not null, which if pieceArray[2,4] is not null will be forever (infinite loop).
I suspect that your loop should look something like this...
for(int i = 0; i < BOARDSIZEy; i++)
// Look for the first available square in the target column.
// When found, set the piece on that square then break out.
if(pieceArray[targetX, i] == null)
pieceArray[targetX, i] = pieceArray[origX, origY];
break;
Similar Messages
-
Need help displaying images with List component for Flash CS4 (ActionScript 3.0)
Hi folks:
I am an inexperienced user of Flash CS4 Pro (v10.0.2). I am attempting to use the List component with ActionScript 3.0 to make a different image display when a user clicks each item in a list.
I did find a tutorial that showed me how to make different text display using a dynamic text box and the following ActionScript:
MyList.addEventListener(Event.CHANGE, ShowSelectedItem);
function ShowSelectedItem(event:Event):void {
ListText.text=MyList.selectedItem.data;
...where My List is the instance of the List component and ListText is the dynamix text box. In this case, the user clicks an item in the list, defined by the label value in the dataProvider parameter of the List component, and text displays as defined in the data value in the dataProvider parameter.
However, as I mentioned to start, what I really want to do is make images display instead of text. Can anyone provide me the steps to do this?
I appreciate your help (in advance)!!
CindyHi...thanks for responding! I was planning on using images from the Library, but if there is a better way to do it, I'm open. So far, I just have text in the data property. This is part of my problem. I don't know what I need to put in the data value for an image to display. Do I just put the image file name and Flash will know to pull it from the Library? Do I need to place the images on the stage on different frames? I apologize for the "stupid user" questions, but as you can tell, I'm a newbie.
Appreciate your patience and any help you can offer!
Cindy -
Need help finding the default payment method for supplier site in R12
I am using the following query to find out what the default payment method is for a supplier site.
select pv.vendor_id ,
pvs.vendor_site_id,
iepa.ext_payee_id,
ieppm.payment_method_code
from ap_supplier_sites_all pvs
,ap_suppliers pv
,iby_external_payees_all iepa
,iby_ext_party_pmt_mthds ieppm
where pv.pay_group_lookup_code = 'EMPLOYEE'
and pv.vendor_type_lookup_code = 'EMPLOYEE'
and pv.employee_id is not null
and pv.employee_id =92584--p_person_id
and pv.vendor_id= pvs.vendor_id
and pvs.vendor_site_code = 'HOME'
and pvs.pay_group_lookup_code <> 'ATTACHMENT'
and ((pv.end_date_active is null) or (pv.end_date_active >= sysdate))
and ((pvs.inactive_date is null) or (pvs.inactive_date>= sysdate))
and pvs.pay_site_flag = 'Y'
and pvs.vendor_site_id = iepa.supplier_site_id
and iepa.ext_payee_id = ieppm.ext_pmt_party_id
and ieppm.primary_flag = 'Y'
and pv.segment1 = '131678'
The problem is that I am returning two rows.
I have gone in to the application and changed the default payment method from 'Check' to 'Electronic' and I am able to see the change on one of the records, however I am unable to determine how I'm supposed to narrow it down to just this record. I am pulling what hair I have left out!
Please help.
ChrisHere is the generic query for some one who is faing problem like us.This query will return all the payment methods for all sites of a supplier
SELECT ieppm.payment_method_code,ieppm.inactive_date
FROM ap_supplier_sites_all assa,
ap_suppliers ass,
iby_external_payees_all iepa,
iby_ext_party_pmt_mthds ieppm
WHERE ass.vendor_id = assa.vendor_id
AND assa.pay_site_flag = 'Y'
AND assa.vendor_site_id = iepa.supplier_site_id
AND iepa.ext_payee_id = ieppm.ext_pmt_party_id
AND ass.segment1 = '10033' -- Supplier Number
AND( (ieppm.inactive_date IS NULL)or (ieppm.inactive_date > sysdate)) ; -
I need help adding a mouse motion listner to my game. PLEASE i need it for
I need help adding a mouse motion listner to my game. PLEASE i need it for a grade.
i have a basic game that shoots target how can use the motion listner so that paint objects (the aim) move with the mouse.
i am able to shoot targets but it jus clicks to them ive been using this:
public void mouse() {
dotX = mouseX;
dotY = mouseY;
int d = Math.abs(dotX - (targetX + 60/2)) + Math.abs(dotY - (targetY + 60/2));
if(d < 15) {
score++;
s1 = "" + score;
else {
score--;
s1 = "" + score;
and here's my cross hairs used for aiming
//lines
page.setStroke(new BasicStroke(1));
page.setColor(Color.green);
page.drawLine(dotX-10,dotY,dotX+10,dotY);
page.drawLine(dotX,dotY-10,dotX,dotY+10);
//cricle
page.setColor(new Color(0,168,0,100));
page.fillOval(dotX-10,dotY-10,20,20);
please can some1 help meplease can some1 help meNot when you triple post a question:
http://forum.java.sun.com/thread.jspa?threadID=5244281
http://forum.java.sun.com/thread.jspa?threadID=5244277 -
Need help activating Adobe Acrobat XI PRO FOR WINDOWS?
need help activating Adobe Acrobat XI PRO FOR WINDOWS?
Hi jurleana15722686,
Are you working with a subscription version or perpetual (where you bought the software outright)? Are you running into a particular problem or receiving an error message when you try to activate?
For starters, please check out this document: https://helpx.adobe.com/x-productkb/policy-pricing/activation-deactivation-products.html.
If you're still having trouble, please let us know what the exact issue is, including any error messages that you're receiving. It would also be helpful to know what version of Windows you're using.
Best,
Sara
[disucssion moved to Downloading, Installing, Setting Up forum] -
Need help on buying FIREWIRE/USB-compatible for Logic Pro 9.0.2 on my SL
Hi...Im in needs of help in my new OS Mac World.Had my Logic Pro 9(9.0.2) install in my Snow Leopard(10.6.3).Need help on buying FIREWIRE/USB-compatible for Logic Pro 9.0.2 on my Snow Leopard.Just a real basic audio interface that works with my Macbook pro Specification.You're help will be much more appreciated..
Best Regards:RatzyMazzyIn any case I would suggest to get an audio interface which is *Core Audio* compatible. This means that you just need to plug it in and it will work with OS X’s integrated driver. I once had an M-Audio interface which needed its own driver and it had latency problems because of them. I am currently using the EDIROL FA-66 with 10.6.3 on my MacBook Pro. It still works flawlessly and has worked without problems in the past with 10.4 and 10.5, too. Here is how it looks like: http://www.rolandus.com/products/productdetails.php?ProductId=731
I have also heard good things about the FireWire interfaces from Presonus, like the FireBox.
Björn -
Need help startng websphere server in eclipse for debugging porpose
I am using Eclipse Sdk Version: 3.1.2
IBM websphere 6.0
JDK 1.4
I set debug value to "true" in my application.xml
I have a .ear file of my application deployed on the websphere appserver. Currently I can test my application in nobebug mode.
values of environment variables are -
JAVA_HOME - C:\DEV\IBMJDK142; C:\Program Files\Java\jre1.6.0_03
PATH - C:\DEV\IBMJDK142\bin; C:\Program Files\IBM\WebSphere MQ\Java\lib;C:\DEV\IBMJDK142\bin;%SystemRoot%\system32;%SystemRoot%;
I want to test the application in debug mode.
I am using default server on websphere, which is server1.
In Admin-console of webshere I went to
server-->Application server-->choose server1-->Debugging Service ---->checked the checkbox "Enable service at server startup"
Here value of my JVM debug port is 7777.
next In Eclipse env I chose Run---->Debug....--->Remote Java Application ----> created a new application with the name of my application and set the connection properties to -
Host - localhost
port-7777
Eclipse----> Windows----->Preferences---->Server----->Installed Runtime---->Add---->selected values such as -
JRE - default JRE(JDK 1.4)
IBM Websphere Installation Directory - C:/DEV/WebSphere/AppServer
saved it.
Now in debug perspective, I created a new server with selection/values such as -
IBM--->IBM Websphere v6---->
port - 9081
server profile directory - C:/DEV/WebSphere/AppServer/profiles/default
cell - GCWSNTRANode01Cell
node - GCWSNTRANode01
server - server1
Next---->Added the project to configured project ----->FINISH
Closed Eclipse to save env settings.
Started the default server (server1)
opened eclipse - desired project--->debug perspective ---->choose server--->Right Click----Start/Debug
mesg "Starting ServerI BM Websphere 6 - IBM Websphere 6 failed to start"
can some one please tell me what I am missing here.Need help startng websphere server in eclipse for debugging porpose
can some one please tell me what I am missing here. Well for one, you're trying to debug a dolphin
Edited by: redfalconf35 on Jun 19, 2008 4:50 PM -
I need help setting up an apple id for my son's phone. It seems his email address has been taken and/or we cant get the password.
Two different things
If you forgot the password
If you forgot your Apple ID password - Apple Support
If the email ID you want to use is in use by someone else - then you may need a new one
The iCloud ID's are usually unique and may be of help if you set one up -
I need help in finding a free update for my windows 7.5 mobile
I need help in finding a free update for my mobile 7.5 windows phone
Message was edited by: chevycamer427http://www.windowsphone.com/en-us/store/app/adobe-reader/bc4f319a-9a9a-df11-a490-00237de2d b9e
[topic moved to Windows Phone subforum] -
I need help in activating apple id to for the find my iphone app
i need help in activating apple id to for the find my iphone app
What sort of help are you requesting from us, your fellow users? What exactly is the problem/issue?
-
Need help Installing Flash player 10.3 for firefox. It stops at 50%
So I have Windows Vista Basic Home, I tried updating my Flash version in firefox because it was out of date, but everytime it start downloading it , then I get the a message that says "Error " Appliation in use." I uninstalled it and followed all the suggestions on the websites nothing is working. I even uninstall google chrome thinking it was the problem but I'm still having that problem so I really don't know what to do because now the only place Flash player is installed seems to be Google chrome that I had to redoawload, but everywhere else tells me that I need to install it.
RE-RE-RE REPITO, NO ENTIENDO NADA DE INGLES, PARA ESTE IDIOMA SOY COMPLETAMENTE NULA, POR FAVOR TODOS LOS MENSAJES, NOTAS, ECT., MANDEN EN ESPAÑOL.
Date: Thu, 29 Sep 2011 15:13:29 -0600
From: [email protected]
To: [email protected]
Subject: Need help Installing Flash player 10.3 for firefox. It stops at 50%
Re: Need help Installing Flash player 10.3 for firefox. It stops at 50%
created by Kpiebo in Installing Flash Player - View the full discussion
I have been at it since yesterday and it's still not working.
Replies to this message go to everyone subscribed to this thread, not directly to the person who posted the message. To post a reply, either reply to this email or visit the message page: http://forums.adobe.com/message/3945878#3945878
To unsubscribe from this thread, please visit the message page at http://forums.adobe.com/message/3945878#3945878. In the Actions box on the right, click the Stop Email Notifications link.
Start a new discussion in Installing Flash Player by email or at Adobe Forums
For more information about maintaining your forum email notifications please go to http://forums.adobe.com/message/2936746#2936746. -
I need help to find the serial number for Photoshop Elements 11
Hi! I need help to find the serial number for Photoshop Elements 11 I downloaded last year on Apple Application Store.. I have been using photoshop on mac for over a year and now need the serial number to be able to use it on macbook. I looked up Adobe's website for help but found none and noone to ask for support.. Any ideas how I can get the serial number using the App Sore bill I have?
Please post Photoshop Elements related queries over at
http://forums.adobe.com/community/photoshop_elements -
Hi, I need help on how to update software for my ipad1, can someone help me?
The iPad 1 can not be upgraded beyond 5.1.1. If you haven't upgraded to iOS 5.1.1, see the info below.
If your iDevice is using a version of iOS lower than 5, you will need to use iTunes on your syncing computer to perform the upgrade. Use the Apple link below as a guide for the upgrade.
http://support.apple.com/kb/HT4972
Also read the instructions from the section entitled "Update your device using iTunes" at the link below.
http://support.apple.com/kb/HT4623
Information regarding transferring purchases from your iDevice to iTunes on your syncing computer can be found at the link below.
http://support.apple.com/kb/ht1848 -
What happened to the 24/7 live chat for mobile me? I need help right now. Too complex for this. Crime involved., What happened to the 24/7 live chat for mobile me? I need help right now. Too complex for this. Crime involved.
Hi Tmswrite,
Here is what you want to do to protect yourself and your device:
Find My iPhone Basics - Apple Support
iCloud: Find My iPhone overview
Here's some information on how the Activation Lock protects you:
Find My iPhone Activation Lock in iOS 7
Sorry for your troubles. Hope it turns out OK for you!
GB -
need help urgent, my iphone is stuck at connect to itunes screen, when i restore it using itunes, it shows error -1...may someone help me plz....
See:
iOS: Unable to Update or Restore
http://support.apple.com/kb/ht1808
Maybe you are looking for
-
Vendor's balance is showing in S_ALR_87012103 as Zero but no bal in FBL1n
Hi Gurus, In S_ALR_87012103 report,vendor bal as on date is showing zero(i.e.bill booked & paid hence bal zero). But it is not appearing in FBL1N.It is observed that first we made adv to vendor in dec 2006 and then bill booked. Pl advise. Regards, Sa
-
Clearing of Open items (per Vendor)
Hi All, I would like to ask if there is a way to show multiple line items of a single vendor as multiple line items and not the sum of these line items during clearing in F-04. Right now, when clearing multiple line items of a single vendor, these li
-
Problem of upload file into the fieldpoint
hi,all I have build the program for fieldpoint.Then,i want to upload it to the fieldpoint 2000.But it dont allow me to do so,said that it is not authorized to do so. But i cannt upload any file or build any new file. However,i can upload a small VI w
-
500 gig drive only 465 gig. Is this normal?
Hi all, whilst I realize that the amount of space you actually get on a drive is less than it is meant to be, how much is acceptable? Actually, it always made me wonder why the available size is not reported accurately, isn't it contravening consumer
-
I used to be able to export (not import) my bookmarks to my computer in case of crash. The new version (4) doesn't seem to have the feature or else I can't locate it. Your instructions on your help menus are out of date and don't correlate to your ne