Blog 26

Today in class we worked on our projects. In DAT602 I am happy with my progress I have the GUI connecting to my GameData class and so when I click buttons in the GUI MySQL procedures are run. For example I have the enter username, login, and create account procedures all working correctly.

Todd showed us how to get get the datagridview click event code working, which I implemented along with a message when the data grid cell is selected that specifies what cell the user clicked on.

The next job I have to do is implement the link between the GUI and the administrative, logout and gameplay actions.

Advertisements
Blog 26

Blog 25

Today because it was the Queens Birthday there was no DAT602 class, but that does not mean I wasn’t working on DAT. I finished off my screen designs. David told me the other day how Todd had helped him to get the data grid view working, because we were the only two people in the class that had a problem getting it working. To get it working I used a GameData class to store the code that Todd had put online and I altered it around to be appropriate for my database procedures.

I linked it up to my FindAllOnlinePlayers procedure and when run it displayed all online players.

I have now pasted the test class code I wrote for Milestone two into the GameData class as Todd had recommended last week.

I also spent a large proportion of the day working on DAT601 working on the coding and my report.

 

Blog 25

Blog 24

Today in the class of Wednesday the 1st of June Todd covered how we split the program up into different tiers, to separate the concerns of our system. This process will be required for our milestone three hand in.

For example any data retained should be stored in a module so that it can be accessed from any form rather than having to be called by each from. So it is a bit like a global variable in that everything can access it.

We put all stuff that connects to data (in test) in class called GameData, in other words paste all the test class code from milestone 2, into a GameData class in the windows forms application for milestone 3 (Because the test class called procedures in the MySQL database).

The GameData is defined inside a module, and when module is run then it creates a publicly available instance of the GameData.

Class Notes:

When coding in the IDE it helps us to write the code, but not structure the program. We want to separate the GUI from the business class, and store persistent data in something called a model, which is just a class named GameData.

We use a method of thinking called N-Tier design-it separating concerns out depending on what they are functioning on.

This architecture imposes a structure or shape on the program your writing. e.g. If code makes something happen in graphical area then put it in the GUI (e.g. frm code).

The business class is the “do something class”. Whenever you want something retained and stored you go to the model, it acts as a store that retains the state. State may just be call to database.

 

For our Milestone 3 we need the model to store PlayerID and GameID, as these are persistent data values that need to be stored, these are pulled out of the database in the GameData class. We call the GameData class from a module with the following code:

Module ModuleGS
Public aGameData As GameData = New GameData()
End Module

The GameData object needs to be rapped inside a module as a GameData so that our project should not have the GameData in each form but in a module instead. Anything  in a module in vb is globally named. You call GameData with GB.

For milestone three we must have Login, select, and show Game working GUI.

So in every program when you have something not specifically related to GUI you place it in business instead. So whenever some action happens in GUI it is stored as event in business tier, as it is not specifically tied to the GUI.

We need to retain state across all parts of program we use a static class, there is only one of these in each application therefore called a singleton. A module is called a singleton. So anything that ephemerally does the work calls the module to get the work done.

We can paste the Test class code from our milestone 2 into a GameData class:

Public Class GameData ‘This is a data object that stores persistent data about GameID and PlayerID
Private _players As List(Of tblplayer)
Private _gameID As Integer = -1
Private _thisPlayer As String
Private db As gamedbEntities = New gamedbEntities()

Public ReadOnly Property Players() As List(Of tblplayer) ‘This gets the players by calling the getPlayers procedure in the MySQL
Get
‘ New everytime
_players = (db.getPlayers()).ToList()

Return _players
End Get

End Property

Public ReadOnly Property GameID As Integer
Get
Return _gameID
End Get
End Property
Public Function RegisterGame() As Integer
_gameID = ((db.regGame()).ToList()).First()
Return _gameID
End Function

Public Sub RegisterPlayer(pGame As String, pName As String, pPass As String)
Dim dummy = db.regPlayer(pGame, pName, pPass)
End Sub

End Class

Project Work:

