Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

help with bug
Started by zettelrhean Oct 09 2018 12:06 PM

9 replies to this topic
lua corona
[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

zettelrhean

[GLOBAL: userInfoPane.html]
zettelrhean
  • Observer

  • 25 posts
  • Corona SDK

i dont really know where else to place this but im having troubles with a bug that i CANNOT find a way around, its with the movement of the player, i have squares around the player on a grid system but once they get next to a wall the squares start to bug out, its really hard to explain so ill just attach the whole thing to this so that hopefully someone can help me

Attached Files



[TOPIC: post.html]
#2

cyberparkstudios

[GLOBAL: userInfoPane.html]
cyberparkstudios
  • Contributor

  • 538 posts
  • Corona SDK

If you see the error messages that print to the Corona Simulator Console output you will see 'room.png' cannot be found because the path and name of the image files are case-sensitive.  In your main folder your have 'Room.png', so you will always get an error since the case does not match.

 

I think there are several other image files you have there that are going to crash because they also do not match by case.

 

It is also good organizational idea to place all the images/textures into a folder.  Name that folder anything you want, but the normal way devs name the folder that holds the image assets something like 'Images' or 'Textures' or 'Assets' or 'Pics' .... just be sure to include that as the path to the image

 

example:

mveSqrR = display.newImage("Images/movementSQR.png")

 

other then 'case-sensitive' issue I have not looked at the code.  Try to get those image names correct first and then see if you are having any issues.

 

Best of luck!

 

Bob



[TOPIC: post.html]
#3

roaminggamer

[GLOBAL: userInfoPane.html]
roaminggamer
  • Corona Geek

  • 7,363 posts
  • Corona SDK

Side note: You're case names are wrong for these files:

button.png, grid.png, Player.png

 

You need to be careful about case.

 

 

Looks like @cyberparkstudios and i were typing at the same time.

 

Yes.  Please correct all the case-errors and re-post the example if it still has issues.  

 

Tip: Be sure to pay attention to the console log.



[TOPIC: post.html]
#4

cyberparkstudios

[GLOBAL: userInfoPane.html]
cyberparkstudios
  • Contributor

  • 538 posts
  • Corona SDK

Let me correct one thing.  I think the simulator just warns about the path..  (if I remember correctly it will crash on a device) if they are not matching by case....  however maybe Corona has fixed that so it works on devices as well.  I just always make sure case matches between my filename and the code.

 

I think it is good practice to make sure they match.

 

I will look at the code now, and see what I can see.


  • roaminggamer likes this

[TOPIC: post.html]
#5

cyberparkstudios

[GLOBAL: userInfoPane.html]
cyberparkstudios
  • Contributor

  • 538 posts
  • Corona SDK

If you could be more clear on what bugs out..  I can move the character to the right edge of screen,  and can move him from there to the top, bottom and 3 left green squares(which are visible) but the 3 right green squares are off right side of screen ... I can get him moved back to the left from there, using the right button on the bottom left corner of the screen.

 

So I am not sure what bugs-out, and not sure if you want the 3 green buttons on right to go off screen or not.  I an not sure what the brown squares that show in the center of the grid are for..



[TOPIC: post.html]
#6

zettelrhean

[GLOBAL: userInfoPane.html]
zettelrhean
  • Observer

  • 25 posts
  • Corona SDK

If you could be more clear on what bugs out..  I can move the character to the right edge of screen,  and can move him from there to the top, bottom and 3 left green squares(which are visible) but the 3 right green squares are off right side of screen ... I can get him moved back to the left from there, using the right button on the bottom left corner of the screen.

 

So I am not sure what bugs-out, and not sure if you want the 3 green buttons on right to go off screen or not.  I an not sure what the brown squares that show in the center of the grid are for..

the brown sqaures are an unadded obstacle layout, and no the squares are not supposed to bug out when they get to the edge of the screen, thats the problem



[TOPIC: post.html]
#7

zettelrhean

[GLOBAL: userInfoPane.html]
zettelrhean
  • Observer

  • 25 posts
  • Corona SDK

for the people who got the image errors i went through and fixed it

Attached Files



[TOPIC: post.html]
#8

XeduR @Spyric

[GLOBAL: userInfoPane.html]
XeduR @Spyric
  • Contributor

  • 361 posts
  • Corona SDK

I downloaded the project and tried it, but to be completely honest, I couldn't make a lick of sense of what is supposed to happen and what the problem might be.

I took a glimpse at your code and I would recommend that you try to figure out a more logical means of determining if those movement squares (?) are visible or not. What you want is a function that you can call to check all of the tiles where the player could potentially move and check if those tiles are impassable or not. If a tile is impassable, then make the associated movement symbol invisible. That way you would run into the issue of having extra green squares pop up in odd places.

 

Also, take this from me, trying to maintain an if else statement that is thousands of lines long is insane. If you ever need to change something, you'll need to go through all of that code again, and again, and again, until you begin to hate your code. Also, by using a "more universal" function, you'll have an easier time debugging your code and/or inserting new gameplay mechanics into the game, etc. I'd reckon you could cut 2000 lines off your code by replacing those if else statements and object creations with smart function(s) and loop(s).



[TOPIC: post.html]
#9

cyberparkstudios

[GLOBAL: userInfoPane.html]
cyberparkstudios
  • Contributor

  • 538 posts
  • Corona SDK

@zettelrhean

 

Thanks for fixing those image names.  I tested ver 2 and 'grid.png/Grid.png' still not matching case.

 

I am still not sure what you mean by 'bugging out'.  Do you mean those brown squares are not suppose to even be on the screen?

There not suppose to be in the center of the screen?  They are not suppose to be that many or in that shape/formation?  

 

I have yet to really look over the code, because it is going to take some time as it is.  Xedu R is correct, it is difficult to tell what the purpose of the code is besides the obvious move the character in the direction of the chosen green square. But then I have not really gone over all the code (2500 lines) yet....

 

but I wanted to mention some things that will be of great help to anyone.

(I am guessing you are relatively new to programming, so maybe these pointers can help)

 

1. try to get a good understanding of 'scope' - I see no 'local' variables.  Everything is global in your code, and that is almost universally considered problematic.  This is very common to newer programmers.

 

2. corona documentation: at the top of the forum page, click on documentation tab.  Maybe go thru the 'getting started', even if you already did... if nothing else see how in the examples, when 'local' is used and not used.  Try to get an strong understanding of 'events' in corona, particularly the 'touch' event. One of the most used events in Corona.

 

3. Put aside this project for a day or so and go over some of the Sample-Code that is in the corona sdk folder.  Do the code and play around changing some of it to get at least a little understanding how all the 'corona components' work.  I think I would avoid physics for awhile, till you get a good feel of the rest of the components.

 

Best of luck, and I will look at version 2 of your code a little later today.  I hope to hear from you before then with more specifics about the bugging issue exactly.

 

Bob



[TOPIC: post.html]
#10

cyberparkstudios

[GLOBAL: userInfoPane.html]
cyberparkstudios
  • Contributor

  • 538 posts
  • Corona SDK

@zettelrhean

 

There is a lot of code to redo on your example, and without knowing what the purpose of everything is, and what the bug is I decided to piece together a quick skeleton app that I think does at least some of what you are trying to do.

 

The idea here is, if you want, look over the sample I have attached, and see if it makes sense to you.  Then try and expand that code to get it to do what you want.  It might be better then piece by piece trying to re-do/un-do/convert your existing code.

 

I tired to keep the code close to what you were doing and used just a few of your images, since I only did the background, grid, player, direction boxes and movement(I think that is the bulk of your code).

 

1. As there was little information to work with, it is not the best or only way to do it. If it was my project I would code it differently, but this example works and can be built on by you; if you choose to.  I coded it this way, as it also leaves less for me to explain - in that I mean, I think for a beginner you will be able to grasp the example as it is better then say a more efficient-fancy way of coding it. If nothing else, it can give you an idea on how to re-do your code.  I recommend redoing your code because of the lack of local variables, super-large functions, and way more lines of code then it seems needed. 

 

2. The sample I have attached (although not doing exactly all of what your code was doing) is only 200 lines of code compared to nearly 2500 lines. So you can see where it will reduce your code alot and help in troubleshooting any bugs.  The way you had your code( 2500 lines), makes debugging super hard.

 

3. I did nothing with the config file or anything else I normally would do, to try and keep to the code and keep things as simple as possible.  I did notice a lot of 'scaling' in your code. I can guess why you are doing that, but I would try and avoid that; unless you really need to for some reason.

 

I hope this helps in some way.

 

Bob

 

 

 

Attached Files




[topic_controls]
[/topic_controls]

Also tagged with one or more of these keywords: lua, corona