| Blockland Forums > General Discussion |
| OH MY GOSH IM LEARNING TO CODE |
| << < (8/12) > >> |
| Racerboy:
--- Quote from: Yosher on September 08, 2012, 08:09:11 AM ---*learning to steal and horribly edit addons --- End quote --- Oh my god... Gj Setro, 10/10 |
| Jetlok:
i dont think setro is smart enough to learn how to code --- Quote from: Yosher on September 08, 2012, 08:09:11 AM ---*learning to steal and horribly edit addons --- End quote --- ahh see? |
| M:
--- Quote from: Kaphonaits² on September 08, 2012, 06:03:51 AM ---<3. --- End quote --- <3 --- Quote from: Kaphonaits² on September 08, 2012, 06:03:51 AM ---On a totally unrelated note, I'm ashamed that I pretended to use weird fake enums in Torque Script. --- Code: ---$Pref::BlockyTraitors::Enum::ROLE_DEAD = 1; $Pref::BlockyTraitors::Enum::ROLE_INNO = 2; $Pref::BlockyTraitors::Enum::ROLE_TATER = 3; $Pref::BlockyTraitors::Enum::ROLE_WATCH = 4; --- End code --- --- End quote --- It is actually good to do that (though you wouldn't want something like that in the Pref namespace) - makes your code easier to read. No need to write comments if your code's behaviour is obvious from reading the code itself. I personally would have used something like $BlockyTraitors::Role::Dead. |
| Supreme Guy:
I'm learning to code in flash, it's really fun. http://puu.sh/1385U 69 lines of code, fairly challenging. When you learn the ropes it's a real joy to do this stuff though. --- Code: ---import flash.events.Event; import flash.display.Sprite; //written by Samuel Struik //8 September 2012 /* T = make a rectangle move across the screen three times. once this is done, the rectangel will begin following the mouse. O = rect_mc, feedback_txt M = Use booleans to toggle the mouse following and the automatic movement. use if statements to increment variables and make the rectangle return to its original side. */ //**variables //shapes var rect_mc:Sprite = new Sprite(); rect_mc.graphics. beginFill(0x333333); rect_mc.graphics.drawRect(-5, -5, 10, 10) rect_mc.graphics.endFill(); stage.addChild(rect_mc); rect_mc.y = 200 rect_mc.x = -21 //numbers, booleans var dragToggle:Boolean = false; var crossCount:Number = 0; var moveDirec:Number = 1; //**Event Listeners stage.addEventListener(Event.ENTER_FRAME, enterFrameHandler); //**functions function enterFrameHandler(e:Event):void{ //if the dragToggle boolean isn't active if(!dragToggle){ if(moveDirec == 1){ //use the equation of acceleration to make the object decellerate rect_mc.x += (575 - rect_mc.x)/8 if(rect_mc.x > 571){ //when the movieclip's x coordinate is larger than 571, increment the crossCount variable by one and make the direction variable change. crossCount ++; moveDirec = 2; //display the variable in the text field. crossFeedback_txt.text = ""+String(crossCount)+""; } } if(moveDirec == 2){ //use the equation of acceleration to make the object decellerate rect_mc.x += (-25 - rect_mc.x)/8 //when the movieclip's x coordinate is smaller than -25, increment the crossCount variable by one and make the direction variable change. if(rect_mc.x < -21){ crossCount ++; moveDirec = 1; //display the variable in the text field. crossFeedback_txt.text = ""+String(crossCount)+""; } } } if(dragToggle){ //yet again, using the equation of acceleration to make the square move smoothly. rect_mc.x += (stage.moulove - rect_mc.x)/6 rect_mc.y += (stage.mouseY - rect_mc.y)/6 background_mc.gotoAndPlay(2); } if(crossCount == 5){ dragToggle = true; //inform the user of the square's new behaviour. crossFeedback_txt.text = "The square will now follow your cursor."; } //displaying the x and y coordinates of the shape and the mouse, for debugging. rectxy_txt.text = "rect_mc.x = "+String(rect_mc.x)+"\nrect_mc.y = "+String(rect_mc.y)+""; moulovey_txt.text = ""+String(moulove)+" = moulove\n"+String(mouseY)+" = mouseY"; } --- End code --- |
| Reinforcements:
--- Quote from: Isaac Fox on September 08, 2012, 05:04:08 AM ---Why, why, why are my parents forcing me to learn Python? I want to learn TorqueScript, dammit! --- End quote --- Don't be so frustrated, once you learn one language, it's much easier to learn the next language. ;) |
| Navigation |
| Message Index |
| Next page |
| Previous page |