Hello I am in grade 12 programming("ICS4U") and I have decided to create a game in Java for my end term project/exam. I have collected an image off the Internet because I like its perspective. I will be making my own using it as a template. Although I am not very skilled with math and my efforts are outweighed.
Anyways after days of trial and error, I cannot get my collision detection working just right.
I have decided that id post my problem to a forum and hope for the best. :| attached is my entire project RamL.Java is the primary file. Thanks in advance!! I will do my best to return the favor to the forum.
You are unlikely to get an answer unless you post the relevant code in code tags and explain what the problem is. Just saying it isn't working is not good enough, you need to give an explanation of what is happening and what should happen.
Alright, my primary problem is my collision detection is slightly off and locks the sprite in the corner to the far right. My background is attached to this comment.
<\code> public void updateHero() {
sorry never used forums much here is vb6 code i used to try to solve this problem
Code:
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
'calculate the top y
Dim topY As Single
Dim lowerY As Single
'case for the top y
Select Case X
Case 0 To 580
topY = 480 - (335 / 580) * X
Case 581 To 1020
topY = 400 - (235 / 435) * (1020 - X)
Case Else
Exit Sub
End Select
'case for the lower Y
Select Case X
Case 0 To 435
lowerY = 480 + 235 / 435 * X
Case 436 To 1020
lowerY = 400 + 235 / 585 * (1020 - X)
Case Else
Exit Sub
End Select
Label1.Caption = topY
Label2.Caption = lowerY
Label3.Caption = X
Label4.Caption = Y
Select Case Y
Case Is < topY: Form1.BackColor = vbRed
Case Is > lowerY: Form1.BackColor = vbBlue
Case Else: Form1.BackColor = vbWhite
End Select
End Sub
Private Sub Form_Resize()
Line1(0).X1 = 0
Line1(0).Y1 = 480
Line1(0).X2 = 580
Line1(0).Y2 = 160
Line1(1).X1 = 580
Line1(1).Y1 = 160
Line1(1).X2 = 1020
Line1(1).Y2 = 400
Line1(2).X1 = 1020
Line1(2).Y1 = 400
Line1(2).X2 = 435
Line1(2).Y2 = 715
Line1(3).X1 = 435
Line1(3).Y1 = 715
Line1(3).X2 = 0
Line1(3).Y2 = 480
End Sub
I am not completely sure how to create a formula that will detect if your x,y cord is out of bounds on this background, is it distorted ? what shape is the walkable area? I have started looking at tiled base games but I do not understand how it works, or what dimensions would give me a similar look as this image.
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.