Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Author
Message
luskos
19
Years of Service
User Offline
Joined: 28th Jun 2007
Location:
Posted: 3rd Feb 2013 20:16
Hi guys i have this code here which rotates few cubes.My problem is that i can't make all of them rotate and point in one direction as i want them to .I'm making magic cube (rubik's) game.If you replace line 51 : for i = 6 to 9 with for i = 2 to 9 you will see what happens.I tried to find a way to make rotation of last 4 cubes right, like the real puzzle but no success...Please help me if you can.



Coding is My Kung Fu!
And My Kung Fu is better than Yours!
mr Handy
18
Years of Service
User Offline
Joined: 7th Sep 2007
Location: out of TGC
Posted: 4th Feb 2013 06:58


This?

*** Merry Chuckmas! ***
luskos
19
Years of Service
User Offline
Joined: 28th Jun 2007
Location:
Posted: 4th Feb 2013 11:51
Yes, that's it.Sometimes it's hard to think simple. Thank you!

Coding is My Kung Fu!
And My Kung Fu is better than Yours!
Chris Tate
DBPro Master
17
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 4th Feb 2013 17:38
Quote: "Sometimes it's hard to think simple."


I disagree. It is always hard to think simple, especially with programming.

TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 4th Feb 2013 17:40
Quote: "I disagree. It is always hard to think simple, especially with programming."


Or anything that requires technical logic for that matter (circuits, maths, physics, etc.)

TheComet

http://blankflankstudios.tumblr.com/
"ZIP files are such a retarded format!" - Phaelax
luskos
19
Years of Service
User Offline
Joined: 28th Jun 2007
Location:
Posted: 6th Feb 2013 13:42
Hi again, i have another problem i'm unable to solve do to my bad understandings how exactly limbs work.Here is some sample code i ripped out of my rubik's game to be...It works just i want it to but there is something strange happening when rotation ocures.If you look at positions you will see that when you rotate cubes some positions deviate from originaly inteded. Example: If you hover the mouse on object 9 it shows x:0 , y:0 ,z:0.When you rotate counterclockwise object 7 goes where 9 was but "y" says 2.185... though the object is at the right place the limb goes not where i expect it to be.And this is a problem because i use plains just like in this example for every side of the cube to group cubes and if a limb offsets like this, sometimes it goes in wrong group and cube start rotating randomly> Sometimes program crash if some random cube goes in a group array and overload it because the arrays are designed to hold 9 cubes at any given time in a group, but suddenly they become 10 or more.I can't figure out some workarround for this.

Here is the code:


Coding is My Kung Fu!
And My Kung Fu is better than Yours!
mr Handy
18
Years of Service
User Offline
Joined: 7th Sep 2007
Location: out of TGC
Posted: 6th Feb 2013 14:00
For your sake I'd say that famous 3ds max does same crap.

Why you can't just store cube sides data as array, why so physical?

*** Merry Chuckmas! ***
luskos
19
Years of Service
User Offline
Joined: 28th Jun 2007
Location:
Posted: 6th Feb 2013 14:41
Just because i could not figure out how to do it.I imagine that i can use speceific cube positions to determine in which group to add them, but i think with this kind of rotation the problem will persist.

Coding is My Kung Fu!
And My Kung Fu is better than Yours!
mr Handy
18
Years of Service
User Offline
Joined: 7th Sep 2007
Location: out of TGC
Posted: 6th Feb 2013 14:58
The problem is with data precision. Howewer it is strange, 'cause you rotating cubes by 10 degrees, there should be no problems.

*** Merry Chuckmas! ***
luskos
19
Years of Service
User Offline
Joined: 28th Jun 2007
Location:
Posted: 6th Feb 2013 15:37
So we have no clue what's wrong here...

Coding is My Kung Fu!
And My Kung Fu is better than Yours!
mr Handy
18
Years of Service
User Offline
Joined: 7th Sep 2007
Location: out of TGC
Posted: 7th Feb 2013 06:51 Edited at: 7th Feb 2013 06:54
But I don't see a reason why you need to get position; you just need to make two arrays of 26 values, to store correct cubes layout (win) and current, and manually refresh current (all your sides are moving strictly 90* so it is easy). You don't need to check every side, just common layout.

p.s. in arrays you can store cubes ID , from 1 to 26.

Win array layout:

1 2 3
4 5 6
7 8 9

10 11 12
13 _ 14
15 16 17

18 19 20
21 22 23
24 25 26

*** Merry Chuckmas! ***
luskos
19
Years of Service
User Offline
Joined: 28th Jun 2007
Location:
Posted: 7th Feb 2013 21:58 Edited at: 10th Feb 2013 15:29
I tried that and it\'s the same as before, cubes flying in all directions.I think the problem is that rotation is interrupted if you click and move the mouse in two oposite directions or diagonally.If you rotate the cubes and click really fast somwhere before rotation end, it stops in the middle.I tried many times to make it uninterruptible.I upload everything for you Handy to check it out or anyone else.I\'m really tired now.

Coding is My Kung Fu!
And My Kung Fu is better than Yours!
mr Handy
18
Years of Service
User Offline
Joined: 7th Sep 2007
Location: out of TGC
Posted: 8th Feb 2013 07:51 Edited at: 8th Feb 2013 07:53
Sorry, I don't have much time right now, but had a quick look:
1. your path to files is absolute, that's wrong, make it relative.
2. i think there is some vertical grouping mistakes.
3. rotation logic is not correct - i can make cube spin forever in different directions without moving mouse. i think it must be redone.
4. mouse wheel strange behaviour.

*** Merry Chuckmas! ***
luskos
19
Years of Service
User Offline
Joined: 28th Jun 2007
Location:
Posted: 8th Feb 2013 13:21 Edited at: 10th Feb 2013 15:30
1 Is not big issue for now it\'s simple overlook.

2 I forget to add few lines.I attach source with corrections.
I double checked it should be correct now.Excuse me about that i work on this late at night.

3. I tried to make it right many times, not sure how to do it without moving the mouse.

4.When you turn the wheel it either goes away from the cube or closer, if it goes to close to the cube it spins the camera at the oposite direction of the cube, you can either right click and rotate the camera 180 degrees or spin the wheel.

Coding is My Kung Fu!
And My Kung Fu is better than Yours!
mr Handy
18
Years of Service
User Offline
Joined: 7th Sep 2007
Location: out of TGC
Posted: 8th Feb 2013 13:53 Edited at: 8th Feb 2013 13:56
3. Mouse move is a good idea, it's just not correct handled.

Still rotation grouping problem

*** Merry Chuckmas! ***
luskos
19
Years of Service
User Offline
Joined: 28th Jun 2007
Location:
Posted: 9th Feb 2013 16:59
Mouse is now correctly handled and i started working on rotation grouping problem.

Coding is My Kung Fu!
And My Kung Fu is better than Yours!
luskos
19
Years of Service
User Offline
Joined: 28th Jun 2007
Location:
Posted: 10th Feb 2013 07:49 Edited at: 10th Feb 2013 15:31
As it seems grouping works fine.I've implemented Log system to keep track of regrouping, make few rotations and exit then there should be log.txt.The funny thing is that if you rotate first Blue side then Orange side once it works.Source attached.

Example log:

Log start
REPOSITION [1] CW BLUE 120
GROUP SHUFFLE START
BEFORE SHUFFLE:
[56][31][66]
[51][20][61]
[58][42][68]
AFTER SHUFFLE:
[58][51][56]
[42][20][31]
[68][61][66]
GROUP SHUFFLE END

Blue Group: 58,51,56,42,20,31,68,61,66


Orange Group: 65,63,56,32,30,51,55,53,58

REPOSITION [1] LEFT ORANGE (Clockwise)
GROUP SHUFFLE START
BEFORE SHUFFLE:
[65][63][56]
[32][30][51]
[55][53][58]
AFTER SHUFFLE:
[55][32][65]
[53][30][63]
[58][51][56]
GROUP SHUFFLE END

Orange Group: 55,32,65,53,30,63,58,51,56


Blue Group: 56,63,65,42,20,31,68,61,66

REPOSITION [1] CW BLUE 120
GROUP SHUFFLE START
BEFORE SHUFFLE:
[56][63][65]
[42][20][31]
[68][61][66]
AFTER SHUFFLE:
[68][42][56]
[61][20][63]
[66][31][65]
GROUP SHUFFLE END

Blue Group: 68,42,56,61,20,63,66,31,65


Orange Group: 55,32,56,53,30,42,58,51,68

Coding is My Kung Fu!
And My Kung Fu is better than Yours!
mr Handy
18
Years of Service
User Offline
Joined: 7th Sep 2007
Location: out of TGC
Posted: 10th Feb 2013 09:22 Edited at: 10th Feb 2013 09:28
I have an idea. Add this to the end of loop:

The idea is to fix object pivot, so when any side has been rotated, all cube pivots are reset! This code fixes rotation - all cubes are rotating correctly, but it is not well tied with your code. I hope you got the idea.

About grouping issue: your groups are dynamic?

*** Merry Chuckmas! ***
luskos
19
Years of Service
User Offline
Joined: 28th Jun 2007
Location:
Posted: 10th Feb 2013 12:40 Edited at: 10th Feb 2013 14:19
I found the solution, it's called EZrotate, now everything works perfectly i started adding more sides.By the end of the day whole cube should be done.Accidently purchased it the other day.I thought that i cancel the order and today i saw it, so i took advantage.Really good plugin.Anyway i'm glad you helped me so much with this.From every advice you gave me i've learned something.And about groups, i think you can call them that way.It's real pain to code them but it's worth the time.I didn't change them at all just added few lines and everything worked like magic.

Coding is My Kung Fu!
And My Kung Fu is better than Yours!
mr Handy
18
Years of Service
User Offline
Joined: 7th Sep 2007
Location: out of TGC
Posted: 10th Feb 2013 16:04
That's cool!
But personally I like challenges, maybe later I try to make rubik's cube without plugins, using DBP only.

*** Merry Chuckmas! ***
luskos
19
Years of Service
User Offline
Joined: 28th Jun 2007
Location:
Posted: 10th Feb 2013 18:33
I could of done it without plugins too, but when i saw your post it was too late to rewrite everytithing that work fine just to test if it solves the problem.It was a challenge for me.I hope you have lots of fun with that challenge.Cheers!

Coding is My Kung Fu!
And My Kung Fu is better than Yours!
mr Handy
18
Years of Service
User Offline
Joined: 7th Sep 2007
Location: out of TGC
Posted: 11th Feb 2013 11:32 Edited at: 11th Feb 2013 11:33
Don't forget to post final exe!

*** Merry Chuckmas! ***
luskos
19
Years of Service
User Offline
Joined: 28th Jun 2007
Location:
Posted: 11th Feb 2013 21:09
http://forum.thegamecreators.com/?m=forum_view&t=203559&b=5&p=0

Coding is My Kung Fu!
And My Kung Fu is better than Yours!

Login to post a reply

Server time is: 2026-07-07 05:15:09
Your offset time is: 2026-07-07 05:15:09