Code Help (ARCE)

Whether you're a newbie or an experienced programmer, any questions, help, or just talk of any language will be welcomed here.

Moderator: Coders of Rage

TheLividePianoist
Chaos Rift Newbie
Chaos Rift Newbie
Posts: 15
Joined: Thu Jan 29, 2009 5:48 pm

Code Help (ARCE)

Post by TheLividePianoist »

Don't mean to come with my every coding problems but I was wondering if someone with a bit of experience, preferably ARCE, in Blitz Plus could give me a hand. Well, I'm trying to create an adventure log (a text prototype at the moment) and I'm trying to create a scrolling effect. For some reason what I thought would've been a simple addition isn't working. I have 3 Text Positions, Logline1$, Logline2$, & Logline3$ like this:

Code: Select all

Text 200,405, "ADVENTURE LOG"
Text 200,425, logline1$ 
Text 200,440, logline2$ 
Text 200,455, logline3$ 

Code: Select all

If ImagesCollide(player,x,y,0,chest,chest1\x,chest1\y,0) Then
	If KeyHit(57) Then 
	If frame = 0 
		numpicked = numpicked + 1  
		numopen = numopen - 1
	EndIf 
	
		If numpicked = 1 Then 
			logline1$ = "Player has obtained a Radogin Bow" 
		ElseIf numpicked = 2 Then
		 	logline2$ = "Player has obtained a Radogin Bow"
		ElseIf numpicked = 3 Then
			logline3$ = "Player has obtained a Radogin Bow" 
		ElseIf numpicked = 4 Then 
		If numopen = 0 Then 
			logline4$ = "Player has obtained a Gun"
			logline3$ = "Player has obtained a Gun" 
			logline2$ = "Player has obtained a Ragodin Bow"
			logline1$ = "Player has obtained a Sword" 
		EndIf   
		EndIf 
				
		frame = frame + 1
		If frame = 3 Then frame = 0  
		
		If numpicked = 3 Then 
		occupied = 1 
			Inv3$ = eq4$ 
		ElseIf numpicked = 2 Then 
			Inv2$ = eq4$ 
			occupied = 1
		ElseIf numpicked = 1 Then
			Inv1$ = eq4$ 
			occupied = 1 
		EndIf 
		If frame = 1 Or frame = 2 Then 
			PlaySound LockLatch
 		EndIf 
	EndIf 		
EndIf 
Basically it states that if, frame = 0 (chest frame) then # of times the chest is open is subtracted by 1 and the # its picked is added by 1. If the # it was picked = 4 then a new line for the adventure log is added (logline4$). Another coder told me that all I'd have to do is make logline4$ - logline3$ and logline2$ - logline1$.....I tried and failed. I'm pretty sure it is simple and I'm just not getting it. I appreciate the help and any remake of the code if necessary is alright.

Keep in mind that I am a beginner coder and I don't have your "experience".
-TheLividePianoist
User avatar
Arce
Jealous Self-Righteous Prick
Jealous Self-Righteous Prick
Posts: 2153
Joined: Mon Jul 10, 2006 9:29 pm

Re: Code Help (ARCE)

Post by Arce »

Sorry for my lack of response...I've been busier than shit lately...=/

I'll get to it in a day or so, when I'm done with my editor abstract and research outline, as well as any other homework.

Also, thanks for making a clear, concise post detailing the problem. Doesn't look like it'll be too hard for me to help ya! The main thig is that I've got some suggestions about better ways to structure your inventory system, and that'll take me a bit to post.

Good luck, and again sorry for my lack of response...=/
<qpHalcy0n> decided to paint the office, now i'm high and my hands hurt
TheLividePianoist
Chaos Rift Newbie
Chaos Rift Newbie
Posts: 15
Joined: Thu Jan 29, 2009 5:48 pm

Re: Code Help (ARCE)

Post by TheLividePianoist »