I had created all the GUI forms for my game in Milestone 1 as screen designs but having looked through all my files and external hard drive backups I cannot find this Visual Studio application and so I will go through creating all the GUI forms again this afternoon.

We must make sure that our VB Windows forms application has the entity reference version 5, before creating the VB application.

When making forms that need to be updated with a timer calling a refreshdata procedure we need to set the form to double buffered=true, so the data grid view does not flicker.

Make a method that encapsulates refreshdata that can be called when form created, and when timer ticks.

So information retained between forms should be put in a module so you can just call the module and it will be available to you inside the application.

 

Note: Property is a pair of methods in a particular syntax  that looks like an attribute

Blog 24

Blog 23

Today in the class of Monday the 30th of May we covered the connection of the data control to data-source. We talked about the GUI control and component concepts.

Todd showed us how to use a data grid view to display data from the database on the Windows Form.

Both David and I followed Todd’s method exactly but both got the same error after selecting the database to connect to (after checking the database connection which was successful) but after selecting a table and pressing the “Finish” button we got a error (see below screenshot:

DAT602 error data grid view.PNG

Both David and I checked our connection string to the database with Todd and it was identical. Everything else was identical between our computer except I had an updated version of Visual Studio, but David didn’t.

I also believe that I had everything the same as Jonathan who had easily connected the data grid view to the database and was now playing around with inserting data to the database which was then displayed on the data grid view.

Aaron and DJ also easily connected to their database from with the data grid view, so it seemed that for some completely unknown reason only David and I had this problem.

Todd suggested we got the updated MySQL plugin for Visual Studio, which I will try to do this evening.

Class Notes summarizing whats needed for DAT602 Milestone 3:

There are two features we will implement in our game for the milestone 3, graphical control, and component.

A graphical control is some representation of system that allows you to control something. The prime example of this is the button, when you click on it ti does something. A control is a representation of physical switches, button, etc.

Therefore a graphical control can be anything you can interact with and it will do something.

Whilst a component is a reusable chunk of mechanism that has various types of interfaces in it that will let the system integrate itself in a IDE. The component doesn’t necessarily have a GUI parts to it.

So control is a specialization of a component.

A component can be interrogated by IDE to provide you by what facilities are available for that particular component.

We watched a video on using the data grid, here’s what I got out of the video:

For MS3 we will make a graphical version of the system, we will make a windows form application. Take a button, labels and textbox and then drag and drop in the data sub menu and select the data grid control.

Select the data grid control and the triangle on top right corner it allows you to manipulate the grid. Select “Choose data source”

Do no enable the “Enable adding” or “Enable editing”.

Then double click the button, to create the button event handler which produces code you see, and then there is manipulated code manipulated by GUI .Write:

Me.DataGirdView.Row.Add(txtName.Text, txtSurname.Text)

Inside the brackets we write the number of columns the data grid view will show (i.e. number of columns in the data grid view). So when you add data to the form the data is shown in the data grid view columns, this only adds data to local system it is not connecting to the database.

 

Project work:

In our game we will need a timer, but is a timer a control or a component. The timer is a component as it doesn’t have a representation on the form, even though it has a event the ‘tick’ associated with it it isn’t represented on the GUI.

The timer is a component that will be made with a from at the same time as the controls of the form.

We will need a timer for your game because you can do a refresh on a timer. A timer will allow you to check if there has been changes in the game since you last did something.

Timer is recommended to ‘tick’ 5 times per second. As the timer property is set in millisecond then specify it ‘tick’s every 200 milliseconds. When you join the game your timer starts.

Anytime when something happens it goes to the server, it doesn’t get back pulled down again until the UpdateDisplay() method is called by the timer which has a period of time 200 milliseconds between ‘ticks’

Between every 200 milliseconds a method UpdateDisplay() it will go to the database and grab the the new location of the moving object for display on the GUI, but to make the game fair every time a control is selected in the UpdateDisplay() method is called pulling the new location for the GUI for both users. You also have the Timer component call the UpdateDisplay() method every  200 millisecond

If each users display is updated every 200 milliseconds then the longest possible time between two different users updates is 100 milliseconds.

 

 

 

Blog 23

Blog 22

Today in the class of Wednesday the 25th of May we just continued to work on our assignments due on Friday. Todd answered questions of several of the students. I continued to work on calling my MySQL procedures from Visual Studio which I have almost finished.

I have also added further functionality to my MySQL adminplayerlock and adminplayerunlock procedures by checking if the account is already locked (if executing the adminplayerlock) or unlocked (if executing the adminplayerunlock) in addition to the previous check if the user performing the administrative action is set to administrator (which Todd recommended). The reason I added this additional IF statement check was I thought it is no good locking/ unlocking a user account that is already locked/unlocked therefore it is just an additional safety check.

I have assisted in teaching a few people how to connect to MySQL database from their test class application, and have helped troubleshoot some mistakes that I had previously, that Jonathan had kindly helped me with or that I had troubleshooted through trial and error.

I have found that once you get the hang of the test class coding it is fairly easy, however it is hard to learn because Visual Studio is temperamental and presents fairly obscure errors such as “Add function import” because you haven’t added a MySQL procedure from in my case the dat602gamedbModel.Store to the dat602gameModel and so the test class cannot access the MySQL procedure. I find such errors hard to workout first time and they take a lot of troubleshooting to understand.

Blog 22

Blog 21

Today in the class of Monday the 23rd of May we did a project study session. I tried to help Harry with the dilemma he was having with updating the location of the tiles in his tile game. Later Harry also asked Todd.

I sat down with Becca and clarified some of the attributes she had used in her logical entity relationship diagram for DAT601, as I was trying to create some example data for the attributes.

Later I asked Jonathan about his test class, as mine only had the login procedure as that was all I could construct in the time I had before emailing it to Todd for feedback on Friday. After discussing the test class with Jonathan I realized that I needed to include a call to all my MySQL procedures not just the LoginProcedure. Therefore my job for the rest of the day is to finish off the test class VB file.

 

 

 

Blog 21

Blog 20

Today Wednesday the 18th of May because the class was optional I stayed at home and worked on finishing my DAt602 MySQL procedures to meet the assignment requirements, and try to get the test class code set up from the code example that Todd has put on Moodle so I could email my MySQL procedures and test class code to Todd for feedback.

I have now got 20 procedure including one to create all my database tables (this is from milestone one), another to insert data to all my tables, and the other 18 procedure are performing the CRUD actions that shows the database transactions that the game must perform.

I will not paste my code on the blog because I do not want plagiarism errors, however I have got all the procedure running successfully in a single file with no errors.

After spending most of the day commenting and improving my procedures, and trying to understand what was required for the test class hand in, I started work on it. I watched the two videos that Todd put up on Moodle.

I created a new project and then connected to the database. I started to create the test class as was shown in the second video. After creating the test class I had several errors, I found 2 of those errors was because I had written in the database name but did not follow it with “entities” for instantiating the object to represent the database dat602gamedb.

So after fixing that issue I still had one more error saying the result of the login procedure I was running did not exist. After some troubleshooting I found that this was because I needed to set the return type of the LoginProcedure in the stored functions drop down menu. After doing this I set the return variable _return equal to the result of the query. Now there were no more errors. However when I ran the code all got was a blank command prompt interface, after some thinking and discussion with other students I realized that there was no code in the Main.vs because when I had pasted it in it was under the Module header and the Import code threw an error because that needs to be at the top of the page. Therefore I write the Import code at the top of the page and then wrote the rest of the code as Todd had it on Moodle. I tried running it and it worked successfully, this time I got a message on the command prompt saying “Login unsuccessful” for the parameters I had written in Visual Studio t be passed to the MySQL procedure.

After this I checked my MySQL code and then emailed both the MySQL code and the test class and Main code to Todd.

For my project I have to write up my rationale for the MySQL procedural code now that I have finished writing it up. I also will have to wait for feedback from Todd about my test class code before writing up my rationale for that.

 

Blog 20