I can't move (or even see anything, for that matte

BlitzMax Forums/BlitzMax Beginners Area/I can't move (or even see anything, for that matte

XxGuardianKnightxX(Posted 2008) [#1]
I am a total n00b at BlitzMax. What I really can't stand is how the code will seemingly be perfect, yet something is wrong with it (to make matters worse, I seemingly can't debug line-by-line like before...I gotta compile it in 'debug mode' first.)

For one thing, I cannot see anything save for a blank window, so I cannot do much at all now can I? This problem reared its thoroughly unpretty head at me before, but I realized I could ward it off by properly putting "flip" at the end. Worked fine for text (and a single sprite, albeit one with its ugly magenta mask color still on despite obvious SetMaskColor definition prior, but that's a later story for a later post.)

The "blank window" issue came back up when I coded this:
'so simple and lazy, I won't really bother to comment this piece of crap...
Graphics 640,480,0

w = 10
h = 10

xpos = 320
ypos = 240

'*** Main Loop ***
While Not KeyHit(KEY_ESCAPE)

'moving stuff

'move LEFT
If KeyDown(KEY_LEFT) Then
	xpos = xpos - 1
	EndIf
'move RIGHT
If KeyDown(KEY_RIGHT) Then
	xpos = xpos + 1
	EndIf
'move UP
If KeyDown(KEY_UP) Then
	ypos = ypos - 1
	EndIf
'move DOWN
If KeyDown(KEY_DOWN) Then
	ypos = ypos + 1
	EndIf

'drawing stuff
SetOrigin xpos,ypos

SetColor 0,255,0
DrawRect xpos,ypos,w,h

Cls

Flip
Wend

Please bear with me, I am trying to learn BlitzMax as fast as I can :(


Brucey(Posted 2008) [#2]
Move your Cls above your Draw commands.... Since Cls will "CLear the Screen".


SebHoll(Posted 2008) [#3]
The first thing I spotted is that you are calling Cls immediately before Flip so you should expect to see a blank screen. 'Cls' needs to be instead placed before any of your drawing commands such as DrawRect.

Edit: lol - u beat me to it!


XxGuardianKnightxX(Posted 2008) [#4]
Move your Cls above your Draw commands.... Since Cls will "CLear the Screen".


Just tried it, but it still does not work :(


Brucey(Posted 2008) [#5]
It's because you are changing the drawing origin from the default (0,0) to the centre of the window.
Then... you are drawing the rectangle at the same 320,240 location, which, when translated by the value of the new origin, is actually 640,480 - i.e. the bottom right-hand corner of the window.

You either don't want to SetOrigin at all.... or draw your rect at 0,0.


Perturbatio(Posted 2008) [#6]
remove the setorigin

*EDIT*

Goddammit Brucey, stoppit!


Brucey(Posted 2008) [#7]
Someone ban me please... :-/


XxGuardianKnightxX(Posted 2008) [#8]
remove the setorigin


Works like a charm now!

Hey Brucey, I did you a favor and quoted your advice. Hope that makes you feel better :)

-Dash


Perturbatio(Posted 2008) [#9]
Hey Brucey, I did you a favor and quoted your advice. Hope that makes you feel better :)


Nope, either you quoted my advice and called me Brucey, or you quoted the wrong advice.

You have sucked the life from my very soul with such an act. ;)


XxGuardianKnightxX(Posted 2008) [#10]
It all blurs together for me...
forget I said anything 0_o


Czar Flavius(Posted 2008) [#11]
http://www.dashproject.com/ very interesting website Dash!


XxGuardianKnightxX(Posted 2008) [#12]
http://www.dashproject.com/ very interesting website Dash!

It is a work-in-progress that me and my friend will get around to getting online, but it is not up yet. And please, let's keep this a mature and civil discussion. I don't mean to act like a moderator when I am not one, but I have a need for polite and respectful posts. Seeing as my question is already answered and my program runs fine now, I see no reason to continue posting in this thread.


Czar Flavius(Posted 2008) [#13]
I was merely making friendly banter :) I'm sorry if I appeared rude or immature.


Ked(Posted 2008) [#14]
lol.


XxGuardianKnightxX(Posted 2008) [#15]
I was merely making friendly banter :) I'm sorry if I appeared rude or immature.


I understand, and sorry for my overreaction. I'm just used to being trolled and ridiculed on this half-nightmare we call the internet...you obviously didn't mean it the wrong way though.

I am glad the Blitz forums are so much friendlier than most forums :)