Oh no problem, thanks for the reply though and since you have suggestions...any thing from you would be great.
User avatar
eatcomics
ES Beta Backer
ES Beta Backer
Posts: 2528
Joined: Sat Mar 08, 2008 7:52 pm
Location: Illinois

Re: Code Help (ARCE)

Post by eatcomics »

I think when it said subtract those numbers it was meant to make logline3 = logline 4... That is how I would do it, just make each one change to the next one.
Image
TheLividePianoist
Chaos Rift Newbie
Chaos Rift Newbie
Posts: 15
Joined: Thu Jan 29, 2009 5:48 pm

Re: Code Help (ARCE)

Post by TheLividePianoist »

Well, I tried that and I thought It would work too but what happens instead is:

Say logline2$ read "Nice bunch of chaps.", logline3$ read "Hi, name's charlie. Fancy meeting you here!" and logline4$ read "Elysian Shadows ROCK!".

Using your suggestion and what I've done already: make logline2$ = logline3$ and logline3$ = logline4$.
The string in logline2$ would then take over logline3$ but then logline3$ which was just recently changed to the string in logline2$ can't equal logline4$ or else, logline4$ would be the same string as logline2$. Very complicated the way I put it but I guess that would only work if I'm only changing 1 line. Hope I didn't confuse you up.
User avatar
MarauderIIC
Respected Programmer
Respected Programmer
Posts: 3406
Joined: Sat Jul 10, 2004 3:05 pm
Location: Maryland, USA

Re: Code Help (ARCE)

Post by MarauderIIC »

If you're scrolling up and $log1 is at the top,

$log1 = $log2
$log2 = $log3
$log3 = $log4
$log4 = blank

Order is important.
I realized the moment I fell into the fissure that the book would not be destroyed as I had planned.
User avatar
eatcomics
ES Beta Backer
ES Beta Backer
Posts: 2528
Joined: Sat Mar 08, 2008 7:52 pm
Location: Illinois

Re: Code Help (ARCE)

Post by eatcomics »

MarauderIIC wrote:If you're scrolling up and $log1 is at the top,

$log1 = $log2
$log2 = $log3
$log3 = $log4
$log4 = blank

Order is important.
Yeah sorry, I didn't put too much effort into my previous post... :(
Image
TheLividePianoist
Chaos Rift Newbie
Chaos Rift Newbie
Posts: 15
Joined: Thu Jan 29, 2009 5:48 pm

Re: Code Help (ARCE)

Post by TheLividePianoist »

So I just sat down, trying to figure out the problem and gave the code a couple tweaks. Unfortunately, I've come to realize that the whole advlog system (which was horrible and terribly written) must be wiped and redone probably as a proper TYPE or array (nah...types are better). I will have to work on Chest Functions for those temporary "invisible items" the player will obtain when in collision with chest on open frame. I will wipe out the whole Advlog System tomorrow including the chest functions and re-write it when I see the examples ARCE is doing. Once again thanks and I appreciate it. This goes out to everyone else that contributed ideas as well. Right now though, it's approaching 1 o'clock and I best to be getting some rest.

Maybe something like this (Introduce your own suggestions or better approaches on how to do it):

Code: Select all

;This way I'm doing it would take me for ever seeing as I'd have to enter a string for each line and declare it's Y coordinate. Better approaches are welcome!

Type advlog
	Field logline1$ 
	Field logline2$ 
	Field logline3$
	Field logline4$ 
	Field logline1y
	Field logline2y
	Field logline3y 
	Field logline4y
End Type

addline.advlog = New advlog
addline.advlog\logline1$ = "" 
addline.advlog\logline2$ = "" 
addline.advlog\logline3$ = ""
addline.advlog\logline4$ = "" 
addline.advlog\logline1y = 450 
addline.advlog\logline2y = 435
addline.advlog\logline3y = 420 
addline.advlog\logline4y = 405 

;Skip to Text Area 
Text 200,390, "Adventure Log"
Text 200,addline\logline1y, addline\logline1$ 
Text 200,addline\logline2y, addline\logline2$ 
Text 200,addline\logline3y, addline\logline3$ 
Text 200,addline\logline4y, addline\logline4$ 
I don't know any GUI programming (the events and all that) but I'll probably just create an Adventure Log image and place the loglines within it's size.
User avatar
Arce
Jealous Self-Righteous Prick
Jealous Self-Righteous Prick
Posts: 2153
Joined: Mon Jul 10, 2006 9:29 pm

Re: Code Help (ARCE)

Post by Arce »

FUCKCKCKCKCKCK!
I posted an ENTIRE FUCKING TUTORIAL AND MY IT FUCKING TIMED OUT AND I LOST IT ALL!!

FUCK FUCK!

Anyway, here's the source and an example or a working log. When I get more time (hopefully tomorrow) I'll repost the fucking turorial

Sorry for inconviences...

Code: Select all

Graphics 640,480


Type AdventureLog
	Field logline.LogLine[3]
	Field w,h,x,y
	Field r,g,b
End Type 

Type LogLine
	Field logline$
	Field x,y
	Field r,g,b
End Type 

Global AdvLog.AdventureLog = New AdventureLog
initializeLog()

Repeat
	Cls 
		drawLog()
		If KeyHit(1) End
		If KeyHit(200) Then addLogLine("Suck my cock bitch!",255,0,255)
		If KeyHit(208) Then addLogLine("Sorry for the statement above.",255,255,255)
		If KeyHit(203) Then clearLog()
	Flip 
Forever 

Function initializeLog()
	AdvLog\Logline[1]=New Logline
	AdvLog\Logline[2]=New Logline
	AdvLog\Logline[3]=New Logline

	AdvLog\w=250
	AdvLog\h=100
	AdvLog\x=380
	AdvLog\y=10

	AdvLog\r=255
	AdvLog\g=0
	AdvLog\b=0

	AdvLog\LogLine[1]\logline$="ass"
	AdvLog\LogLine[1]\x=10
	AdvLog\LogLine[1]\y=40
	AdvLog\LogLine[1]\r=0
	AdvLog\LogLine[1]\g=255
	AdvLog\LogLine[1]\b=255


	AdvLog\LogLine[2]\logline$="hole"
	AdvLog\LogLine[2]\x=10
	AdvLog\LogLine[2]\y=55
	AdvLog\LogLine[2]\r=255
	AdvLog\LogLine[2]\g=255
	AdvLog\LogLine[2]\b=255

	AdvLog\LogLine[3]\logline$="BAM"
	AdvLog\LogLine[3]\x=10
	AdvLog\LogLine[3]\y=70
	AdvLog\LogLine[3]\r=255
	AdvLog\LogLine[3]\g=255
	AdvLog\LogLine[3]\b=255
End Function

Function drawLog()
	Color AdvLog\r,AdvLog\g,AdvLog\b
	Rect AdvLog\x,AdvLog\y,AdvLog\w,AdvLog\h,0
	Rect AdvLog\x,AdvLog\y,AdvLog\w,15,1
	
	Color 255,255,255
	Text AdvLog\x+ (AdvLog\w / 2) - 45,AdvLog\y,"Adventure Log"

	
	For i = 1 To 3
		Color AdvLog\LogLine[i]\r,AdvLog\LogLine[i]\g,AdvLog\LogLine[i]\b
		Text (AdvLog\x + AdvLog\LogLine[i]\x),(AdvLog\y + AdvLog\LogLine[i]\y),AdvLog\LogLine[i]\logline$
	Next
	
End Function 

Function clearLog()
	For i = 1 To 3
		AdvLog\LogLine[i]\logline$=""
		AdvLog\LogLine[i]\r=0
		AdvLog\LogLine[i]\g=0
		AdvLog\LogLine[i]\b=0
	Next 
End Function 

Function addLogLine(newline$,r,g,b)
	If AdvLog\LogLine[3]\logline$="" Then 
		AdvLog\LogLine[3]\logline$=newline$
		AdvLog\LogLine[3]\r=r
		AdvLog\LogLine[3]\g=g
		AdvLog\LogLine[3]\b=b
	Else
		AdvLog\LogLine[1]\logline$=AdvLog\LogLine[2]\LogLine$
			AdvLog\LogLine[1]\r=AdvLog\LogLine[2]\r
			AdvLog\LogLine[1]\g=AdvLog\LogLine[2]\g
			AdvLog\LogLine[1]\b=AdvLog\LogLine[2]\b
		
		AdvLog\LogLine[2]\logline$=AdvLog\LogLine[3]\LogLine$
			AdvLog\LogLine[2]\r=AdvLog\LogLine[3]\r
			AdvLog\LogLine[2]\g=AdvLog\LogLine[3]\g
			AdvLog\LogLine[2]\b=AdvLog\LogLine[3]\b
		
		AdvLog\LogLine[3]\logline$=newline$
			AdvLog\LogLine[3]\r=r
			AdvLog\LogLine[3]\g=g
			AdvLog\LogLine[3]\b=b
	EndIf 
End Function 
Aw, shit, extension .bb not allowed. I"m giving myself admin powers when i get home...=/
Output of above source
Output of above source
output.PNG (10.31 KiB) Viewed 1423 times
<qpHalcy0n> decided to paint the office, now i'm high and my hands hurt
User avatar
M_D_K
Chaos Rift Demigod
Chaos Rift Demigod
Posts: 1087
Joined: Tue Oct 28, 2008 10:33 am
Favorite Gaming Platforms: PC
Programming Language of Choice: C/++
Location: UK

Re: Code Help (ARCE)

Post by M_D_K »

Nice Arce. If I wasn't using my console as main engine output I'd put something of similar design in.
...Fuck it. I'll put that in tooSome day
Gyro Sheen wrote:you pour their inventory onto my life
IRC wrote: <sparda> The routine had a stack overflow, sorry.
<sparda> Apparently the stack was full of shit.
User avatar
MarauderIIC
Respected Programmer
Respected Programmer
Posts: 3406
Joined: Sat Jul 10, 2004 3:05 pm
Location: Maryland, USA

Re: Code Help (ARCE)

Post by MarauderIIC »

Arce wrote:Aw, shit, extension .bb not allowed. I"m giving myself admin powers when i get home...=/
Or you could just attach a .txt in the meantime. Also, it's allowed now.
I realized the moment I fell into the fissure that the book would not be destroyed as I had planned.
TheLividePianoist
Chaos Rift Newbie
Chaos Rift Newbie
Posts: 15
Joined: Thu Jan 29, 2009 5:48 pm

Re: Code Help (ARCE)

Post by TheLividePianoist »

Thanks a lot man, just the code I need to work off of. I'd love to see the tut and I want to thank ya for taking out the time. I'll keep working tonight.
User avatar
eatcomics
ES Beta Backer
ES Beta Backer
Posts: 2528
Joined: Sat Mar 08, 2008 7:52 pm
Location: Illinois

Re: Code Help (ARCE)

Post by eatcomics »

Arce is very generous about code, he's always willing to help even if it means writing an entire program :mrgreen:
Image
User avatar
MarauderIIC
Respected Programmer
Respected Programmer
Posts: 3406
Joined: Sat Jul 10, 2004 3:05 pm
Location: Maryland, USA

Re: Code Help (ARCE)

Post by MarauderIIC »

Unfortunately he's usually also swamped.
I realized the moment I fell into the fissure that the book would not be destroyed as I had planned.
User avatar
eatcomics
ES Beta Backer
ES Beta Backer
Posts: 2528
Joined: Sat Mar 08, 2008 7:52 pm
Location: Illinois

Re: Code Help (ARCE)

Post by eatcomics »

That's the impression that I get...
Image
Post Reply